#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, char, char);
int move_disk(int disk, char source, char dest, char aux) {
  int static count = 0;
  if (disk == 1) {
    count++;
    printf("[%d] Move disk %d from peg %c to peg %c.\n", count, disk, source,
           dest);
    return count;
  }
  move_disk(disk - 1, source, aux, dest);
  count++;
  printf("[%d] Move disk %d from peg %c to peg %c.\n", count, disk, source,
         dest);
  move_disk(disk - 1, aux, dest, source);
  return count;
}


x86 assembly (clang, -O0):
<move_disk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %edi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %cl,-0xa(%rbp)
mov    %al,-0xb(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1182 <move_disk+0x62>
mov    0x2ee9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee0(%rip)
mov    0x2eda(%rip),%esi
mov    -0x8(%rbp),%edx
mov    -0x9(%rbp),%al
lea    0xe99(%rip),%rdi
movsbl %al,%ecx
movsbl -0xa(%rbp),%r8d
call   1040 <printf@plt>
mov    0x2eba(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    11f0 <move_disk+0xd0>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x9(%rbp),%cl
mov    -0xb(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0xa(%rbp),%ecx
call   1030 <move_disk@plt>
mov    0x2e91(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e88(%rip)
mov    0x2e82(%rip),%esi
mov    -0x8(%rbp),%edx
mov    -0x9(%rbp),%al
lea    0xe41(%rip),%rdi
movsbl %al,%ecx
movsbl -0xa(%rbp),%r8d
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xb(%rbp),%cl
mov    -0xa(%rbp),%al
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x9(%rbp),%ecx
call   1030 <move_disk@plt>
mov    0x2e47(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_disk>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jne    1159 <move_disk+0x39>
mov    0x2f01(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ef8(%rip)
movsbl %sil,%ecx
movsbl %dl,%r8d
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <printf@plt>
jmp    11ad <move_disk+0x8d>
mov    %edi,%ebx
lea    -0x1(%rbx),%r14d
movsbl %sil,%r12d
movsbl %cl,%r15d
movsbl %dl,%ebp
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
call   1030 <move_disk@plt>
mov    0x2eb4(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2eab(%rip)
lea    0xe70(%rip),%rdi
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <move_disk@plt>
mov    0x2e81(%rip),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@move_disk.count = internal global i32 0
@.str = [42 x i8] c"[%d] Move disk %d from peg %c to peg %c.\0A\00"
define i32 @move_disk(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i32 %0, i32* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8 %3, i8* %9
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %21
12: ; preds = %4
%13 = load i32, i32* @move_disk.count
%14 = add nsw i32 %13, 1
store i32 %14, i32* @move_disk.count
%15 = load i32, i32* @move_disk.count
%16 = load i32, i32* %6
%17 = load i8, i8* %7
%18 = load i8, i8* %8
%19 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i8 signext %17, i8 signext %18)
%20 = load i32, i32* @move_disk.count
store i32 %20, i32* %5
br label %42
21: ; preds = %4
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = load i8, i8* %7
%25 = load i8, i8* %9
%26 = load i8, i8* %8
%27 = call i32 @move_disk(i32 %23, i8 signext %24, i8 signext %25, i8 signext %26)
%28 = load i32, i32* @move_disk.count
%29 = add nsw i32 %28, 1
store i32 %29, i32* @move_disk.count
%30 = load i32, i32* @move_disk.count
%31 = load i32, i32* %6
%32 = load i8, i8* %7
%33 = load i8, i8* %8
%34 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %31, i8 signext %32, i8 signext %33)
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = load i8, i8* %9
%38 = load i8, i8* %8
%39 = load i8, i8* %7
%40 = call i32 @move_disk(i32 %36, i8 signext %37, i8 signext %38, i8 signext %39)
%41 = load i32, i32* @move_disk.count
store i32 %41, i32* %5
br label %42
42: ; preds = %21, %12
%43 = load i32, i32* %5
ret i32 %43
}

LLVM IR (-O2):
@move_disk.count = internal unnamed_addr global i32 0
@.str = [42 x i8] c"[%d] Move disk %d from peg %c to peg %c.\0A\00"
define i32 @move_disk(i32 %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = load i32, i32* @move_disk.count
%8 = add nsw i32 %7, 1
store i32 %8, i32* @move_disk.count
%9 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %8, i32 1, i8 signext %1, i8 signext %2)
br label %17
10: ; preds = %4
%11 = add nsw i32 %0, -1
%12 = tail call i32 @move_disk(i32 %11, i8 signext %1, i8 signext %3, i8 signext %2)
%13 = load i32, i32* @move_disk.count
%14 = add nsw i32 %13, 1
store i32 %14, i32* @move_disk.count
%15 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %0, i8 signext %1, i8 signext %2)
%16 = tail call i32 @move_disk(i32 %11, i8 signext %3, i8 signext %2, i8 signext %1)
br label %17
17: ; preds = %10, %6
%18 = load i32, i32* @move_disk.count
ret i32 %18
}