#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 /*<<< orphan*/ copy(int *, int *, int);
int /*<<< orphan*/ sum(int *, int *, int *, int);
int fib(int *f1, int *f2, int *f3, int size) {
  int temp = 2;
  do {
    sum(f3, f1, f2, size);
    temp++;
    copy(f1, f2, size);
    copy(f2, f3, size);
  } while (f3[0] == 0);
  return temp;
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <sum@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <copy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <copy@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     113e <fib+0x1e>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%r12
mov    $0x2,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1040 <sum@plt>
add    $0x1,%ebx
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <copy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <copy@plt>
cmpl   $0x0,(%r15)
je     1140 <fib+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fib(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 2, i32* %9
br label %10
10: ; preds = %26, %4
%11 = load i32*, i32** %7
%12 = load i32*, i32** %5
%13 = load i32*, i32** %6
%14 = load i32, i32* %8
%15 = call i32 @sum(i32* %11, i32* %12, i32* %13, i32 %14)
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
%18 = load i32*, i32** %5
%19 = load i32*, i32** %6
%20 = load i32, i32* %8
%21 = call i32 @copy(i32* %18, i32* %19, i32 %20)
%22 = load i32*, i32** %6
%23 = load i32*, i32** %7
%24 = load i32, i32* %8
%25 = call i32 @copy(i32* %22, i32* %23, i32 %24)
br label %26
26: ; preds = %10
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %10, label %31
31: ; preds = %26
%32 = load i32, i32* %9
ret i32 %32
}

LLVM IR (-O2):
define i32 @fib(i32* %0, i32* %1, i32* %2, i32 %3) {
br label %5
5: ; preds = %5, %4
%6 = phi i32 [ 2, %4 ], [ %8, %5 ]
%7 = tail call i32 @sum(i32* %2, i32* %0, i32* %1, i32 %3)
%8 = add nuw nsw i32 %6, 1
%9 = tail call i32 @copy(i32* %0, i32* %1, i32 %3)
%10 = tail call i32 @copy(i32* %1, i32* %2, i32 %3)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %5, label %13
13: ; preds = %5
ret i32 %8
}