#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 */

/* Variables and functions */
int fib(int *, int *, int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int size = 1000;
  int *f1 = (int *)malloc(size * sizeof(int));
  int *f2 = (int *)malloc(size * sizeof(int));
  int *f3 = (int *)malloc(size * sizeof(int));
  int i;
  for (i = 0; i < size; i++) {
    f1[i] = 0;
    f2[i] = 0;
    f3[i] = 0;
  }
  f1[size - 1] = 1;
  f2[size - 1] = 1;
  int temp = fib(f1, f2, f3, size);
  printf("%d\n", temp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cd <main+0x9d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <main+0x56>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%ecx
call   1050 <fib@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xfa0,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0xfa0,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0xfa0,%edi
call   1040 <malloc@plt>
lea    0xfa0(%r14),%rcx
lea    0xfa0(%rbx),%rsi
lea    0xfa0(%rax),%rdi
cmp    %rsi,%r14
setb   %r9b
cmp    %rcx,%rbx
setb   %r10b
cmp    %rdi,%r14
setb   %dl
cmp    %rcx,%rax
setb   %r8b
cmp    %rdi,%rbx
setb   %cl
cmp    %rsi,%rax
setb   %sil
test   %r10b,%r9b
jne    11fc <main+0xcc>
and    %r8b,%dl
jne    11fc <main+0xcc>
and    %sil,%cl
jne    11fc <main+0xcc>
mov    $0xc,%ecx
xorps  %xmm0,%xmm0
nopl   0x0(%rax)
movups %xmm0,-0x30(%r14,%rcx,4)
movups %xmm0,-0x20(%r14,%rcx,4)
movups %xmm0,-0x30(%rbx,%rcx,4)
movups %xmm0,-0x20(%rbx,%rcx,4)
movups %xmm0,-0x30(%rax,%rcx,4)
movups %xmm0,-0x20(%rax,%rcx,4)
cmp    $0x3ec,%rcx
je     124c <main+0x11c>
movups %xmm0,-0x10(%r14,%rcx,4)
movups %xmm0,(%r14,%rcx,4)
movups %xmm0,-0x10(%rbx,%rcx,4)
movups %xmm0,(%rbx,%rcx,4)
movups %xmm0,-0x10(%rax,%rcx,4)
movups %xmm0,(%rax,%rcx,4)
add    $0x10,%rcx
jmp    11b0 <main+0x80>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x0,-0x4(%r14,%rcx,4)
movl   $0x0,-0x4(%rbx,%rcx,4)
movl   $0x0,-0x4(%rax,%rcx,4)
movl   $0x0,(%r14,%rcx,4)
movl   $0x0,(%rbx,%rcx,4)
movl   $0x0,(%rax,%rcx,4)
add    $0x2,%rcx
cmp    $0x3e9,%rcx
jne    1210 <main+0xe0>
movl   $0x1,0xf9c(%r14)
movl   $0x1,0xf9c(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
mov    $0x3e8,%ecx
call   1050 <fib@plt>
lea    0xd85(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\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 i32
store i32 0, i32* %1
store i32 1000, i32* %2
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %3
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 4
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %4
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %5
store i32 0, i32* %6
br label %26
26: ; preds = %43, %0
%27 = load i32, i32* %6
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %46
30: ; preds = %26
%31 = load i32*, i32** %3
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 0, i32* %34
%35 = load i32*, i32** %4
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 0, i32* %38
%39 = load i32*, i32** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 0, i32* %42
br label %43
43: ; preds = %30
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %26
46: ; preds = %26
%47 = load i32*, i32** %3
%48 = load i32, i32* %2
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %47, i64 %50
store i32 1, i32* %51
%52 = load i32*, i32** %4
%53 = load i32, i32* %2
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %52, i64 %55
store i32 1, i32* %56
%57 = load i32*, i32** %3
%58 = load i32*, i32** %4
%59 = load i32*, i32** %5
%60 = load i32, i32* %2
%61 = call i32 @fib(i32* %57, i32* %58, i32* %59, i32 %60)
store i32 %61, i32* %7
%62 = load i32, i32* %7
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 4000)
%2 = inttoptr i64 %1 to i32*
%3 = inttoptr i64 %1 to i8*
%4 = tail call i64 @malloc(i32 4000)
%5 = inttoptr i64 %4 to i32*
%6 = inttoptr i64 %4 to i8*
%7 = tail call i64 @malloc(i32 4000)
%8 = inttoptr i64 %7 to i32*
%9 = inttoptr i64 %7 to i8*
%10 = getelementptr i32, i32* %2, i64 1000
%11 = bitcast i32* %10 to i8*
%12 = getelementptr i32, i32* %5, i64 1000
%13 = bitcast i32* %12 to i8*
%14 = getelementptr i32, i32* %8, i64 1000
%15 = bitcast i32* %14 to i8*
%16 = icmp ult i8* %3, %13
%17 = icmp ult i8* %6, %11
%18 = and i1 %16, %17
%19 = icmp ult i8* %3, %15
%20 = icmp ult i8* %9, %11
%21 = and i1 %19, %20
%22 = or i1 %18, %21
%23 = icmp ult i8* %6, %15
%24 = icmp ult i8* %9, %13
%25 = and i1 %23, %24
%26 = or i1 %22, %25
br i1 %26, label %57, label %27
27: ; preds = %0, %43
%28 = phi i64 [ %56, %43 ], [ 0, %0 ]
%29 = getelementptr inbounds i32, i32* %2, i64 %28
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %30
%31 = getelementptr inbounds i32, i32* %29, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %32
%33 = getelementptr inbounds i32, i32* %5, i64 %28
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %33, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %8, i64 %28
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %38
%39 = getelementptr inbounds i32, i32* %37, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %40
%41 = or i64 %28, 8
%42 = icmp eq i64 %41, 1000
br i1 %42, label %68, label %43
43: ; preds = %27
%44 = getelementptr inbounds i32, i32* %2, i64 %41
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %45
%46 = getelementptr inbounds i32, i32* %44, i64 4
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %47
%48 = getelementptr inbounds i32, i32* %5, i64 %41
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %49
%50 = getelementptr inbounds i32, i32* %48, i64 4
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %51
%52 = getelementptr inbounds i32, i32* %8, i64 %41
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %53
%54 = getelementptr inbounds i32, i32* %52, i64 4
%55 = bitcast i32* %54 to <4 x i32>*
store <4 x i32> zeroinitializer, <4 x i32>* %55
%56 = add nuw nsw i64 %28, 16
br label %27
57: ; preds = %0, %57
%58 = phi i64 [ %66, %57 ], [ 0, %0 ]
%59 = getelementptr inbounds i32, i32* %2, i64 %58
store i32 0, i32* %59
%60 = getelementptr inbounds i32, i32* %5, i64 %58
store i32 0, i32* %60
%61 = getelementptr inbounds i32, i32* %8, i64 %58
store i32 0, i32* %61
%62 = or i64 %58, 1
%63 = getelementptr inbounds i32, i32* %2, i64 %62
store i32 0, i32* %63
%64 = getelementptr inbounds i32, i32* %5, i64 %62
store i32 0, i32* %64
%65 = getelementptr inbounds i32, i32* %8, i64 %62
store i32 0, i32* %65
%66 = add nuw nsw i64 %58, 2
%67 = icmp eq i64 %66, 1000
br i1 %67, label %68, label %57
68: ; preds = %27, %57
%69 = getelementptr inbounds i32, i32* %2, i64 999
store i32 1, i32* %69
%70 = getelementptr inbounds i32, i32* %5, i64 999
store i32 1, i32* %70
%71 = tail call i32 @fib(i32* %2, i32* %5, i32* %8, i32 1000)
%72 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
ret i32 0
}