#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 getFileType(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sclRename(char *, char *, char *);
int /*<<< orphan*/ tapRename(char *, char *, char *);
int /*<<< orphan*/ trdRename(char *, char *, char *);
void renam(char *ipath, char *oname, char *nname) {
  int type = getFileType(ipath);
  switch (type) {
  case 3:
    tapRename(ipath, oname, nname);
    break;
  case 1:
    sclRename(ipath, oname, nname);
    break;
  case 2:
    trdRename(ipath, oname, nname);
    break;
  default:
    printf("Unknown image type\n");
    break;
  }
}


x86 assembly (clang, -O0):
<renam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getFileType@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     11bc <renam+0x6c>
jmp    1184 <renam+0x34>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     11d2 <renam+0x82>
jmp    1195 <renam+0x45>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
jne    11e8 <renam+0x98>
jmp    11a6 <renam+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <tapRename@plt>
jmp    11f4 <renam+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <sclRename@plt>
jmp    11f4 <renam+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <trdRename@plt>
jmp    11f4 <renam+0xa4>
lea    0xe11(%rip),%rdi
call   1060 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<renam>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1060 <getFileType@plt>
cmp    $0x1,%eax
je     1185 <renam+0x35>
cmp    $0x2,%eax
je     1198 <renam+0x48>
cmp    $0x3,%eax
jne    11ab <renam+0x5b>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <tapRename@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <sclRename@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <trdRename@plt>
lea    0xe4e(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Unknown image type\0A\00"
define void @renam(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32 @getFileType(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
switch i32 %10, label %26 [
i32 3, label %11
i32 1, label %16
i32 2, label %21
]
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32 @tapRename(i8* %12, i8* %13, i8* %14)
br label %28
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = call i32 @sclRename(i8* %17, i8* %18, i8* %19)
br label %28
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @trdRename(i8* %22, i8* %23, i8* %24)
br label %28
26: ; preds = %3
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %21, %16, %11
ret void
}

LLVM IR (-O2):
@str = [19 x i8] c"Unknown image type\00"
define void @renam(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @getFileType(i8* %0)
switch i32 %4, label %11 [
i32 3, label %5
i32 1, label %7
i32 2, label %9
]
5: ; preds = %3
%6 = tail call i32 @tapRename(i8* %0, i8* %1, i8* %2)
br label %13
7: ; preds = %3
%8 = tail call i32 @sclRename(i8* %0, i8* %1, i8* %2)
br label %13
9: ; preds = %3
%10 = tail call i32 @trdRename(i8* %0, i8* %1, i8* %2)
br label %13
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5
ret void
}