#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 src, char dst, char aux) {
  static int step = 0;
  printf("Towers(%d %c %c %c)\n", n, src, dst, aux);
  if (n == 1)
    printf("\t\t\tStep %3d: Move %c to %c\n", ++step, src, dst);
  else {
    towers(n - 1, src, aux, dst);
    printf("\t\t\tStep %3d: Move %c to %c\n", ++step, src, dst);
    towers(n - 1, aux, dst, src);
  }
  return;
}


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)
mov    -0x4(%rbp),%esi
mov    -0x5(%rbp),%cl
mov    -0x6(%rbp),%al
movsbl -0x7(%rbp),%r8d
lea    0xeb0(%rip),%rdi
movsbl %cl,%edx
movsbl %al,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1193 <towers+0x73>
mov    0x2ec7(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2ebe(%rip)
mov    -0x5(%rbp),%al
lea    0xe95(%rip),%rdi
movsbl %al,%edx
movsbl -0x6(%rbp),%ecx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <towers+0xd0>
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    0x2e80(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2e77(%rip)
mov    -0x5(%rbp),%al
lea    0xe4e(%rip),%rdi
movsbl %al,%edx
movsbl -0x6(%rbp),%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    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r13d
mov    %edi,%ebp
lea    0xec4(%rip),%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
movsbl %r14b,%r14d
cmp    $0x1,%ebp
jne    115c <towers+0x3c>
mov    %r13d,%r12d
jmp    11c0 <towers+0xa0>
add    $0xffffffff,%ebp
nop
mov    %ebx,%r12d
movsbl %r13b,%ebx
movsbl %r12b,%r15d
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <towers@plt>
mov    0x2eb4(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2eab(%rip)
lea    0xe85(%rip),%rdi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%ebx
mov    %r12d,%r13d
add    $0xffffffff,%ebp
jne    1160 <towers+0x40>
mov    0x2e6e(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2e65(%rip)
movsbl %r12b,%edx
lea    0xe3b(%rip),%rdi
mov    %r14d,%ecx
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):
@towers.step = internal global i32 0
@.str = [21 x i8] c"Towers(%d %c %c %c)\0A\00"
@.str.1 = [28 x i8] c"\09\09\09Step %3d: Move %c to %c\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 = load i8, i8* %6
%11 = load i8, i8* %7
%12 = load i8, i8* %8
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9, i8 signext %10, i8 signext %11, i32 %13)
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %4
%18 = load i32, i32* @towers.step
%19 = add nsw i32 %18, 1
store i32 %19, i32* @towers.step
%20 = load i8, i8* %6
%21 = load i8, i8* %7
%22 = call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8 signext %20, i8 signext %21)
br label %39
23: ; preds = %4
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 1
%26 = load i8, i8* %6
%27 = load i8, i8* %8
%28 = load i8, i8* %7
%29 = load i32, i32* @towers.step
%30 = add nsw i32 %29, 1
store i32 %30, i32* @towers.step
%31 = load i8, i8* %6
%32 = load i8, i8* %7
%33 = call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8 signext %31, i8 signext %32)
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = load i8, i8* %8
%37 = load i8, i8* %7
%38 = load i8, i8* %6
br label %39
39: ; preds = %23, %17
ret void
}

LLVM IR (-O2):
@towers.step = internal unnamed_addr global i32 0
@.str = [21 x i8] c"Towers(%d %c %c %c)\0A\00"
@.str.1 = [28 x i8] c"\09\09\09Step %3d: Move %c to %c\0A\00"
define void @towers(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = sext i8 %3 to i32
%6 = tail call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %0, i8 signext %1, i8 signext %2, i32 %5)
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %13
8: ; preds = %13, %4
%9 = phi i8 [ %1, %4 ], [ %14, %13 ]
%10 = load i32, i32* @towers.step
%11 = add nsw i32 %10, 1
store i32 %11, i32* @towers.step
%12 = tail call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8 signext %9, i8 signext %2)
ret void
13: ; preds = %4, %13
%14 = phi i8 [ %15, %13 ], [ %3, %4 ]
%15 = phi i8 [ %14, %13 ], [ %1, %4 ]
%16 = phi i32 [ %17, %13 ], [ %0, %4 ]
%17 = add nsw i32 %16, -1
tail call void @towers(i32 %17, i8 signext %15, i8 signext %14, i8 signext %2)
%18 = load i32, i32* @towers.step
%19 = add nsw i32 %18, 1
store i32 %19, i32* @towers.step
%20 = tail call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8 signext %15, i8 signext %2)
%21 = sext i8 %15 to i32
%22 = tail call i32 (i8*, i32, i8, i8, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17, i8 signext %14, i8 signext %2, i32 %21)
%23 = icmp eq i32 %17, 1
br i1 %23, label %8, label %13
}