#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 uint64_t;

/* Variables and functions */
int proximoFib() {
  static uint64_t first, second, iterationNumber = 0;
  if (iterationNumber == 0) {
    second = 0;
  } else if (iterationNumber == 1) {
    first = 0;
    second = 1;
  } else {
    uint64_t temp = first;
    first = second;
    second += temp;
  }
  ++iterationNumber;
  return second;
}


x86 assembly (clang, -O0):
<proximoFib>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2f21(%rip)
jne    1120 <proximoFib+0x20>
movl   $0x0,0x2f0d(%rip)
jmp    116f <proximoFib+0x6f>
cmpl   $0x1,0x2f05(%rip)
jne    1146 <proximoFib+0x46>
movl   $0x0,0x2eed(%rip)
movl   $0x1,0x2ee7(%rip)
jmp    116a <proximoFib+0x6a>
mov    0x2ed8(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0x2ed3(%rip),%eax
mov    %eax,0x2ec9(%rip)
mov    -0x4(%rbp),%eax
add    0x2ec4(%rip),%eax
mov    %eax,0x2ebe(%rip)
jmp    116f <proximoFib+0x6f>
mov    0x2eb7(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eae(%rip)
mov    0x2ea4(%rip),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<proximoFib>:
mov    0x2f26(%rip),%ecx
mov    %ecx,%eax
test   %ecx,%ecx
je     1136 <proximoFib+0x36>
cmp    $0x1,%ecx
jne    1122 <proximoFib+0x22>
movl   $0x0,0x2f09(%rip)
mov    $0x1,%eax
jmp    1136 <proximoFib+0x36>
mov    0x2f00(%rip),%edx
mov    0x2ef6(%rip),%eax
add    %edx,%eax
mov    %edx,0x2eee(%rip)
mov    %eax,0x2eec(%rip)
add    $0x1,%ecx
mov    %ecx,0x2ee7(%rip)
ret

LLVM IR (-O0):
@proximoFib.first = internal global i32 0
@proximoFib.second = internal global i32 0
@proximoFib.iterationNumber = internal global i32 0
define i32 @proximoFib() {
%1 = alloca i32
%2 = load i32, i32* @proximoFib.iterationNumber
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 0, i32* @proximoFib.second
br label %16
5: ; preds = %0
%6 = load i32, i32* @proximoFib.iterationNumber
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 0, i32* @proximoFib.first
store i32 1, i32* @proximoFib.second
br label %15
9: ; preds = %5
%10 = load i32, i32* @proximoFib.first
store i32 %10, i32* %1
%11 = load i32, i32* @proximoFib.second
store i32 %11, i32* @proximoFib.first
%12 = load i32, i32* %1
%13 = load i32, i32* @proximoFib.second
%14 = add nsw i32 %13, %12
store i32 %14, i32* @proximoFib.second
br label %15
15: ; preds = %9, %8
br label %16
16: ; preds = %15, %4
%17 = load i32, i32* @proximoFib.iterationNumber
%18 = add nsw i32 %17, 1
store i32 %18, i32* @proximoFib.iterationNumber
%19 = load i32, i32* @proximoFib.second
ret i32 %19
}

LLVM IR (-O2):
@proximoFib.first = internal unnamed_addr global i32 0
@proximoFib.second = internal unnamed_addr global i32 0
@proximoFib.iterationNumber = internal unnamed_addr global i32 0
define i32 @proximoFib() {
%1 = load i32, i32* @proximoFib.iterationNumber
switch i32 %1, label %3 [
i32 0, label %7
i32 1, label %2
]
2: ; preds = %0
store i32 0, i32* @proximoFib.first
br label %7
3: ; preds = %0
%4 = load i32, i32* @proximoFib.first
%5 = load i32, i32* @proximoFib.second
store i32 %5, i32* @proximoFib.first
%6 = add nsw i32 %5, %4
br label %7
7: ; preds = %0, %2, %3
%8 = phi i32 [ 1, %2 ], [ %6, %3 ], [ %1, %0 ]
store i32 %8, i32* @proximoFib.second
%9 = add nsw i32 %1, 1
store i32 %9, i32* @proximoFib.iterationNumber
ret i32 %8
}