#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 *, char);
char *parse_mime(char *uri) {
  char *ext;
  ext = strrchr(uri, '.') + 1;
  if (strcmp(ext, "html") || strcmp(ext, "htm"))
    return "text/html";
  if (strcmp(ext, "gif"))
    return "image/gif";
  if (strcmp(ext, "jpg"))
    return "image/jpg";
  if (strcmp(ext, "png"))
    return "image/png";
  return "application/octet-stream";
}


x86 assembly (clang, -O0):
<parse_mime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1176 <parse_mime+0x56>
mov    -0x18(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1186 <parse_mime+0x66>
lea    0xe87(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <parse_mime+0xef>
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b0 <parse_mime+0x90>
lea    0xe67(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <parse_mime+0xef>
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11da <parse_mime+0xba>
lea    0xe47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <parse_mime+0xef>
mov    -0x18(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1204 <parse_mime+0xe4>
lea    0xe27(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <parse_mime+0xef>
lea    0xe21(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mime>:
push   %r14
push   %rbx
push   %rax
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
lea    0xeb9(%rip),%r14
test   %rax,%rax
jne    11c2 <parse_mime+0xa2>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11c2 <parse_mime+0xa2>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1181 <parse_mime+0x61>
lea    0xe8f(%rip),%r14
jmp    11c2 <parse_mime+0xa2>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     119e <parse_mime+0x7e>
lea    0xe7c(%rip),%r14
jmp    11c2 <parse_mime+0xa2>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe75(%rip),%rax
lea    0xe64(%rip),%r14
cmove  %rax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"html\00"
@.str.1 = [4 x i8] c"htm\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [4 x i8] c"gif\00"
@.str.4 = [10 x i8] c"image/gif\00"
@.str.5 = [4 x i8] c"jpg\00"
@.str.6 = [10 x i8] c"image/jpg\00"
@.str.7 = [4 x i8] c"png\00"
@.str.8 = [10 x i8] c"image/png\00"
@.str.9 = [25 x i8] c"application/octet-stream\00"
define i8* @parse_mime(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)
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %32
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %32
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %32
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %32
31: ; preds = %26
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %32
32: ; preds = %31, %30, %25, %20, %15
%33 = load i8*, i8** %2
ret i8* %33
}

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