#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 */
unsigned int atoi(char *);
unsigned int fib(int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char **argv) {
  if (argc < 2)
    return -1;
  unsigned n = atoi(argv[1]);
  unsigned int res = 0;
  for (int i = 1; i <= n; ++i) {
    unsigned int f = fib(i);
    if (f % 2 != 0)
      res += f * f;
  }
  printf("%lu\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
ja     11c0 <main+0x90>
mov    -0x1c(%rbp),%edi
call   1040 <fib@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ad <main+0x7d>
mov    -0x20(%rbp),%eax
imul   -0x20(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11b2 <main+0x82>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <main+0x4a>
mov    -0x18(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
cmp    $0x2,%edi
jl     11a6 <main+0x76>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %eax,%eax
je     1198 <main+0x68>
mov    %eax,%r15d
neg    %r15d
xor    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1040 <fib@plt>
mov    %eax,%ecx
and    $0x1,%ecx
neg    %ecx
imul   %eax,%eax
and    %ecx,%eax
add    %eax,%ebp
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <main+0x40>
lea    0xe61(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %41
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
br label %18
18: ; preds = %35, %13
%19 = load i32, i32* %8
%20 = load i32, i32* %6
%21 = icmp ule i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = load i32, i32* %8
%24 = call i32 @fib(i32 %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = urem i32 %25, 2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i32, i32* %9
%30 = load i32, i32* %9
%31 = mul i32 %29, %30
%32 = load i32, i32* %7
%33 = add i32 %32, %31
store i32 %33, i32* %7
br label %34
34: ; preds = %28, %22
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %18
38: ; preds = %18
%39 = load i32, i32* %7
%40 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %38, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %12, %4
%10 = phi i32 [ 0, %4 ], [ %20, %12 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %23
12: ; preds = %4, %12
%13 = phi i32 [ %21, %12 ], [ 1, %4 ]
%14 = phi i32 [ %20, %12 ], [ 0, %4 ]
%15 = tail call i32 @fib(i32 %13)
%16 = and i32 %15, 1
%17 = icmp eq i32 %16, 0
%18 = mul i32 %15, %15
%19 = select i1 %17, i32 0, i32 %18
%20 = add i32 %19, %14
%21 = add nuw i32 %13, 1
%22 = icmp eq i32 %13, %7
br i1 %22, label %9, label %12
23: ; preds = %2, %9
%24 = phi i32 [ 0, %9 ], [ -1, %2 ]
ret i32 %24
}