#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*/ moveTower(int, char, char, char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num = 0;
  char source = 'A', dest = 'B', temp = 'T';
  printf("This program generates the moves required for solving the Towers of "
         "Hanoi.\n");
  printf("Tower A is the source tower, B is the destination tower and T is the "
         "spare tower.\n");
  printf("How many disks would you like in your simulation?\n");
  scanf("%d", &num);
  printf("Commencing moves...\n");
  moveTower(num, source, dest, temp);
  printf("Moves completed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x41,-0x9(%rbp)
movb   $0x42,-0xa(%rbp)
movb   $0x54,-0xb(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
call   1030 <printf@plt>
lea    0xf2e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf55(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf48(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x9(%rbp),%cl
mov    -0xa(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0xb(%rbp),%ecx
call   1050 <moveTower@plt>
lea    0xf39(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xf5d(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    $0x41,%esi
mov    $0x42,%edx
mov    $0x54,%ecx
call   1050 <moveTower@plt>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [76 x i8] c"This program generates the moves required for solving the Towers of Hanoi.\0A\00"
@.str.1 = [83 x i8] c"Tower A is the source tower, B is the destination tower and T is the spare tower.\0A\00"
@.str.2 = [51 x i8] c"How many disks would you like in your simulation?\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c"Commencing moves...\0A\00"
@.str.5 = [18 x i8] c"Moves completed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i8 65, i8* %3
store i8 66, i8* %4
store i8 84, i8* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = load i8, i8* %3
%13 = load i8, i8* %4
%14 = load i8, i8* %5
%15 = call i32 @moveTower(i32 %11, i8 signext %12, i8 signext %13, i8 signext %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@str = [75 x i8] c"This program generates the moves required for solving the Towers of Hanoi.\00"
@str.6 = [82 x i8] c"Tower A is the source tower, B is the destination tower and T is the spare tower.\00"
@str.7 = [50 x i8] c"How many disks would you like in your simulation?\00"
@str.8 = [20 x i8] c"Commencing moves...\00"
@str.9 = [17 x i8] c"Moves completed.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.7, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = call i32 @moveTower(i32 %8, i8 signext 65, i8 signext 66, i8 signext 84)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}