return 0;
 }
 
-static int emit_mod_ret_check_imm8(u8 **pprog, int value)
-{
-       u8 *prog = *pprog;
-       int cnt = 0;
-
-       if (!is_imm8(value))
-               return -EINVAL;
-
-       if (value == 0)
-               EMIT2(0x85, add_2reg(0xC0, BPF_REG_0, BPF_REG_0));
-       else
-               EMIT3(0x83, add_1reg(0xF8, BPF_REG_0), value);
-
-       *pprog = prog;
-       return 0;
-}
-
 static int invoke_bpf(const struct btf_func_model *m, u8 **pprog,
                      struct bpf_tramp_progs *tp, int stack_size)
 {
                              u8 **branches)
 {
        u8 *prog = *pprog;
-       int i;
+       int i, cnt = 0;
 
        /* The first fmod_ret program will receive a garbage return value.
         * Set this to 0 to avoid confusing the program.
                if (invoke_bpf_prog(m, &prog, tp->progs[i], stack_size, true))
                        return -EINVAL;
 
-               /* Generate a branch:
-                *
-                * if (ret !=  0)
+               /* mod_ret prog stored return value into [rbp - 8]. Emit:
+                * if (*(u64 *)(rbp - 8) !=  0)
                 *      goto do_fexit;
-                *
-                * If needed this can be extended to any integer value which can
-                * be passed by user-space when the program is loaded.
                 */
-               if (emit_mod_ret_check_imm8(&prog, 0))
-                       return -EINVAL;
+               /* cmp QWORD PTR [rbp - 0x8], 0x0 */
+               EMIT4(0x48, 0x83, 0x7d, 0xf8); EMIT1(0x00);
 
                /* Save the location of the branch and Generate 6 nops
                 * (4 bytes for an offset and 2 bytes for the jump) These nops