#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 */
typedef int suseconds_t;
struct timeval {
  int tv_usec;
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void incrementTimeval(struct timeval *time, suseconds_t increment) {
  assert(time != NULL);
  assert(0 <= time->tv_usec && time->tv_usec < 1000000);
  if (increment >= 1000000) {
    time->tv_sec += (increment / 1000000);
    increment = increment % 1000000;
  }
  assert(increment < 1000000);
  time->tv_usec += increment;
  if (time->tv_usec >= 1000000) {
    time->tv_sec += 1;
    time->tv_usec -= 1000000;
    assert(0 <= time->tv_usec && time->tv_usec < 1000000);
  }
}


x86 assembly (clang, -O0):
<incrementTimeval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    (%rdx),%ecx
mov    %al,-0xd(%rbp)
jg     1154 <incrementTimeval+0x44>
mov    -0x8(%rbp),%rax
cmpl   $0xf4240,(%rax)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xf4240,-0xc(%rbp)
jl     1193 <incrementTimeval+0x83>
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
add    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0xf4240,-0xc(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0xf4240,(%rax)
jl     120d <incrementTimeval+0xfd>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
sub    $0xf4240,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    (%rdx),%ecx
mov    %al,-0xe(%rbp)
jg     1200 <incrementTimeval+0xf0>
mov    -0x8(%rbp),%rax
cmpl   $0xf4240,(%rax)
setl   %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<incrementTimeval>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0xf4240,(%r14)
setb   %dil
call   1030 <assert@plt>
cmp    $0xf4240,%ebx
jl     115a <incrementTimeval+0x4a>
mov    %ebx,%eax
imul   $0x431bde83,%rax,%rax
shr    $0x32,%rax
add    %eax,0x4(%r14)
imul   $0xf4240,%eax,%eax
sub    %eax,%ebx
mov    $0x1,%edi
call   1030 <assert@plt>
add    (%r14),%ebx
mov    %ebx,(%r14)
cmp    $0xf4240,%ebx
jl     1198 <incrementTimeval+0x88>
addl   $0x1,0x4(%r14)
lea    -0xf4240(%rbx),%eax
mov    %eax,(%r14)
xor    %edi,%edi
cmp    $0x1e8480,%ebx
setb   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @incrementTimeval(%struct.timeval* %0, i32 %1) {
%3 = alloca %struct.timeval*
%4 = alloca i32
store %struct.timeval* %0, %struct.timeval** %3
store i32 %1, i32* %4
%5 = load %struct.timeval*, %struct.timeval** %3
%6 = icmp ne %struct.timeval* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load %struct.timeval*, %struct.timeval** %3
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = icmp sle i32 0, %11
br i1 %12, label %13, label %18
13: ; preds = %2
%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 = icmp slt i32 %16, 1000000
br label %18
18: ; preds = %13, %2
%19 = phi i1 [ false, %2 ], [ %17, %13 ]
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 1000000
br i1 %23, label %24, label %33
24: ; preds = %18
%25 = load i32, i32* %4
%26 = sdiv i32 %25, 1000000
%27 = load %struct.timeval*, %struct.timeval** %3
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = add nsw i32 %29, %26
store i32 %30, i32* %28
%31 = load i32, i32* %4
%32 = srem i32 %31, 1000000
store i32 %32, i32* %4
br label %33
33: ; preds = %24, %18
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 1000000
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %4
%39 = load %struct.timeval*, %struct.timeval** %3
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = add nsw i32 %41, %38
store i32 %42, i32* %40
%43 = load %struct.timeval*, %struct.timeval** %3
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = icmp sge i32 %45, 1000000
br i1 %46, label %47, label %69
47: ; preds = %33
%48 = load %struct.timeval*, %struct.timeval** %3
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
%52 = load %struct.timeval*, %struct.timeval** %3
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = sub nsw i32 %54, 1000000
store i32 %55, i32* %53
%56 = load %struct.timeval*, %struct.timeval** %3
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = icmp sle i32 0, %58
br i1 %59, label %60, label %65
60: ; preds = %47
%61 = load %struct.timeval*, %struct.timeval** %3
%62 = getelementptr inbounds %struct.timeval, %struct.timeval* %61, i32 0, i32 0
%63 = load i32, i32* %62
%64 = icmp slt i32 %63, 1000000
br label %65
65: ; preds = %60, %47
%66 = phi i1 [ false, %47 ], [ %64, %60 ]
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
br label %69
69: ; preds = %65, %33
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @incrementTimeval(%struct.timeval* %0, i32 %1) {
%3 = icmp ne %struct.timeval* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i32, i32* %6
%8 = icmp ult i32 %7, 1000000
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp sgt i32 %1, 999999
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = udiv i32 %1, 1000000
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %13
store i32 %16, i32* %14
%17 = urem i32 %1, 1000000
br label %18
18: ; preds = %12, %2
%19 = phi i32 [ %17, %12 ], [ %1, %2 ]
%20 = tail call i32 @assert(i32 1)
%21 = load i32, i32* %6
%22 = add nsw i32 %21, %19
store i32 %22, i32* %6
%23 = icmp sgt i32 %22, 999999
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = add nsw i32 %22, -1000000
store i32 %28, i32* %6
%29 = icmp ult i32 %22, 2000000
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
br label %32
32: ; preds = %24, %18
ret void
}