#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 */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  clock_t starting_time = clock();
  float run_time = ((float)clock() - (float)starting_time) / CLOCKS_PER_SEC;
  printf("-----------\n");
  printf("Program completed in: %f seconds\n", run_time);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ssq -0x10(%rbp),%xmm1
subss  %xmm1,%xmm0
mov    0x2e91(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
cvtsi2ss %rax,%xmm1
cvtsi2ss %rbx,%xmm0
subss  %xmm0,%xmm1
mov    0x2e8d(%rip),%rax
divss  (%rax),%xmm1
movss  %xmm1,0xc(%rsp)
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str = [13 x i8] c"-----------\0A\00"
@.str.1 = [34 x i8] c"Program completed in: %f seconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca float
store i32 0, i32* %1
%4 = call i64 (...) @clock()
store i64 %4, i64* %2
%5 = call i64 (...) @clock()
%6 = sitofp i64 %5 to float
%7 = load i64, i64* %2
%8 = sitofp i64 %7 to float
%9 = fsub float %6, %8
%10 = load float, float* @CLOCKS_PER_SEC
%11 = fdiv float %9, %10
store float %11, float* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = load float, float* %3
%14 = fpext float %13 to double
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %14)
ret i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [34 x i8] c"Program completed in: %f seconds\0A\00"
@str = [12 x i8] c"-----------\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sitofp i64 %2 to float
%4 = sitofp i64 %1 to float
%5 = fsub float %3, %4
%6 = load float, float* @CLOCKS_PER_SEC
%7 = fdiv float %5, %6
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%9 = fpext float %7 to double
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %9)
ret i32 0
}