#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ cpu_relax();
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char *argv[]) {
  const int n = (argc > 1) ? atoi(argv[1]) : 1000;
  double t0 = omp_get_wtime();
  for (int i = 0; i < n; i++) {
    cpu_relax();
  }
  double t1 = omp_get_wtime();
  printf("dt = %lf\n", t1 - t0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x34(%rbp)
jmp    1182 <main+0x42>
mov    $0x3e8,%eax
mov    %eax,-0x34(%rbp)
jmp    1182 <main+0x42>
mov    -0x34(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bc <main+0x7c>
mov    $0x0,%al
call   1050 <cpu_relax@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119b <main+0x5b>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1168 <main+0x28>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
test   %ebx,%ebx
jg     1180 <main+0x40>
jmp    118c <main+0x4c>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3e8,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <cpu_relax@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x40>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"dt = %lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ %16, %12 ], [ 1000, %17 ]
store i32 %19, i32* %6
%20 = call double (...) @omp_get_wtime()
store double %20, double* %7
store i32 0, i32* %8
br label %21
21: ; preds = %27, %18
%22 = load i32, i32* %8
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 (...) @cpu_relax()
br label %27
27: ; preds = %25
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %21
30: ; preds = %21
%31 = call double (...) @omp_get_wtime()
store double %31, double* %9
%32 = load double, double* %9
%33 = load double, double* %7
%34 = fsub double %32, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"dt = %lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call double (...) @omp_get_wtime()
br label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call double (...) @omp_get_wtime()
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %15
12: ; preds = %4, %6
%13 = phi double [ %5, %4 ], [ %10, %6 ]
%14 = phi i32 [ 1000, %4 ], [ %9, %6 ]
br label %20
15: ; preds = %20, %6
%16 = phi double [ %10, %6 ], [ %13, %20 ]
%17 = tail call double (...) @omp_get_wtime()
%18 = fsub double %17, %16
%19 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %18)
ret i32 0
20: ; preds = %12, %20
%21 = phi i32 [ %23, %20 ], [ 0, %12 ]
%22 = tail call i32 (...) @cpu_relax()
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %14
br i1 %24, label %15, label %20
}