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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ shashawen(int);
void main() {
  int test[5010];
  int i;
  struct timeval start, end;
  gettimeofday(&start, NULL);
  for (i = 0; i < 5010; ++i)
    shashawen(test[i]);
  gettimeofday(&end, NULL);
  printf("%lf s used\n", (end.tv_sec - start.tv_sec) * 1000 +
                             (double)(end.tv_usec - start.tv_usec) / 1000);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e80,%rsp
lea    -0x4e68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movl   $0x0,-0x4e54(%rbp)
cmpl   $0x1392,-0x4e54(%rbp)
jge    118c <main+0x5c>
movslq -0x4e54(%rbp),%rax
mov    -0x4e50(%rbp,%rax,4),%edi
call   1030 <shashawen@plt>
mov    -0x4e54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e54(%rbp)
jmp    1155 <main+0x25>
lea    -0x4e78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x4e78(%rbp),%eax
sub    -0x4e68(%rbp),%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    -0x4e70(%rbp),%rax
sub    -0x4e60(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xe33(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
add    $0x4e80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x4e70,%rsp
xor    %ebx,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
cs nopw 0x0(%rax,%rax,1)
mov    0x20(%rsp,%rbx,4),%edi
call   1030 <shashawen@plt>
add    $0x1,%rbx
cmp    $0x1392,%rbx
jne    1150 <main+0x20>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    (%rsp),%eax
sub    0x10(%rsp),%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    0x8(%rsp),%rax
sub    0x18(%rsp),%rax
cvtsi2sd %rax,%xmm1
divsd  0xe68(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
lea    0xe61(%rip),%rdi
add    $0x4e70,%rsp
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [12 x i8] c"%lf s used\0A\00"
define void @main() {
%1 = alloca [5010 x i32]
%2 = alloca i32
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i32 0, i32* %2
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5010
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5010 x i32], [5010 x i32]* %1, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = call i32 @shashawen(i32 %13)
br label %15
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%23 = load i32, i32* %22
%24 = sub nsw i32 %21, %23
%25 = mul nsw i32 %24, 1000
%26 = sitofp i32 %25 to double
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%30 = load i64, i64* %29
%31 = sub nsw i64 %28, %30
%32 = sitofp i64 %31 to double
%33 = fdiv double %32, 1.000000e+03
%34 = fadd double %26, %33
%35 = fptosi double %34 to i32
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %35)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [12 x i8] c"%lf s used\0A\00"
define void @main() {
%1 = alloca [5010 x i32]
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast [5010 x i32]* %1 to i8*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %13, %8 ]
%10 = getelementptr inbounds [5010 x i32], [5010 x i32]* %1, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @shashawen(i32 %11)
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, 5010
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
%22 = mul nsw i32 %21, 1000
%23 = sitofp i32 %22 to double
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%27 = load i64, i64* %26
%28 = sub nsw i64 %25, %27
%29 = sitofp i64 %28 to double
%30 = fdiv double %29, 1.000000e+03
%31 = fadd double %30, %23
%32 = fptosi double %31 to i32
%33 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %32)
ret void
}