#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 */
scalar_t__ strcasecmp(char *, char const *);
char *strrchr(char const *, char);
int get_code(const char *arg) {
  const char *suffix = strrchr(arg, '.');
  if (suffix == NULL)
    suffix = arg;
  if (suffix[0] == '.') {
    suffix++;
  }
  if (strcasecmp("WAV", suffix) == 0)
    return 1;
  else if (strcasecmp("MP3", suffix) == 0)
    return 2;
  else if (strcasecmp("OGG", suffix) == 0)
    return 3;
  else if (strcasecmp("FLAC", suffix) == 0)
    return 4;
  else if (strcasecmp("AO", suffix) == 0)
    return 5;
  return 65536;
  ;
}


x86 assembly (clang, -O0):
<get_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1151 <get_code+0x31>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    116d <get_code+0x4d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1193 <get_code+0x73>
movl   $0x1,-0x4(%rbp)
jmp    1246 <get_code+0x126>
mov    -0x18(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11b9 <get_code+0x99>
movl   $0x2,-0x4(%rbp)
jmp    1246 <get_code+0x126>
mov    -0x18(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11df <get_code+0xbf>
movl   $0x3,-0x4(%rbp)
jmp    1246 <get_code+0x126>
mov    -0x18(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1205 <get_code+0xe5>
movl   $0x4,-0x4(%rbp)
jmp    1246 <get_code+0x126>
mov    -0x18(%rbp),%rsi
lea    0xe01(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    122b <get_code+0x10b>
movl   $0x5,-0x4(%rbp)
jmp    1246 <get_code+0x126>
jmp    1230 <get_code+0x110>
jmp    1235 <get_code+0x115>
jmp    123a <get_code+0x11a>
jmp    123f <get_code+0x11f>
movl   $0x10000,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_code>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
cmove  %rbx,%rax
xor    %ebx,%ebx
cmpb   $0x2e,(%rax)
sete   %bl
add    %rax,%rbx
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b1 <get_code+0x91>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b8 <get_code+0x98>
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11bf <get_code+0x9f>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c6 <get_code+0xa6>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
mov    $0x5,%ecx
mov    $0x10000,%eax
cmove  %ecx,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"WAV\00"
@.str.1 = [4 x i8] c"MP3\00"
@.str.2 = [4 x i8] c"OGG\00"
@.str.3 = [5 x i8] c"FLAC\00"
@.str.4 = [3 x i8] c"AO\00"
define i32 @get_code(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %9, %1
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 46
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
br label %20
20: ; preds = %17, %11
%21 = load i8*, i8** %4
%22 = call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %2
br label %50
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 2, i32* %2
br label %50
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 3, i32* %2
br label %50
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 4, i32* %2
br label %50
40: ; preds = %35
%41 = load i8*, i8** %4
%42 = call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 5, i32* %2
br label %50
45: ; preds = %40
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
store i32 65536, i32* %2
br label %50
50: ; preds = %49, %44, %39, %34, %29, %24
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [4 x i8] c"WAV\00"
@.str.1 = [4 x i8] c"MP3\00"
@.str.2 = [4 x i8] c"OGG\00"
@.str.3 = [5 x i8] c"FLAC\00"
@.str.4 = [3 x i8] c"AO\00"
define i32 @get_code(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
%4 = select i1 %3, i8* %0, i8* %2
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 46
%7 = zext i1 %6 to i64
%8 = getelementptr i8, i8* %4, i64 %7
%9 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %1
%12 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %14
%18 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i32 5, i32 65536
br label %24
24: ; preds = %20, %17, %14, %11, %1
%25 = phi i32 [ 1, %1 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ %23, %20 ]
ret i32 %25
}