#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, int);
void hanoi(int n, int A, int B, int C) {
  if (n == 1)
    printf("   plate %d : from %d to %d\n", n, A, C);
  else {
    hanoi(n - 1, A, C, B);
    printf("   plate %d : from %d to %d\n", n, A, C);
    hanoi(n - 1, B, A, C);
  }
}


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   $0x1,-0x4(%rbp)
jne    1158 <hanoi+0x38>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <hanoi+0x75>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <hanoi@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <hanoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %esi,%ebp
cmp    $0x1,%edi
jne    113a <hanoi+0x1a>
mov    %ebp,%r15d
jmp    1180 <hanoi+0x60>
mov    %edi,%ebx
add    $0xffffffff,%ebx
lea    0xeba(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %edx,%r15d
lea    0x1(%rbx),%r13d
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1040 <hanoi@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <printf@plt>
mov    %ebp,%edx
mov    %r15d,%ebp
add    $0xffffffff,%ebx
jne    1150 <hanoi+0x30>
lea    0xe79(%rip),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c" plate %d : from %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* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
br label %31
16: ; preds = %4
%17 = load i32, i32* %5
%18 = sub nsw i32 %17, 1
%19 = load i32, i32* %6
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i32, i32* %8
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = load i32, i32* %8
br label %31
31: ; preds = %16, %11
ret void
}

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