#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;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ clock();
int /*<<< orphan*/ do_something();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, float, ...);
int main(int argc, char *argv[]) {
  clock_t t;
  t = clock();
  do_something();
  t = clock() - t;
  printf("Number of ticks per second %ld\n", CLOCKS_PER_SEC);
  printf("Number of ticks taken by program %ld and %f seconds\n", t,
         ((float)t) / CLOCKS_PER_SEC);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <do_something@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e6a(%rip),%rax
movss  (%rax),%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
cvtsi2ssq -0x18(%rbp),%xmm0
cvtsi2ssq -0x18(%rbp),%xmm1
mov    0x2e45(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe6e(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <do_something@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
sub    %r14,%rbx
mov    0x2e7f(%rip),%r14
movss  (%r14),%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
movaps %xmm0,%xmm1
divss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe89(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Number of ticks per second %ld\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [53 x i8] c"Number of ticks taken by program %ld and %f seconds\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 (...) @clock()
store i64 %7, i64* %6
%8 = call i32 (...) @do_something()
%9 = call i64 (...) @clock()
%10 = load i64, i64* %6
%11 = sub nsw i64 %9, %10
store i64 %11, i64* %6
%12 = load float, float* @CLOCKS_PER_SEC
%13 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), float %12)
%14 = load i64, i64* %6
%15 = sitofp i64 %14 to float
%16 = load i64, i64* %6
%17 = sitofp i64 %16 to float
%18 = load float, float* @CLOCKS_PER_SEC
%19 = fdiv float %17, %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), float %15, double %20)
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@.str = [32 x i8] c"Number of ticks per second %ld\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [53 x i8] c"Number of ticks taken by program %ld and %f seconds\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @clock()
%4 = tail call i32 (...) @do_something()
%5 = tail call i64 (...) @clock()
%6 = sub nsw i64 %5, %3
%7 = load float, float* @CLOCKS_PER_SEC
%8 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), float %7)
%9 = sitofp i64 %6 to float
%10 = load float, float* @CLOCKS_PER_SEC
%11 = fdiv float %9, %10
%12 = fpext float %11 to double
%13 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), float %9, double %12)
%14 = load i32, i32* @EXIT_SUCCESS
%15 = tail call i32 @exit(i32 %14)
unreachable
}