#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 INT_MIN;
int /*<<< orphan*/ moveDisk(char, char, int);
int pop(struct Stack *);
int /*<<< orphan*/ push(struct Stack *, int);
void moveDisksBetweenTwoPoles(struct Stack *src, struct Stack *dest, char s,
                              char d) {
  int pole1TopDisk = pop(src);
  int pole2TopDisk = pop(dest);
  if (pole1TopDisk == INT_MIN) {
    push(src, pole2TopDisk);
    moveDisk(d, s, pole2TopDisk);
  } else if (pole2TopDisk == INT_MIN) {
    push(dest, pole1TopDisk);
    moveDisk(s, d, pole1TopDisk);
  } else if (pole1TopDisk > pole2TopDisk) {
    push(src, pole1TopDisk);
    push(src, pole2TopDisk);
    moveDisk(d, s, pole2TopDisk);
  } else {
    push(dest, pole2TopDisk);
    push(dest, pole1TopDisk);
    moveDisk(s, d, pole1TopDisk);
  }
}


x86 assembly (clang, -O0):
<moveDisksBetweenTwoPoles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pop@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
jne    1199 <moveDisksBetweenTwoPoles+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <push@plt>
mov    -0x12(%rbp),%cl
mov    -0x11(%rbp),%al
mov    -0x1c(%rbp),%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <moveDisk@plt>
jmp    1243 <moveDisksBetweenTwoPoles+0x113>
mov    -0x1c(%rbp),%eax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%eax
jne    11d0 <moveDisksBetweenTwoPoles+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <push@plt>
mov    -0x11(%rbp),%cl
mov    -0x12(%rbp),%al
mov    -0x18(%rbp),%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <moveDisk@plt>
jmp    123e <moveDisksBetweenTwoPoles+0x10e>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    120d <moveDisksBetweenTwoPoles+0xdd>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <push@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <push@plt>
mov    -0x12(%rbp),%cl
mov    -0x11(%rbp),%al
mov    -0x1c(%rbp),%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <moveDisk@plt>
jmp    1239 <moveDisksBetweenTwoPoles+0x109>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <push@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <push@plt>
mov    -0x11(%rbp),%cl
mov    -0x12(%rbp),%al
mov    -0x18(%rbp),%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <moveDisk@plt>
jmp    123e <moveDisksBetweenTwoPoles+0x10e>
jmp    1243 <moveDisksBetweenTwoPoles+0x113>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moveDisksBetweenTwoPoles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbx
call   1030 <pop@plt>
mov    %eax,%r13d
mov    %r12,%rdi
call   1030 <pop@plt>
mov    %eax,%ebp
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%r13d
je     117b <moveDisksBetweenTwoPoles+0x4b>
cmp    %eax,%ebp
je     119b <moveDisksBetweenTwoPoles+0x6b>
cmp    %ebp,%r13d
jle    1191 <moveDisksBetweenTwoPoles+0x61>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1050 <push@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <push@plt>
movsbl %r14b,%edi
movsbl %r15b,%esi
mov    %ebp,%edx
jmp    11b1 <moveDisksBetweenTwoPoles+0x81>
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <push@plt>
mov    %r12,%rdi
mov    %r13d,%esi
call   1050 <push@plt>
movsbl %r15b,%edi
movsbl %r14b,%esi
mov    %r13d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <moveDisk@plt>

