#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);
void hanoi(int from, int to, int n) {
  int other = 3 - (from + to);
  if (n == 1)
    printf("move from %d to %d \n", from, to);
  else {
    hanoi(from, other, n - 1);
    printf("move from %d to %d \n", from, to);
    hanoi(other, to, n - 1);
  }
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
mov    $0x3,%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1162 <hanoi+0x42>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1196 <hanoi+0x76>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1040 <hanoi@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1040 <hanoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%r12d
cmp    $0x1,%edx
jne    1138 <hanoi+0x18>
mov    %r12d,%ebx
jmp    117d <hanoi+0x5d>
mov    %edx,%ebp
add    $0xffffffff,%ebp
lea    0xebc(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x3,%ebx
sub    %r12d,%ebx
sub    %r14d,%ebx
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <hanoi@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
mov    %ebx,%r12d
add    $0xffffffff,%ebp
jne    1150 <hanoi+0x30>
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

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