#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, char, char);
void Hanoi(char a, char b, char c, int n) {
  if (n > 0) {
    Hanoi(a, c, b, n - 1);
    printf("Move Disk %d from Tower %c to Tower %c\n", n, a, c);
    Hanoi(b, a, c, n - 1);
  }
}


x86 assembly (clang, -O0):
<Hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %ecx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119e <Hanoi+0x7e>
mov    -0x1(%rbp),%sil
mov    -0x3(%rbp),%dl
mov    -0x2(%rbp),%al
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <Hanoi@plt>
mov    -0x8(%rbp),%esi
mov    -0x1(%rbp),%al
lea    0xe8d(%rip),%rdi
movsbl %al,%edx
movsbl -0x3(%rbp),%ecx
call   1040 <printf@plt>
mov    -0x2(%rbp),%sil
mov    -0x1(%rbp),%dl
mov    -0x3(%rbp),%al
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <Hanoi@plt>
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
test   %ecx,%ecx
jle    117d <Hanoi+0x5d>
mov    %ecx,%ebx
mov    %edi,%r13d
movsbl %dl,%r14d
nopl   0x0(%rax,%rax,1)
mov    %esi,%r15d
lea    -0x1(%rbx),%r12d
movsbl %r13b,%ebp
movsbl %sil,%edx
mov    %ebp,%edi
mov    %r14d,%esi
mov    %r12d,%ecx
call   1030 <Hanoi@plt>
lea    0xe9d(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <printf@plt>
mov    %r13d,%esi
mov    %r15d,%r13d
cmp    $0x1,%ebx
mov    %r12d,%ebx
ja     1140 <Hanoi+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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