#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, ...);
void towerOfHanoi(int top, char start, char via, char end) {
  if (top == 1) {
    printf("Move disk 1 from rod %c to rod %c\n", start, end);
    return;
  }
  towerOfHanoi(top - 1, start, end, via);
  printf("Move disk %d from rod %c to rod %c\n", top, start, end);
  towerOfHanoi(top - 1, via, start, end);
}


x86 assembly (clang, -O0):
<towerOfHanoi>:
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)
cmpl   $0x1,-0x4(%rbp)
jne    1160 <towerOfHanoi+0x40>
movsbl -0x5(%rbp),%esi
lea    0xeb0(%rip),%rdi
movsbl -0x7(%rbp),%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <towerOfHanoi+0x91>
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 <towerOfHanoi@plt>
mov    -0x4(%rbp),%esi
mov    -0x5(%rbp),%al
movsbl -0x7(%rbp),%ecx
lea    0xe97(%rip),%rdi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <printf@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 <towerOfHanoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<towerOfHanoi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
movsbl %cl,%r14d
cmp    $0x1,%edi
jne    113c <towerOfHanoi+0x1c>
mov    %r13d,%r15d
jmp    118b <towerOfHanoi+0x6b>
mov    %edi,%ebx
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,%r15d
lea    0x1(%rbx),%r12d
movsbl %r13b,%ebp
movsbl %dl,%ecx
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <towerOfHanoi@plt>
lea    0xeb2(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%edx
mov    %r15d,%r13d
add    $0xffffffff,%ebx
jne    1150 <towerOfHanoi+0x30>
movsbl %r15b,%esi
lea    0xe6a(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"Move disk 1 from rod %c to rod %c\0A\00"
@.str.1 = [36 x i8] c"Move disk %d from rod %c to rod %c\0A\00"
define void @towerOfHanoi(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 eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = load i8, i8* %8
%15 = call i32 (i8*, i32, i8, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %13, i8 signext %14)
br label %32
16: ; preds = %4
%17 = load i32, i32* %5
%18 = sub nsw i32 %17, 1
%19 = load i8, i8* %6
%20 = load i8, i8* %8
%21 = load i8, i8* %7
%22 = load i32, i32* %5
%23 = load i8, i8* %6
%24 = load i8, i8* %8
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, i32, i8, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %22, i8 signext %23, i32 %25)
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1
%29 = load i8, i8* %7
%30 = load i8, i8* %6
%31 = load i8, i8* %8
br label %32
32: ; preds = %16, %11
ret void
}

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