#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*/ printf(char *, int, int, int);
hanoi(int n, int from, int to) {
  if (n > 1)
    hanoi(n - 1, from, 6 - (from + to));
  printf("Move disk %d from pole %d to pole %d\n", n, from, to);
  if (n > 1)
    hanoi(n - 1, 6 - (from + to), to);
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1156 <hanoi+0x36>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x6,%edx
sub    %eax,%edx
call   1040 <hanoi@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1190 <hanoi+0x70>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x6,%esi
sub    %eax,%esi
mov    -0x10(%rbp),%edx
call   1040 <hanoi@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r12d
cmp    $0x2,%edi
jl     117c <hanoi+0x5c>
lea    0xec1(%rip),%r15
nop
mov    %ebp,%ebx
lea    -0x1(%r12),%r13d
mov    $0x6,%ebp
sub    %ebx,%ebp
sub    %r14d,%ebp
mov    %r13d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <hanoi@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1030 <printf@plt>
cmp    $0x2,%r12d
mov    %r13d,%r12d
ja     1140 <hanoi+0x20>
mov    $0x1,%r12d
lea    0xe7d(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Move disk %d from pole %d to pole %d\0A\00"
define i32 @hanoi(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = add nsw i32 %14, %15
%17 = sub nsw i32 6, %16
%18 = call i32 @hanoi(i32 %12, i32 %13, i32 %17)
br label %19
19: ; preds = %10, %3
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %35
26: ; preds = %19
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = add nsw i32 %29, %30
%32 = sub nsw i32 6, %31
%33 = load i32, i32* %7
%34 = call i32 @hanoi(i32 %28, i32 %32, i32 %33)
br label %35
35: ; preds = %26, %19
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [38 x i8] c"Move disk %d from pole %d to pole %d\0A\00"
define i32 @hanoi(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %14
5: ; preds = %3, %5
%6 = phi i32 [ %10, %5 ], [ %1, %3 ]
%7 = phi i32 [ %8, %5 ], [ %0, %3 ]
%8 = add nsw i32 %7, -1
%9 = add i32 %6, %2
%10 = sub i32 6, %9
%11 = tail call i32 @hanoi(i32 %8, i32 %6, i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %6, i32 %2)
%13 = icmp ugt i32 %7, 2
br i1 %13, label %5, label %14
14: ; preds = %5, %3
%15 = phi i32 [ %0, %3 ], [ 1, %5 ]
%16 = phi i32 [ %1, %3 ], [ %10, %5 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %2)
ret i32 undef
}