#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*/ mov(char, char);
void hanoi(int n, char src, char dest) {
  char temp;
  if (src + dest == 'B' + 'A')
    temp = 'C';
  if (src + dest == 'A' + 'C')
    temp = 'B';
  if (src + dest == 'B' + 'C')
    temp = 'A';
  if (n == 1)
    mov(src, dest);
  else {
    hanoi(n - 1, src, temp);
    mov(src, dest);
    hanoi(n - 1, temp, dest);
  }
  return;
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %edi,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %ecx,%eax
cmp    $0x83,%eax
jne    114f <hanoi+0x2f>
movb   $0x43,-0x7(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %ecx,%eax
cmp    $0x84,%eax
jne    1168 <hanoi+0x48>
movb   $0x42,-0x7(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %ecx,%eax
cmp    $0x85,%eax
jne    1181 <hanoi+0x61>
movb   $0x41,-0x7(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    119f <hanoi+0x7f>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1030 <mov@plt>
jmp    11d8 <hanoi+0xb8>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x5(%rbp),%al
movsbl %al,%esi
movsbl -0x7(%rbp),%edx
call   1040 <hanoi@plt>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1030 <mov@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x7(%rbp),%al
movsbl %al,%esi
movsbl -0x6(%rbp),%edx
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    %edx,%r15d
movsbl %r15b,%r14d
cmp    $0x1,%edi
jne    113c <hanoi+0x1c>
mov    %esi,%r13d
jmp    11bb <hanoi+0x9b>
mov    %edi,%ebx
mov    %esi,%eax
add    %r15d,%eax
cmp    $0x84,%eax
sete   %cl
xor    $0x43,%cl
cmp    $0x85,%eax
movzbl %cl,%eax
mov    $0x41,%ecx
cmove  %ecx,%eax
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%r13d
movsbl %sil,%ebp
movsbl %al,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12d,%edx
call   1040 <hanoi@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <mov@plt>
movzbl %r12b,%eax
add    %r15d,%eax
cmp    $0x84,%eax
sete   %cl
xor    $0x43,%cl
cmp    $0x85,%eax
movzbl %cl,%eax
mov    $0x41,%ecx
cmove  %ecx,%eax
mov    %r13d,%esi
add    $0xffffffff,%ebx
jne    1170 <hanoi+0x50>
movsbl %r13b,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mov@plt>

LLVM IR (-O0):
define void @hanoi(i32 %0, i8 signext %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = load i8, i8* %6
%11 = sext i8 %10 to i32
%12 = add nsw i32 %9, %11
%13 = icmp eq i32 %12, 131
br i1 %13, label %14, label %15
14: ; preds = %3
store i8 67, i8* %7
br label %15
15: ; preds = %14, %3
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = add nsw i32 %17, %19
%21 = icmp eq i32 %20, 132
br i1 %21, label %22, label %23
22: ; preds = %15
store i8 66, i8* %7
br label %23
23: ; preds = %22, %15
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = add nsw i32 %25, %27
%29 = icmp eq i32 %28, 133
br i1 %29, label %30, label %31
30: ; preds = %23
store i8 65, i8* %7
br label %31
31: ; preds = %30, %23
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i8, i8* %5
%36 = load i8, i8* %6
%37 = call i32 @mov(i8 signext %35, i8 signext %36)
br label %50
38: ; preds = %31
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 1
%41 = load i8, i8* %5
%42 = load i8, i8* %7
%43 = load i8, i8* %5
%44 = load i8, i8* %6
%45 = call i32 @mov(i8 signext %43, i8 signext %44)
%46 = load i32, i32* %4
%47 = sub nsw i32 %46, 1
%48 = load i8, i8* %7
%49 = load i8, i8* %6
br label %50
50: ; preds = %38, %34
ret void
}

LLVM IR (-O2):
define void @hanoi(i32 %0, i8 signext %1, i8 signext %2) {
%4 = sext i8 %2 to i32
%5 = sext i8 %1 to i32
%6 = add nsw i32 %5, %4
%7 = icmp eq i32 %0, 1
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = icmp eq i32 %6, 133
%10 = icmp eq i32 %6, 132
%11 = select i1 %10, i8 66, i8 67
%12 = select i1 %9, i8 65, i8 %11
br label %16
13: ; preds = %16, %3
%14 = phi i8 [ %1, %3 ], [ %17, %16 ]
%15 = tail call i32 @mov(i8 signext %14, i8 signext %2)
ret void
16: ; preds = %8, %16
%17 = phi i8 [ %27, %16 ], [ %12, %8 ]
%18 = phi i8 [ %17, %16 ], [ %1, %8 ]
%19 = phi i32 [ %20, %16 ], [ %0, %8 ]
%20 = add nsw i32 %19, -1
tail call void @hanoi(i32 %20, i8 signext %18, i8 signext %17)
%21 = tail call i32 @mov(i8 signext %18, i8 signext %2)
%22 = zext i8 %17 to i32
%23 = add nsw i32 %22, %4
%24 = icmp eq i32 %23, 132
%25 = select i1 %24, i8 66, i8 67
%26 = icmp eq i32 %23, 133
%27 = select i1 %26, i8 65, i8 %25
%28 = icmp eq i32 %20, 1
br i1 %28, label %13, label %16
}