#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*/ algoritmoHanoi(int, char *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  printf("Escriba el numero de discos en la torre de hanoi: ");
  scanf("%d", &n);
  while (n < 0) {
    printf("Error, reescriba el numero de discos en la torre: ");
    scanf("%d", &n);
  }
  algoritmoHanoi(n, "Primera Torre", "Segunda Torre", "Tercera Torre");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1186 <main+0x56>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    115b <main+0x2b>
mov    -0x8(%rbp),%edi
lea    0xed9(%rip),%rsi
lea    0xee0(%rip),%rdx
lea    0xee7(%rip),%rcx
call   1030 <algoritmoHanoi@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jns    119b <main+0x6b>
lea    0xed1(%rip),%r14
lea    0xec7(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
js     1180 <main+0x50>
lea    0xec7(%rip),%rsi
lea    0xece(%rip),%rdx
lea    0xed5(%rip),%rcx
call   1030 <algoritmoHanoi@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Escriba el numero de discos en la torre de hanoi: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Error, reescriba el numero de discos en la torre: \00"
@.str.3 = [14 x i8] c"Primera Torre\00"
@.str.4 = [14 x i8] c"Segunda Torre\00"
@.str.5 = [14 x i8] c"Tercera Torre\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %5
11: ; preds = %5
%12 = load i32, i32* %2
%13 = call i32 @algoritmoHanoi(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"Escriba el numero de discos en la torre de hanoi: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Error, reescriba el numero de discos en la torre: \00"
@.str.3 = [14 x i8] c"Primera Torre\00"
@.str.4 = [14 x i8] c"Segunda Torre\00"
@.str.5 = [14 x i8] c"Tercera Torre\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = call i32 @printf(i8* dereferenceable(1) 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.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = phi i32 [ %5, %0 ], [ %10, %7 ]
%14 = call i32 @algoritmoHanoi(i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}