#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ code();
int /*<<< orphan*/ printf(char *, double);
int main() {
  clock_t t;
  printf("start: %d \n", (int)(t = clock()));
  code();
  printf("stop: %d \n", (int)(t = clock() - t));
  printf("Elapsed: %f seconds\n", (double)t / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
cvtsi2sd %eax,%xmm0
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <code@plt>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cvtsi2sd %eax,%xmm0
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
cvtsi2sdq -0x10(%rbp),%xmm0
mov    0x2e5b(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
cvtsi2sd %r14d,%xmm0
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <code@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
sub    %r14,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mov    0x2e63(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"start: %d \0A\00"
@.str.1 = [11 x i8] c"stop: %d \0A\00"
@.str.2 = [21 x i8] c"Elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @clock()
store i64 %3, i64* %2
%4 = trunc i64 %3 to i32
%5 = sitofp i32 %4 to double
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %5)
%7 = call i32 (...) @code()
%8 = call i64 (...) @clock()
%9 = load i64, i64* %2
%10 = sub nsw i64 %8, %9
store i64 %10, i64* %2
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = load i64, i64* %2
%15 = sitofp i64 %14 to double
%16 = load double, double* @CLOCKS_PER_SEC
%17 = fdiv double %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"start: %d \0A\00"
@.str.1 = [11 x i8] c"stop: %d \0A\00"
@.str.2 = [21 x i8] c"Elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = trunc i64 %1 to i32
%3 = sitofp i32 %2 to double
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %3)
%5 = tail call i32 (...) @code()
%6 = tail call i64 (...) @clock()
%7 = sub nsw i64 %6, %1
%8 = trunc i64 %7 to i32
%9 = sitofp i32 %8 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = sitofp i64 %7 to double
%12 = load double, double* @CLOCKS_PER_SEC
%13 = fdiv double %11, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %13)
ret i32 0
}