#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 towers(int n, char fromrod, char torod, char intermediaterod) {
  if (n == 1) {
    printf("Disk 1 moving from rod %c to rod %c using %c as intermediate rod\n",
           fromrod, torod, intermediaterod);
    return;
  }
  towers(n - 1, fromrod, intermediaterod, torod);
  printf("Disc %d moving from rod %c to rod %c using %c as intermdiate rod\n",
         n, fromrod, torod, intermediaterod);
  towers(n - 1, intermediaterod, torod, fromrod);
}


x86 assembly (clang, -O0):
<towers>:
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    1166 <towers+0x46>
movsbl -0x5(%rbp),%esi
mov    -0x6(%rbp),%al
lea    0xead(%rip),%rdi
movsbl %al,%edx
movsbl -0x7(%rbp),%ecx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <towers+0x9e>
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 <towers@plt>
mov    -0x4(%rbp),%esi
mov    -0x5(%rbp),%cl
mov    -0x6(%rbp),%al
movsbl -0x7(%rbp),%r8d
lea    0xeac(%rip),%rdi
movsbl %cl,%edx
movsbl %al,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x7(%rbp),%cl
mov    -0x6(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x5(%rbp),%ecx
call   1040 <towers@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<towers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
movsbl %dl,%r12d
cmp    $0x1,%edi
jne    113c <towers+0x1c>
mov    %r13d,%r14d
jmp    1196 <towers+0x76>
mov    %edi,%ebx
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%r14d
lea    0x1(%rbx),%ecx
mov    %ecx,0x4(%rsp)
movsbl %r13b,%ebp
movsbl %r14b,%r15d
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1040 <towers@plt>
lea    0xeca(%rip),%rdi
mov    0x4(%rsp),%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%ecx
mov    %r14d,%r13d
add    $0xffffffff,%ebx
jne    1150 <towers+0x30>
movsbl %r14b,%esi
movsbl %cl,%ecx
lea    0xe5c(%rip),%rdi
mov    %r12d,%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 = [66 x i8] c"Disk 1 moving from rod %c to rod %c using %c as intermediate rod\0A\00"
@.str.1 = [66 x i8] c"Disc %d moving from rod %c to rod %c using %c as intermdiate rod\0A\00"
define void @towers(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 %17
11: ; preds = %4
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = load i8, i8* %7
%15 = load i8, i8* %8
%16 = call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %13, i8 signext %14, i8 signext %15)
br label %34
17: ; preds = %4
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = load i8, i8* %6
%21 = load i8, i8* %8
%22 = load i8, i8* %7
%23 = load i32, i32* %5
%24 = load i8, i8* %6
%25 = load i8, i8* %7
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8 signext %24, i8 signext %25, i32 %27)
%29 = load i32, i32* %5
%30 = sub nsw i32 %29, 1
%31 = load i8, i8* %8
%32 = load i8, i8* %7
%33 = load i8, i8* %6
br label %34
34: ; preds = %17, %11
ret void
}

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