#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*/ tkh_timeval_normalize(struct timeval *);
void tkh_timeval_plus_eq(struct timeval *tv, const struct timeval *add_me) {
  tv->tv_sec += add_me->tv_sec;
  tv->tv_usec += add_me->tv_usec;
  if (tv->tv_usec >= 1000000) {
    tv->tv_sec += 1;
    tv->tv_usec -= 1000000;
  }
  tkh_timeval_normalize(tv);
}


x86 assembly (clang, -O0):
<tkh_timeval_plus_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
add    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0xf4240,0x4(%rax)
jl     116b <tkh_timeval_plus_eq+0x5b>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
sub    $0xf4240,%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <tkh_timeval_normalize@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tkh_timeval_plus_eq>:
mov    (%rdi),%ecx
mov    0x4(%rdi),%eax
add    (%rsi),%ecx
mov    %ecx,(%rdi)
add    0x4(%rsi),%eax
mov    %eax,0x4(%rdi)
cmp    $0xf4240,%eax
jl     1133 <tkh_timeval_plus_eq+0x23>
add    $0x1,%ecx
mov    %ecx,(%rdi)
add    $0xfff0bdc0,%eax
mov    %eax,0x4(%rdi)
jmp    1030 <tkh_timeval_normalize@plt>

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

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