#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct tvec_base {
  int dummy;
};
struct gf_tw_timer_list {
  int dummy;
};

/* Variables and functions */
int __detach_if_pending(struct gf_tw_timer_list *);
int /*<<< orphan*/ __gf_tw_add_timer(struct tvec_base *,
                                     struct gf_tw_timer_list *);
int __mod_timer(struct tvec_base *base, struct gf_tw_timer_list *timer,
                int pending_only) {
  int ret = 0;
  ret = __detach_if_pending(timer);
  if (!ret && pending_only)
    goto done;
  ret = 1;
  __gf_tw_add_timer(base, timer);
done:
  return ret;
}


x86 assembly (clang, -O0):
<__mod_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <__detach_if_pending@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    115f <__mod_timer+0x3f>
cmpl   $0x0,-0x14(%rbp)
je     115f <__mod_timer+0x3f>
jmp    1173 <__mod_timer+0x53>
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <__gf_tw_add_timer@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__mod_timer>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <__detach_if_pending@plt>
test   %ebp,%ebp
je     1140 <__mod_timer+0x20>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     1150 <__mod_timer+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <__gf_tw_add_timer@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tvec_base = type { i32 }
%struct.gf_tw_timer_list = type { i32 }
define i32 @__mod_timer(%struct.tvec_base* %0, %struct.gf_tw_timer_list* %1, i32 %2) {
%4 = alloca %struct.tvec_base*
%5 = alloca %struct.gf_tw_timer_list*
%6 = alloca i32
%7 = alloca i32
store %struct.tvec_base* %0, %struct.tvec_base** %4
store %struct.gf_tw_timer_list* %1, %struct.gf_tw_timer_list** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load %struct.gf_tw_timer_list*, %struct.gf_tw_timer_list** %5
%9 = call i32 @__detach_if_pending(%struct.gf_tw_timer_list* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %20
16: ; preds = %12, %3
store i32 1, i32* %7
%17 = load %struct.tvec_base*, %struct.tvec_base** %4
%18 = load %struct.gf_tw_timer_list*, %struct.gf_tw_timer_list** %5
%19 = call i32 @__gf_tw_add_timer(%struct.tvec_base* %17, %struct.gf_tw_timer_list* %18)
br label %20
20: ; preds = %16, %15
%21 = load i32, i32* %7
ret i32 %21
}

LLVM IR (-O2):
%struct.tvec_base = type { i32 }
%struct.gf_tw_timer_list = type { i32 }
define i32 @__mod_timer(%struct.tvec_base* %0, %struct.gf_tw_timer_list* %1, i32 %2) {
%4 = tail call i32 @__detach_if_pending(%struct.gf_tw_timer_list* %1)
%5 = icmp eq i32 %4, 0
%6 = icmp ne i32 %2, 0
%7 = and i1 %6, %5
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @__gf_tw_add_timer(%struct.tvec_base* %0, %struct.gf_tw_timer_list* %1)
br label %10
10: ; preds = %3, %8
%11 = phi i32 [ 0, %3 ], [ 1, %8 ]
ret i32 %11
}