#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 {
  int tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int refreshtimeout(struct timeval *timeout, struct timeval timepass) {
  timeout->tv_sec = timeout->tv_sec - timepass.tv_sec;
  timeout->tv_usec = timeout->tv_usec - timepass.tv_usec;
  if (((timeout->tv_sec * 1000000) + timeout->tv_usec) <= 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<refreshtimeout>:
push   %rbp
mov    %rsp,%rbp
mov    %esi,-0x18(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rdi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sub    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
sub    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
imul   $0xf4240,(%rax),%eax
cltq
mov    -0x20(%rbp),%rcx
add    0x8(%rcx),%rax
cmp    $0x0,%rax
jg     115c <refreshtimeout+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    1163 <refreshtimeout+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<refreshtimeout>:
movslq (%rdi),%rax
movslq %esi,%rcx
sub    %rcx,%rax
mov    %eax,(%rdi)
mov    0x8(%rdi),%rcx
sub    %rdx,%rcx
mov    %rcx,0x8(%rdi)
imul   $0xf4240,%rax,%rdx
xor    %eax,%eax
add    %rcx,%rdx
setle  %al
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define i32 @refreshtimeout(%struct.timeval* %0, i32 %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval*
%7 = bitcast %struct.timeval* %5 to { i32, i64 }*
%8 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %7, i32 0, i32 0
store i32 %1, i32* %8
%9 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %7, i32 0, i32 1
store i64 %2, i64* %9
store %struct.timeval* %0, %struct.timeval** %6
%10 = load %struct.timeval*, %struct.timeval** %6
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%14 = load i32, i32* %13
%15 = sub nsw i32 %12, %14
%16 = load %struct.timeval*, %struct.timeval** %6
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
store i32 %15, i32* %17
%18 = load %struct.timeval*, %struct.timeval** %6
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%22 = load i64, i64* %21
%23 = sub nsw i64 %20, %22
%24 = load %struct.timeval*, %struct.timeval** %6
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
store i64 %23, i64* %25
%26 = load %struct.timeval*, %struct.timeval** %6
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = mul nsw i32 %28, 1000000
%30 = sext i32 %29 to i64
%31 = load %struct.timeval*, %struct.timeval** %6
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 1
%33 = load i64, i64* %32
%34 = add nsw i64 %30, %33
%35 = icmp sle i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %3
store i32 1, i32* %4
br label %38
37: ; preds = %3
store i32 0, i32* %4
br label %38
38: ; preds = %37, %36
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define i32 @refreshtimeout(%struct.timeval* nocapture %0, i32 %1, i64 %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = sub nsw i32 %5, %1
store i32 %6, i32* %4
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%8 = load i64, i64* %7
%9 = sub nsw i64 %8, %2
store i64 %9, i64* %7
%10 = mul nsw i32 %6, 1000000
%11 = sext i32 %10 to i64
%12 = add nsw i64 %9, %11
%13 = icmp slt i64 %12, 1
%14 = zext i1 %13 to i32
ret i32 %14
}