#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 */
struct stack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ move(struct stack *, struct stack *);
void hanoi(int n, struct stack *from, struct stack *mid, struct stack *to) {
  if (n == 1) {
    move(from, to);
  } else {
    hanoi(n - 1, from, to, mid);
    move(from, to);
    hanoi(n - 1, mid, from, to);
  }
}


x86 assembly (clang, -O0):
<hanoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1153 <hanoi+0x33>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <move@plt>
jmp    118e <hanoi+0x6e>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1030 <hanoi@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <move@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <hanoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanoi>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    1137 <hanoi+0x17>
mov    %rbx,%r15
jmp    1169 <hanoi+0x49>
mov    %edi,%ebp
add    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    %rdx,%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <hanoi@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <move@plt>
mov    %rbx,%rdx
mov    %r15,%rbx
add    $0xffffffff,%ebp
jne    1140 <hanoi+0x20>
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <move@plt>

LLVM IR (-O0):
%struct.stack = type { i32 }
define void @hanoi(i32 %0, %struct.stack* %1, %struct.stack* %2, %struct.stack* %3) {
%5 = alloca i32
%6 = alloca %struct.stack*
%7 = alloca %struct.stack*
%8 = alloca %struct.stack*
store i32 %0, i32* %5
store %struct.stack* %1, %struct.stack** %6
store %struct.stack* %2, %struct.stack** %7
store %struct.stack* %3, %struct.stack** %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load %struct.stack*, %struct.stack** %6
%13 = load %struct.stack*, %struct.stack** %8
%14 = call i32 @move(%struct.stack* %12, %struct.stack* %13)
br label %29
15: ; preds = %4
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = load %struct.stack*, %struct.stack** %6
%19 = load %struct.stack*, %struct.stack** %8
%20 = load %struct.stack*, %struct.stack** %7
%21 = load %struct.stack*, %struct.stack** %6
%22 = load %struct.stack*, %struct.stack** %8
%23 = call i32 @move(%struct.stack* %21, %struct.stack* %22)
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 1
%26 = load %struct.stack*, %struct.stack** %7
%27 = load %struct.stack*, %struct.stack** %6
%28 = load %struct.stack*, %struct.stack** %8
br label %29
29: ; preds = %15, %11
ret void
}

LLVM IR (-O2):
%struct.stack = type { i32 }
define void @hanoi(i32 %0, %struct.stack* %1, %struct.stack* %2, %struct.stack* %3) {
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %9, %4
%7 = phi %struct.stack* [ %1, %4 ], [ %10, %9 ]
%8 = tail call i32 @move(%struct.stack* %7, %struct.stack* %3)
ret void
9: ; preds = %4, %9
%10 = phi %struct.stack* [ %11, %9 ], [ %2, %4 ]
%11 = phi %struct.stack* [ %10, %9 ], [ %1, %4 ]
%12 = phi i32 [ %13, %9 ], [ %0, %4 ]
%13 = add nsw i32 %12, -1
tail call void @hanoi(i32 %13, %struct.stack* %11, %struct.stack* %3, %struct.stack* %10)
%14 = tail call i32 @move(%struct.stack* %11, %struct.stack* %3)
%15 = icmp eq i32 %13, 1
br i1 %15, label %6, label %9
}