#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();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int proc(int *);
int /*<<< orphan*/ puts(char *);
int main() {
  puts("hello");
  int i;
  int *a = (int *)malloc(400000000 * sizeof(int));
  for (i = 0; i < 400000000; i++)
    a[i] = i;
  clock_t begin, end;
  double time_spent;
  puts("start timer");
  begin = clock();
  int res = proc(a);
  end = clock();
  puts("end timer");
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("Time: %f\n", time_spent);
  printf("Res: %d\n", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5f5e1000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x17d78400,-0x8(%rbp)
jge    11a9 <main+0x59>
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x30>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <proc@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2df1(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe0b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5f5e1000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movdqa 0xe8b(%rip),%xmm0
mov    $0x24,%eax
movdqa 0xe8d(%rip),%xmm8
movdqa 0xe94(%rip),%xmm9
movdqa 0xe9b(%rip),%xmm10
movdqa 0xea2(%rip),%xmm11
movdqa 0xea9(%rip),%xmm12
movdqa 0xeb1(%rip),%xmm6
movdqa 0xeb9(%rip),%xmm7
movdqa 0xec1(%rip),%xmm1
movdqa 0xec9(%rip),%xmm2
movdqa 0xed1(%rip),%xmm3
nop
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqu %xmm0,-0x90(%rbx,%rax,4)
ff ff
movdqu %xmm4,-0x80(%rbx,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqu %xmm4,-0x70(%rbx,%rax,4)
movdqu %xmm5,-0x60(%rbx,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqu %xmm4,-0x50(%rbx,%rax,4)
movdqu %xmm5,-0x40(%rbx,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqu %xmm4,-0x30(%rbx,%rax,4)
movdqu %xmm5,-0x20(%rbx,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqu %xmm4,-0x10(%rbx,%rax,4)
movdqu %xmm5,(%rbx,%rax,4)
paddd  %xmm3,%xmm0
add    $0x28,%rax
cmp    $0x17d78424,%rax
jne    11d0 <main+0x80>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <proc@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
sub    %r14,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mov    0x2d31(%rip),%rax
divsd  (%rax),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe06(%rip),%rdi
call   1050 <printf@plt>
lea    0xe04(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [12 x i8] c"start timer\00"
@.str.2 = [10 x i8] c"end timer\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [10 x i8] c"Time: %f\0A\00"
@.str.4 = [9 x i8] c"Res: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @malloc(i32 1600000000)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %3
store i32 0, i32* %2
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 400000000
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %2
%16 = load i32*, i32** %3
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 %15, i32* %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %11
23: ; preds = %11
%24 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = call i64 (...) @clock()
store i64 %25, i64* %4
%26 = load i32*, i32** %3
%27 = call i32 @proc(i32* %26)
store i32 %27, i32* %7
%28 = call i64 (...) @clock()
store i64 %28, i64* %5
%29 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%30 = load i64, i64* %5
%31 = load i64, i64* %4
%32 = sub nsw i64 %30, %31
%33 = sitofp i64 %32 to double
%34 = load double, double* @CLOCKS_PER_SEC
%35 = fdiv double %33, %34
store double %35, double* %6
%36 = load double, double* %6
%37 = fptosi double %36 to i32
%38 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %7
%40 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [12 x i8] c"start timer\00"
@.str.2 = [10 x i8] c"end timer\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [10 x i8] c"Time: %f\0A\00"
@.str.4 = [9 x i8] c"Res: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @malloc(i32 1600000000)
%3 = inttoptr i64 %2 to i32*
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ 0, %0 ], [ %40, %4 ]
%6 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %41, %4 ]
%7 = add <4 x i32> %6, <i32 4, i32 4, i32 4, i32 4>
%8 = getelementptr inbounds i32, i32* %3, i64 %5
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %6, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %8, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %11
%12 = add nuw nsw i64 %5, 8
%13 = add <4 x i32> %6, <i32 8, i32 8, i32 8, i32 8>
%14 = add <4 x i32> %6, <i32 12, i32 12, i32 12, i32 12>
%15 = getelementptr inbounds i32, i32* %3, i64 %12
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %15, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %18
%19 = add nuw nsw i64 %5, 16
%20 = add <4 x i32> %6, <i32 16, i32 16, i32 16, i32 16>
%21 = add <4 x i32> %6, <i32 20, i32 20, i32 20, i32 20>
%22 = getelementptr inbounds i32, i32* %3, i64 %19
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %23
%24 = getelementptr inbounds i32, i32* %22, i64 4
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %25
%26 = add nuw nsw i64 %5, 24
%27 = add <4 x i32> %6, <i32 24, i32 24, i32 24, i32 24>
%28 = add <4 x i32> %6, <i32 28, i32 28, i32 28, i32 28>
%29 = getelementptr inbounds i32, i32* %3, i64 %26
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %30
%31 = getelementptr inbounds i32, i32* %29, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %32
%33 = add nuw nsw i64 %5, 32
%34 = add <4 x i32> %6, <i32 32, i32 32, i32 32, i32 32>
%35 = add <4 x i32> %6, <i32 36, i32 36, i32 36, i32 36>
%36 = getelementptr inbounds i32, i32* %3, i64 %33
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %37
%38 = getelementptr inbounds i32, i32* %36, i64 4
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> %35, <4 x i32>* %39
%40 = add nuw nsw i64 %5, 40
%41 = add <4 x i32> %6, <i32 40, i32 40, i32 40, i32 40>
%42 = icmp eq i64 %40, 400000000
br i1 %42, label %43, label %4
43: ; preds = %4
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%45 = tail call i64 (...) @clock()
%46 = tail call i32 @proc(i32* %3)
%47 = tail call i64 (...) @clock()
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%49 = sub nsw i64 %47, %45
%50 = sitofp i64 %49 to double
%51 = load double, double* @CLOCKS_PER_SEC
%52 = fdiv double %50, %51
%53 = fptosi double %52 to i32
%54 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %46)
ret i32 0
}