#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, int);
void hanoi(int source, int target, int auxiliary, int disks) {
  if (disks == 0) {
    return;
  }
  hanoi(source, auxiliary, target, disks - 1);
  printf("Move from tower %d to %d\n", source, target);
  hanoi(auxiliary, target, source, disks - 1);
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1143 <hanoi+0x23>
jmp    117d <hanoi+0x5d>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <hanoi@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <hanoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
je     1168 <hanoi+0x48>
mov    %ecx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
add    $0xffffffff,%ebx
lea    0xec3(%rip),%r15
nopl   (%rax)
mov    %edx,%r12d
mov    %ebp,%edi
mov    %edx,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1040 <hanoi@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
mov    %ebp,%edx
mov    %r12d,%ebp
add    $0xffffffff,%ebx
jb     1140 <hanoi+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Move from tower %d to %d\0A\00"
define void @hanoi(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %4
br label %26
12: ; preds = %4
%13 = load i32, i32* %5
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = sub nsw i32 %16, 1
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
br label %26
26: ; preds = %12, %11
ret void
}

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