#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*/ strcmp(char const *, char *);
int strlen(char const *);
const char *get_mimetype(const char *file) {
  int n = strlen(file);
  if (n < 5)
    return NULL;
  if (!strcmp(&file[n - 4], ".ico"))
    return "image/x-icon";
  if (!strcmp(&file[n - 4], ".png"))
    return "image/png";
  if (!strcmp(&file[n - 5], ".html"))
    return "text/html";
  return NULL;
}


x86 assembly (clang, -O0):
<get_mimetype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    114f <get_mimetype+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    11f3 <get_mimetype+0xd3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
cltq
add    %rax,%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1183 <get_mimetype+0x63>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f3 <get_mimetype+0xd3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
cltq
add    %rax,%rdi
lea    0xe79(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <get_mimetype+0x97>
lea    0xe69(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f3 <get_mimetype+0xd3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
cltq
add    %rax,%rdi
lea    0xe54(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11eb <get_mimetype+0xcb>
lea    0xe45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f3 <get_mimetype+0xd3>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mimetype>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x5,%eax
jge    1136 <get_mimetype+0x16>
xor    %eax,%eax
jmp    119f <get_mimetype+0x7f>
mov    %eax,%r15d
lea    -0x4(%r15),%ebx
add    %r14,%rbx
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     118f <get_mimetype+0x6f>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1198 <get_mimetype+0x78>
add    $0xfffffffb,%r15d
add    %r15,%r14
lea    0xead(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
lea    0xe9e(%rip),%rcx
cmove  %rcx,%rax
jmp    119f <get_mimetype+0x7f>
lea    0xe6f(%rip),%rax
jmp    119f <get_mimetype+0x7f>
lea    0xe78(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c".ico\00"
@.str.1 = [13 x i8] c"image/x-icon\00"
@.str.2 = [5 x i8] c".png\00"
@.str.3 = [10 x i8] c"image/png\00"
@.str.4 = [6 x i8] c".html\00"
@.str.5 = [10 x i8] c"text/html\00"
define i8* @get_mimetype(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* null, i8** %2
br label %38
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %10
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %38
19: ; preds = %10
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %19
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %38
28: ; preds = %19
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %28
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %38
37: ; preds = %28
store i8* null, i8** %2
br label %38
38: ; preds = %37, %36, %27, %18, %9
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
@.str = [5 x i8] c".ico\00"
@.str.1 = [13 x i8] c"image/x-icon\00"
@.str.2 = [5 x i8] c".png\00"
@.str.3 = [10 x i8] c"image/png\00"
@.str.4 = [6 x i8] c".html\00"
@.str.5 = [10 x i8] c"text/html\00"
define i8* @get_mimetype(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 5
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = add nsw i32 %2, -4
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %4
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = add nsw i32 %2, -5
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* null
br label %20
20: ; preds = %13, %10, %4, %1
%21 = phi i8* [ null, %1 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %10 ], [ %19, %13 ]
ret i8* %21
}