#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 int /*<<< orphan*/ time_t;

/* Variables and functions */
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  time_t start;
  time_t stop;
  int i, j;
  int *p;
  double res;
  time(&start);
  for (i = 0; i < 90000; i++) {
    p = (int *)malloc(100000 * sizeof(int));
    for (j = 0; j < 100000; j++) {
      *(p + j) = j;
    }
    free(p);
  }
  time(&stop);
  res = difftime(stop, start);
  printf("%f\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <time@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x15f90,-0x10(%rbp)
jge    11d1 <main+0x81>
mov    $0x61a80,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x186a0,-0x14(%rbp)
jge    11ba <main+0x6a>
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <main+0x41>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <main+0x1f>
lea    -0xc(%rbp),%rdi
call   1060 <time@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1060 <time@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x61a80,%edi
call   1070 <malloc@plt>
mov    $0x24,%ecx
movdqa 0xe79(%rip),%xmm0
movdqa 0xe80(%rip),%xmm8
movdqa 0xe87(%rip),%xmm9
movdqa 0xe8e(%rip),%xmm10
movdqa 0xe95(%rip),%xmm11
movdqa 0xe9c(%rip),%xmm12
movdqa 0xea4(%rip),%xmm3
movdqa 0xeac(%rip),%xmm4
movdqa 0xeb4(%rip),%xmm5
movdqa 0xebc(%rip),%xmm6
movdqa 0xec4(%rip),%xmm7
nopl   0x0(%rax)
movdqa %xmm0,%xmm1
paddd  %xmm8,%xmm1
movdqu %xmm0,-0x90(%rax,%rcx,4)
ff ff
movdqu %xmm1,-0x80(%rax,%rcx,4)
movdqa %xmm0,%xmm1
paddd  %xmm9,%xmm1
movdqa %xmm0,%xmm2
paddd  %xmm10,%xmm2
movdqu %xmm1,-0x70(%rax,%rcx,4)
movdqu %xmm2,-0x60(%rax,%rcx,4)
movdqa %xmm0,%xmm1
paddd  %xmm11,%xmm1
movdqa %xmm0,%xmm2
paddd  %xmm12,%xmm2
movdqu %xmm1,-0x50(%rax,%rcx,4)
movdqu %xmm2,-0x40(%rax,%rcx,4)
movdqa %xmm0,%xmm1
paddd  %xmm3,%xmm1
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqu %xmm1,-0x30(%rax,%rcx,4)
movdqu %xmm2,-0x20(%rax,%rcx,4)
movdqa %xmm0,%xmm1
paddd  %xmm5,%xmm1
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqu %xmm1,-0x10(%rax,%rcx,4)
movdqu %xmm2,(%rax,%rcx,4)
paddd  %xmm7,%xmm0
add    $0x28,%rcx
cmp    $0x186c4,%rcx
jne    11e0 <main+0x90>
mov    %rax,%rdi
call   1030 <free@plt>
add    $0x1,%ebx
cmp    $0x15f90,%ebx
jne    1170 <main+0x20>
lea    0x8(%rsp),%rdi
call   1060 <time@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <difftime@plt>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 @time(i32* %2)
store i32 0, i32* %4
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 90000
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = call i64 @malloc(i32 400000)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %6
store i32 0, i32* %5
br label %15
15: ; preds = %24, %12
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 100000
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %5
%20 = load i32*, i32** %6
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 %19, i32* %23
br label %24
24: ; preds = %18
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %15
27: ; preds = %15
%28 = load i32*, i32** %6
%29 = call i32 @free(i32* %28)
br label %30
30: ; preds = %27
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %9
33: ; preds = %9
%34 = call i32 @time(i32* %3)
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = call double @difftime(i32 %35, i32 %36)
store double %37, double* %7
%38 = load double, double* %7
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @time(i32* %1)
br label %6
6: ; preds = %0, %49
%7 = phi i32 [ 0, %0 ], [ %51, %49 ]
%8 = call i64 @malloc(i32 400000)
%9 = inttoptr i64 %8 to i32*
br label %10
10: ; preds = %10, %6
%11 = phi i64 [ 0, %6 ], [ %46, %10 ]
%12 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %6 ], [ %47, %10 ]
%13 = add <4 x i32> %12, <i32 4, i32 4, i32 4, i32 4>
%14 = getelementptr inbounds i32, i32* %9, i64 %11
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %14, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %17
%18 = add nuw nsw i64 %11, 8
%19 = add <4 x i32> %12, <i32 8, i32 8, i32 8, i32 8>
%20 = add <4 x i32> %12, <i32 12, i32 12, i32 12, i32 12>
%21 = getelementptr inbounds i32, i32* %9, i64 %18
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %22
%23 = getelementptr inbounds i32, i32* %21, i64 4
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %24
%25 = add nuw nsw i64 %11, 16
%26 = add <4 x i32> %12, <i32 16, i32 16, i32 16, i32 16>
%27 = add <4 x i32> %12, <i32 20, i32 20, i32 20, i32 20>
%28 = getelementptr inbounds i32, i32* %9, i64 %25
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %31
%32 = add nuw nsw i64 %11, 24
%33 = add <4 x i32> %12, <i32 24, i32 24, i32 24, i32 24>
%34 = add <4 x i32> %12, <i32 28, i32 28, i32 28, i32 28>
%35 = getelementptr inbounds i32, i32* %9, i64 %32
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %38
%39 = add nuw nsw i64 %11, 32
%40 = add <4 x i32> %12, <i32 32, i32 32, i32 32, i32 32>
%41 = add <4 x i32> %12, <i32 36, i32 36, i32 36, i32 36>
%42 = getelementptr inbounds i32, i32* %9, i64 %39
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %43
%44 = getelementptr inbounds i32, i32* %42, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %45
%46 = add nuw nsw i64 %11, 40
%47 = add <4 x i32> %12, <i32 40, i32 40, i32 40, i32 40>
%48 = icmp eq i64 %46, 100000
br i1 %48, label %49, label %10
49: ; preds = %10
%50 = call i32 @free(i32* %9)
%51 = add nuw nsw i32 %7, 1
%52 = icmp eq i32 %51, 90000
br i1 %52, label %53, label %6
53: ; preds = %49
%54 = call i32 @time(i32* %2)
%55 = load i32, i32* %2
%56 = load i32, i32* %1
%57 = call double @difftime(i32 %55, i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %57)
ret i32 0
}