#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*/ move(char, char);
void fun(char a, char b, char c, int n) {
  if (n == 1)
    move(a, c);
  else {
    fun(a, c, b, n - 1);
    move(a, c);
    fun(b, a, c, n - 1);
  }
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %ecx,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    115b <fun+0x3b>
mov    -0x1(%rbp),%al
movsbl %al,%edi
movsbl -0x3(%rbp),%esi
call   1040 <move@plt>
jmp    11a8 <fun+0x88>
mov    -0x1(%rbp),%sil
mov    -0x3(%rbp),%dl
mov    -0x2(%rbp),%al
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <fun@plt>
mov    -0x1(%rbp),%al
movsbl %al,%edi
movsbl -0x3(%rbp),%esi
call   1040 <move@plt>
mov    -0x2(%rbp),%sil
mov    -0x1(%rbp),%dl
mov    -0x3(%rbp),%al
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <fun@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
movsbl %dl,%r14d
cmp    $0x1,%ecx
jne    1139 <fun+0x19>
mov    %r15d,%ebx
jmp    116d <fun+0x4d>
mov    %ecx,%ebp
add    $0xffffffff,%ebp
xchg   %ax,%ax
mov    %esi,%ebx
movsbl %r15b,%r12d
movsbl %sil,%edx
mov    %r12d,%edi
mov    %r14d,%esi
mov    %ebp,%ecx
call   1030 <fun@plt>
mov    %r12d,%edi
mov    %r14d,%esi
call   1040 <move@plt>
mov    %r15d,%esi
mov    %ebx,%r15d
add    $0xffffffff,%ebp
jne    1140 <fun+0x20>
movsbl %bl,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <move@plt>

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

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