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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, void *);
void winsettmo(struct timeval *tmo, struct timeval *tmo_at) {
  struct timeval now;
  tmo->tv_sec = 2;
  tmo->tv_usec = 0;
  gettimeofday(&now, ((void *)0));
  do {
    (tmo_at)->tv_sec = (&now)->tv_sec + (tmo)->tv_sec;
    (tmo_at)->tv_usec = (&now)->tv_usec + (tmo)->tv_usec;
    if ((tmo_at)->tv_usec >= 1000000) {
      ++(tmo_at)->tv_sec;
      (tmo_at)->tv_usec -= 1000000;
    }
  } while (0);
}


x86 assembly (clang, -O0):
<winsettmo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x4(%rax)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0xf4240,0x4(%rax)
jl     118e <winsettmo+0x7e>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
sub    $0xf4240,%ecx
mov    %ecx,0x4(%rax)
jmp    1193 <winsettmo+0x83>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<winsettmo>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x2,(%rdi)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rbx),%eax
add    (%rsp),%eax
mov    %eax,(%r14)
mov    0x4(%rbx),%ecx
add    0x4(%rsp),%ecx
mov    %ecx,0x4(%r14)
cmp    $0xf4240,%ecx
jl     1156 <winsettmo+0x46>
add    $0x1,%eax
mov    %eax,(%r14)
add    $0xfff0bdc0,%ecx
mov    %ecx,0x4(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @winsettmo(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
store i32 2, i32* %5
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
store i32 0, i32* %6
%7 = call i32 @gettimeofday(%struct.timeval* %3, i8* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* %5
%11 = add nsw i32 %10, %9
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%14 = load i32, i32* %13
%15 = load i32, i32* %6
%16 = add nsw i32 %15, %14
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i32 %16, i32* %17
%18 = icmp sgt i32 %16, 999999
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = add nsw i32 %11, 1
store i32 %20, i32* %12
%21 = add nsw i32 %16, -1000000
store i32 %21, i32* %17
br label %22
22: ; preds = %19, %2
ret void
}