#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 timeval {
  scalar_t__ tv_sec;
  scalar_t__ tv_usec;
};
typedef int /*<<< orphan*/ now;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct timeval *, int /*<<< orphan*/, int);
int iscsi_timer_expired(struct timeval *timer) {
  struct timeval now;
  if ((timer == NULL) || ((timer->tv_sec == 0) && (timer->tv_usec == 0)))
    return 0;
  memset(&now, 0, sizeof(now));
  gettimeofday(&now, NULL);
  if (now.tv_sec > timer->tv_sec)
    return 1;
  if ((now.tv_sec == timer->tv_sec) && (now.tv_usec >= timer->tv_usec))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<iscsi_timer_expired>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1154 <iscsi_timer_expired+0x34>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1160 <iscsi_timer_expired+0x40>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1160 <iscsi_timer_expired+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <iscsi_timer_expired+0xb0>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jle    119a <iscsi_timer_expired+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <iscsi_timer_expired+0xb0>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    11c9 <iscsi_timer_expired+0xa9>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jl     11c9 <iscsi_timer_expired+0xa9>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <iscsi_timer_expired+0xb0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iscsi_timer_expired>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
test   %rdi,%rdi
je     117a <iscsi_timer_expired+0x5a>
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
jne    113e <iscsi_timer_expired+0x1e>
cmpq   $0x0,0x8(%rbx)
je     117a <iscsi_timer_expired+0x5a>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rbx),%rcx
mov    $0x1,%eax
cmp    %rcx,0x8(%rsp)
jg     117a <iscsi_timer_expired+0x5a>
jne    1178 <iscsi_timer_expired+0x58>
mov    0x10(%rsp),%rcx
cmp    0x8(%rbx),%rcx
jge    117a <iscsi_timer_expired+0x5a>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define i32 @iscsi_timer_expired(%struct.timeval* %0) {
%2 = alloca i32
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %3
%5 = load %struct.timeval*, %struct.timeval** %3
%6 = icmp eq %struct.timeval* %5, null
br i1 %6, label %17, label %7
7: ; preds = %1
%8 = load %struct.timeval*, %struct.timeval** %3
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load %struct.timeval*, %struct.timeval** %3
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%15 = load i64, i64* %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12, %1
store i32 0, i32* %2
br label %44
18: ; preds = %12, %7
%19 = call i32 @memset(%struct.timeval* %4, i32 0, i32 16)
%20 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%22 = load i64, i64* %21
%23 = load %struct.timeval*, %struct.timeval** %3
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = icmp sgt i64 %22, %25
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 1, i32* %2
br label %44
28: ; preds = %18
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%30 = load i64, i64* %29
%31 = load %struct.timeval*, %struct.timeval** %3
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 0
%33 = load i64, i64* %32
%34 = icmp eq i64 %30, %33
br i1 %34, label %35, label %43
35: ; preds = %28
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%37 = load i64, i64* %36
%38 = load %struct.timeval*, %struct.timeval** %3
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %38, i32 0, i32 1
%40 = load i64, i64* %39
%41 = icmp sge i64 %37, %40
br i1 %41, label %42, label %43
42: ; preds = %35
store i32 1, i32* %2
br label %44
43: ; preds = %35, %28
store i32 0, i32* %2
br label %44
44: ; preds = %43, %42, %27, %17
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define i32 @iscsi_timer_expired(%struct.timeval* %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = icmp eq %struct.timeval* %0, null
br i1 %4, label %29, label %5
5: ; preds = %1
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i64, i64* %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load i64, i64* %10
%12 = icmp eq i64 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %9, %5
%14 = call i32 @memset(%struct.timeval* %2, i32 0, i32 16)
%15 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* %6
%19 = icmp sgt i64 %17, %18
br i1 %19, label %29, label %20
20: ; preds = %13
%21 = icmp eq i64 %17, %18
br i1 %21, label %22, label %28
22: ; preds = %20
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%26 = load i64, i64* %25
%27 = icmp slt i64 %24, %26
br i1 %27, label %28, label %29
28: ; preds = %22, %20
br label %29
29: ; preds = %22, %13, %1, %9, %28
%30 = phi i32 [ 0, %28 ], [ 0, %9 ], [ 0, %1 ], [ 1, %13 ], [ 1, %22 ]
ret i32 %30
}