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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void compute(unsigned usec) {
  struct timeval tv1, tv2;
  gettimeofday(&tv1, NULL);
  do {
    gettimeofday(&tv2, NULL);
  } while (((tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec)) <
           usec);
}


x86 assembly (clang, -O0):
<compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x10(%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    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x14(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    %ecx,%eax
cmp    -0x4(%rbp),%eax
jb     1128 <compute+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r15d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x10(%rsp),%ebp
mov    0x14(%rsp),%ebx
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    %ebp,%eax
mov    0xc(%rsp),%ecx
sub    %ebx,%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
cmp    %r15d,%eax
jb     1140 <compute+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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