#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 /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  printf("gettimdofday = {%ld, %ld}\n", tv.tv_sec, tv.tv_usec);
  int i = 0;
  for (i = 0; i < 100000; i++)
    gettimeofday(&tv, NULL);
  printf("gettimdofday = {%ld, %ld}\n", tv.tv_sec, tv.tv_usec);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x186a0,-0x1c(%rbp)
jge    118b <main+0x6b>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <main+0x43>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x186a0,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x30>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [27 x i8] c"gettimdofday = {%ld, %ld}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
store i32 0, i32* %7
store i32 0, i32* %7
br label %14
14: ; preds = %19, %2
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 100000
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
br label %19
19: ; preds = %17
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %14
22: ; preds = %14
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %26)
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [27 x i8] c"gettimdofday = {%ld, %ld}\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
br label %11
11: ; preds = %2, %11
%12 = phi i32 [ 0, %2 ], [ %14, %11 ]
%13 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, 100000
br i1 %15, label %16, label %11
16: ; preds = %11
%17 = load i32, i32* %6
%18 = load i32, i32* %8
%19 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}