#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 dummy;
};
typedef int /*<<< orphan*/ clockid_t;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void bench_gettimeofday(clockid_t clkid) {
  unsigned long loop;
  struct timeval tmpval;
  for (loop = 0; loop < 100000; loop++) {
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
    (void)gettimeofday(&tmpval, NULL);
  }
}


x86 assembly (clang, -O0):
<bench_gettimeofday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x186a0,-0x10(%rbp)
jae    11c4 <bench_gettimeofday+0xb4>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <bench_gettimeofday+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_gettimeofday>:
push   %r14
push   %rbx
push   %rax
mov    $0x186a0,%ebx
mov    %rsp,%r14
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
add    $0xffffffffffffffff,%rbx
jne    1120 <bench_gettimeofday+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @bench_gettimeofday(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca %struct.timeval
store i32 %0, i32* %2
store i64 0, i64* %3
br label %5
5: ; preds = %19, %1
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 100000
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%10 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%11 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%12 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%13 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%14 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%15 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%16 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%17 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%18 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
br label %19
19: ; preds = %8
%20 = load i64, i64* %3
%21 = add i64 %20, 1
store i64 %21, i64* %3
br label %5
22: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define void @bench_gettimeofday(i32 %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %16, %4 ]
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%8 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%9 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%10 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%11 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%12 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%13 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%14 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%15 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%16 = add nuw nsw i64 %5, 1
%17 = icmp eq i64 %16, 100000
br i1 %17, label %18, label %4
18: ; preds = %4
ret void
}