LLVM IR (-O0):
%struct.Stack = type { i32 }
@INT_MIN = global i32 0
define void @moveDisksBetweenTwoPoles(%struct.Stack* %0, %struct.Stack* %1, i8 signext %2, i8 signext %3) {
%5 = alloca %struct.Stack*
%6 = alloca %struct.Stack*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store %struct.Stack* %0, %struct.Stack** %5
store %struct.Stack* %1, %struct.Stack** %6
store i8 %2, i8* %7
store i8 %3, i8* %8
%11 = load %struct.Stack*, %struct.Stack** %5
%12 = call i32 @pop(%struct.Stack* %11)
store i32 %12, i32* %9
%13 = load %struct.Stack*, %struct.Stack** %6
%14 = call i32 @pop(%struct.Stack* %13)
store i32 %14, i32* %10
%15 = load i32, i32* %9
%16 = load i32, i32* @INT_MIN
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %4
%19 = load %struct.Stack*, %struct.Stack** %5
%20 = load i32, i32* %10
%21 = call i32 @push(%struct.Stack* %19, i32 %20)
%22 = load i8, i8* %8
%23 = load i8, i8* %7
%24 = load i32, i32* %10
%25 = call i32 @moveDisk(i8 signext %22, i8 signext %23, i32 %24)
br label %66
26: ; preds = %4
%27 = load i32, i32* %10
%28 = load i32, i32* @INT_MIN
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %26
%31 = load %struct.Stack*, %struct.Stack** %6
%32 = load i32, i32* %9
%33 = call i32 @push(%struct.Stack* %31, i32 %32)
%34 = load i8, i8* %7
%35 = load i8, i8* %8
%36 = load i32, i32* %9
%37 = call i32 @moveDisk(i8 signext %34, i8 signext %35, i32 %36)
br label %65
38: ; preds = %26
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %53
42: ; preds = %38
%43 = load %struct.Stack*, %struct.Stack** %5
%44 = load i32, i32* %9
%45 = call i32 @push(%struct.Stack* %43, i32 %44)
%46 = load %struct.Stack*, %struct.Stack** %5
%47 = load i32, i32* %10
%48 = call i32 @push(%struct.Stack* %46, i32 %47)
%49 = load i8, i8* %8
%50 = load i8, i8* %7
%51 = load i32, i32* %10
%52 = call i32 @moveDisk(i8 signext %49, i8 signext %50, i32 %51)
br label %64
53: ; preds = %38
%54 = load %struct.Stack*, %struct.Stack** %6
%55 = load i32, i32* %10
%56 = call i32 @push(%struct.Stack* %54, i32 %55)
%57 = load %struct.Stack*, %struct.Stack** %6
%58 = load i32, i32* %9
%59 = call i32 @push(%struct.Stack* %57, i32 %58)
%60 = load i8, i8* %7
%61 = load i8, i8* %8
%62 = load i32, i32* %9
%63 = call i32 @moveDisk(i8 signext %60, i8 signext %61, i32 %62)
br label %64
64: ; preds = %53, %42
br label %65
65: ; preds = %64, %30
br label %66
66: ; preds = %65, %18
ret void
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@INT_MIN = global i32 0
define void @moveDisksBetweenTwoPoles(%struct.Stack* %0, %struct.Stack* %1, i8 signext %2, i8 signext %3) {
%5 = tail call i32 @pop(%struct.Stack* %0)
%6 = tail call i32 @pop(%struct.Stack* %1)
%7 = load i32, i32* @INT_MIN
%8 = icmp eq i32 %5, %7
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @push(%struct.Stack* %0, i32 %6)
%11 = tail call i32 @moveDisk(i8 signext %3, i8 signext %2, i32 %6)
br label %27
12: ; preds = %4
%13 = icmp eq i32 %6, %7
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 @push(%struct.Stack* %1, i32 %5)
%16 = tail call i32 @moveDisk(i8 signext %2, i8 signext %3, i32 %5)
br label %27
17: ; preds = %12
%18 = icmp sgt i32 %5, %6
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = tail call i32 @push(%struct.Stack* %0, i32 %5)
%21 = tail call i32 @push(%struct.Stack* %0, i32 %6)
%22 = tail call i32 @moveDisk(i8 signext %3, i8 signext %2, i32 %6)
br label %27
23: ; preds = %17
%24 = tail call i32 @push(%struct.Stack* %1, i32 %6)
%25 = tail call i32 @push(%struct.Stack* %1, i32 %5)
%26 = tail call i32 @moveDisk(i8 signext %2, i8 signext %3, i32 %5)
br label %27
27: ; preds = %14, %23, %19, %9
ret void
}