#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__ strcmp(char *, char *);
char *strrchr(char const *, char);
const char *mime_type(const char *path) {
  char *pos = strrchr(path, '.');
  if (pos == NULL)
    return "text/plain";
  else if (strcmp(pos, ".xml") == 0)
    return "application/octet-stream";
  else if (strcmp(pos, ".zip") == 0)
    return "application/zip";
  else if (strcmp(pos, ".gif") == 0)
    return "image/gif";
  else if (strcmp(pos, ".jpg") == 0)
    return "image/jpeg";
  else if (strcmp(pos, ".png") == 0)
    return "image/png";
  else if (strcmp(pos, ".svg") == 0)
    return "image/svg+xml";
  else
    return "text/plain";
}


x86 assembly (clang, -O0):
<mime_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1159 <mime_type+0x39>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1183 <mime_type+0x63>
lea    0xe96(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ad <mime_type+0x8d>
lea    0xe8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d7 <mime_type+0xb7>
lea    0xe75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1201 <mime_type+0xe1>
lea    0xe5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122b <mime_type+0x10b>
lea    0xe40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1255 <mime_type+0x135>
lea    0xe25(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1260 <mime_type+0x140>
lea    0xda4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mime_type>:
push   %rbx
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     11c1 <mime_type+0xa1>
mov    %rax,%rbx
lea    0xecd(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ca <mime_type+0xaa>
lea    0xed7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d3 <mime_type+0xb3>
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11dc <mime_type+0xbc>
lea    0xed3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e5 <mime_type+0xc5>
lea    0xecf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ee <mime_type+0xce>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xebd(%rip),%rcx
lea    0xe45(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe38(%rip),%rax
pop    %rbx
ret
lea    0xe3f(%rip),%rax
pop    %rbx
ret
lea    0xe54(%rip),%rax
pop    %rbx
ret
lea    0xe60(%rip),%rax
pop    %rbx
ret
lea    0xe66(%rip),%rax
pop    %rbx
ret
lea    0xe6d(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [5 x i8] c".xml\00"
@.str.2 = [25 x i8] c"application/octet-stream\00"
@.str.3 = [5 x i8] c".zip\00"
@.str.4 = [16 x i8] c"application/zip\00"
@.str.5 = [5 x i8] c".gif\00"
@.str.6 = [10 x i8] c"image/gif\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [11 x i8] c"image/jpeg\00"
@.str.9 = [5 x i8] c".png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c".svg\00"
@.str.12 = [14 x i8] c"image/svg+xml\00"
define i8* @mime_type(i8* %0) {
%2 = alloca i8*
%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 %10
9: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %41
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %41
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %41
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %41
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %41
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %41
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %41
40: ; preds = %35
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %41
41: ; preds = %40, %39, %34, %29, %24, %19, %14, %9
%42 = load i8*, i8** %2
ret i8* %42
}

LLVM IR (-O2):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [5 x i8] c".xml\00"
@.str.2 = [25 x i8] c"application/octet-stream\00"
@.str.3 = [5 x i8] c".zip\00"
@.str.4 = [16 x i8] c"application/zip\00"
@.str.5 = [5 x i8] c".gif\00"
@.str.6 = [10 x i8] c"image/gif\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [11 x i8] c"image/jpeg\00"
@.str.9 = [5 x i8] c".png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c".svg\00"
@.str.12 = [14 x i8] c"image/svg+xml\00"
define i8* @mime_type(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), %16 ], [ %22, %19 ]
ret i8* %24
}