#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*/ print_hanoi(int, char, char);
void hanoi(int ceil, char a, char b, char c) {
  if (0 >= ceil)
    return;
  if (1 == ceil)
    print_hanoi(ceil, a, c);
  else {
    hanoi(ceil - 1, a, c, b);
    print_hanoi(ceil, a, c);
    hanoi(ceil - 1, b, a, c);
  }
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %edi,-0x4(%rbp)
mov    %dl,-0x5(%rbp)
mov    %cl,-0x6(%rbp)
mov    %al,-0x7(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jl     114b <hanoi+0x2b>
jmp    11b8 <hanoi+0x98>
mov    $0x1,%eax
cmp    -0x4(%rbp),%eax
jne    1170 <hanoi+0x50>
mov    -0x4(%rbp),%edi
mov    -0x5(%rbp),%al
movsbl %al,%esi
movsbl -0x7(%rbp),%edx
call   1030 <print_hanoi@plt>
jmp    11b8 <hanoi+0x98>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x5(%rbp),%cl
mov    -0x7(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x6(%rbp),%ecx
call   1040 <hanoi@plt>
mov    -0x4(%rbp),%edi
mov    -0x5(%rbp),%al
movsbl %al,%esi
movsbl -0x7(%rbp),%edx
call   1030 <print_hanoi@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x6(%rbp),%cl
mov    -0x5(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x7(%rbp),%ecx
call   1040 <hanoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
test   %edi,%edi
jle    113e <hanoi+0x1e>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
movsbl %cl,%r14d
cmp    $0x1,%edi
jne    113f <hanoi+0x1f>
mov    %esi,%eax
jmp    1186 <hanoi+0x66>
ret
mov    %edx,%r12d
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,%r13d
lea    0x1(%rbx),%r15d
movsbl %sil,%ebp
movsbl %r12b,%ecx
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <hanoi@plt>
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <print_hanoi@plt>
mov    %r12d,%eax
mov    %r12d,%esi
mov    %r13d,%r12d
add    $0xffffffff,%ebx
jne    1150 <hanoi+0x30>
movsbl %al,%esi
mov    $0x1,%edi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <print_hanoi@plt>

LLVM IR (-O0):
define void @hanoi(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8 %3, i8* %8
%9 = load i32, i32* %5
%10 = icmp sge i32 0, %9
br i1 %10, label %11, label %12
11: ; preds = %4
br label %35
12: ; preds = %4
%13 = load i32, i32* %5
%14 = icmp eq i32 1, %13
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %5
%17 = load i8, i8* %6
%18 = load i8, i8* %8
%19 = call i32 @print_hanoi(i32 %16, i8 signext %17, i8 signext %18)
br label %35
20: ; preds = %12
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 1
%23 = load i8, i8* %6
%24 = load i8, i8* %8
%25 = load i8, i8* %7
%26 = load i32, i32* %5
%27 = load i8, i8* %6
%28 = load i8, i8* %8
%29 = call i32 @print_hanoi(i32 %26, i8 signext %27, i8 signext %28)
%30 = load i32, i32* %5
%31 = sub nsw i32 %30, 1
%32 = load i8, i8* %7
%33 = load i8, i8* %6
%34 = load i8, i8* %8
br label %35
35: ; preds = %11, %20, %15
ret void
}

LLVM IR (-O2):
define void @hanoi(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = icmp slt i32 %0, 1
br i1 %5, label %18, label %6
6: ; preds = %4
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %11
8: ; preds = %11, %6
%9 = phi i8 [ %1, %6 ], [ %14, %11 ]
%10 = tail call i32 @print_hanoi(i32 1, i8 signext %9, i8 signext %3)
br label %18
11: ; preds = %6, %11
%12 = phi i32 [ %15, %11 ], [ %0, %6 ]
%13 = phi i8 [ %14, %11 ], [ %1, %6 ]
%14 = phi i8 [ %13, %11 ], [ %2, %6 ]
%15 = add nsw i32 %12, -1
tail call void @hanoi(i32 %15, i8 signext %13, i8 signext %3, i8 signext %14)
%16 = tail call i32 @print_hanoi(i32 %12, i8 signext %13, i8 signext %3)
%17 = icmp eq i32 %15, 1
br i1 %17, label %8, label %11
18: ; preds = %4, %8
ret void
}