#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 fy1(int, int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int climbStairs(int n) {
  if (n <= 0)
    return 0;
  if (n == 1)
    return 1;
  int count = 0;
  int mid = n / 2, y = 0;
  int fy = 1;
  while (y <= mid) {
    fy = y ? fy1(y - 1, n, fy) : 1;
    printf("y = %d, x = %d, fy = %d\n", y, n - 2 * y, fy);
    count += fy;
    y++;
  }
  return count;
}


x86 assembly (clang, -O0):
<climbStairs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1141 <climbStairs+0x21>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <climbStairs+0xd6>
cmpl   $0x1,-0x8(%rbp)
jne    1157 <climbStairs+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <climbStairs+0xd6>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11f0 <climbStairs+0xd0>
cmpl   $0x0,-0x14(%rbp)
je     11a9 <climbStairs+0x89>
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <fy1@plt>
mov    %eax,-0x1c(%rbp)
jmp    11b6 <climbStairs+0x96>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b6 <climbStairs+0x96>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%edx
mov    -0x18(%rbp),%ecx
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <climbStairs+0x5a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<climbStairs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11a9 <climbStairs+0x89>
mov    %edi,%r15d
mov    $0x1,%r13d
cmp    $0x1,%edi
je     11ac <climbStairs+0x8c>
mov    %r15d,%eax
shr    %eax
mov    %eax,0x4(%rsp)
lea    0xeb3(%rip),%rdi
xor    %ebp,%ebp
mov    $0x1,%r12d
xor    %esi,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1040 <printf@plt>
lea    -0x2(%r15),%ebx
mov    $0x1,%r13d
xchg   %ax,%ax
lea    0x1(%rbp),%r14d
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r12d,%edx
call   1030 <fy1@plt>
mov    %eax,%r12d
lea    0xe75(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
add    %r12d,%r13d
add    $0xfffffffe,%ebx
mov    %r14d,%ebp
cmp    %r14d,0x4(%rsp)
jne    1170 <climbStairs+0x50>
jmp    11ac <climbStairs+0x8c>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"y = %d, x = %d, fy = %d\0A\00"
define i32 @climbStairs(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %48
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %2
br label %48
15: ; preds = %11
store i32 0, i32* %4
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 2
store i32 %17, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %18
18: ; preds = %32, %15
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %46
22: ; preds = %18
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = load i32, i32* %3
%29 = load i32, i32* %7
%30 = call i32 @fy1(i32 %27, i32 %28, i32 %29)
br label %32
31: ; preds = %22
br label %32
32: ; preds = %31, %25
%33 = phi i32 [ %30, %25 ], [ 1, %31 ]
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = load i32, i32* %3
%36 = load i32, i32* %6
%37 = mul nsw i32 2, %36
%38 = sub nsw i32 %35, %37
%39 = load i32, i32* %7
%40 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %38, i32 %39)
%41 = load i32, i32* %7
%42 = load i32, i32* %4
%43 = add nsw i32 %42, %41
store i32 %43, i32* %4
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %18
46: ; preds = %18
%47 = load i32, i32* %4
store i32 %47, i32* %2
br label %48
48: ; preds = %46, %14, %10
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [25 x i8] c"y = %d, x = %d, fy = %d\0A\00"
define i32 @climbStairs(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = lshr i32 %0, 1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0, i32 %0, i32 1)
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ 1, %5 ], [ %13, %8 ]
%10 = phi i32 [ 1, %5 ], [ %18, %8 ]
%11 = phi i32 [ 1, %5 ], [ %17, %8 ]
%12 = add nsw i32 %10, -1
%13 = tail call i32 @fy1(i32 %12, i32 %0, i32 %9)
%14 = mul i32 %10, -2
%15 = add i32 %14, %0
%16 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %15, i32 %13)
%17 = add nsw i32 %13, %11
%18 = add nuw i32 %10, 1
%19 = icmp eq i32 %10, %6
br i1 %19, label %20, label %8
20: ; preds = %8, %3, %1
%21 = phi i32 [ 0, %1 ], [ 1, %3 ], [ %17, %8 ]
ret i32 %21
}