#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 */
struct apex_epoll {
  int dummy;
};
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
void apex_http_response_file(char *, char *, struct apex_epoll *, int);
scalar_t__ strstr(char *, char *);
void apex_http_response(char *name, struct apex_epoll *this, int fd) {
  char *type = {0};
  ssize_t size = 0;
  if (strstr(name, ".html"))
    type = "text/html\n";
  else if (strstr(name, ".jpeg"))
    type = "image/jpeg\n";
  else if (strstr(name, ".jpg"))
    type = "image/jpg\n";
  else if (strstr(name, ".png"))
    type = "image/png\n";
  else if (strstr(name, ".gif"))
    type = "image/gif\n";
  else if (strstr(name, ".ico"))
    type = "image/ico\n";
  else if (strstr(name, ".js"))
    type = "text/javascript\n";
  else if (strstr(name, ".css"))
    type = "text/css\n";
  else {
    type = "text/plain\n";
  }
  return apex_http_response_file(name, type, this, fd);
}


x86 assembly (clang, -O0):
<apex_http_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     116c <apex_http_response+0x4c>
lea    0xea3(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12c0 <apex_http_response+0x1a0>
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1196 <apex_http_response+0x76>
lea    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12bb <apex_http_response+0x19b>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11c0 <apex_http_response+0xa0>
lea    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12b6 <apex_http_response+0x196>
mov    -0x8(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11ea <apex_http_response+0xca>
lea    0xe57(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12b1 <apex_http_response+0x191>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1214 <apex_http_response+0xf4>
lea    0xe3d(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12ac <apex_http_response+0x18c>
mov    -0x8(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     123e <apex_http_response+0x11e>
lea    0xe23(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12a7 <apex_http_response+0x187>
mov    -0x8(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1268 <apex_http_response+0x148>
lea    0xe08(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12a2 <apex_http_response+0x182>
mov    -0x8(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1292 <apex_http_response+0x172>
lea    0xdf4(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    129d <apex_http_response+0x17d>
lea    0xdee(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12a2 <apex_http_response+0x182>
jmp    12a7 <apex_http_response+0x187>
jmp    12ac <apex_http_response+0x18c>
jmp    12b1 <apex_http_response+0x191>
jmp    12b6 <apex_http_response+0x196>
jmp    12bb <apex_http_response+0x19b>
jmp    12c0 <apex_http_response+0x1a0>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1030 <apex_http_response_file@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apex_http_response>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xecc(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     114a <apex_http_response+0x2a>
lea    0xec1(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xec0(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     116a <apex_http_response+0x4a>
lea    0xeb2(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xeb2(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     118a <apex_http_response+0x6a>
lea    0xea3(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xea2(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11a7 <apex_http_response+0x87>
lea    0xe93(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xe95(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11c4 <apex_http_response+0xa4>
lea    0xe86(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xe88(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11e1 <apex_http_response+0xc1>
lea    0xe79(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xe7b(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11fe <apex_http_response+0xde>
lea    0xe6b(%rip),%rsi
jmp    1222 <apex_http_response+0x102>
lea    0xe73(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
lea    0xe70(%rip),%rax
lea    0xe5f(%rip),%rsi
cmove  %rax,%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <apex_http_response_file@plt>

LLVM IR (-O0):
%struct.apex_epoll = type { i32 }
@.str = [6 x i8] c".html\00"
@.str.1 = [11 x i8] c"text/html\0A\00"
@.str.2 = [6 x i8] c".jpeg\00"
@.str.3 = [12 x i8] c"image/jpeg\0A\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [11 x i8] c"image/jpg\0A\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [11 x i8] c"image/png\0A\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [11 x i8] c"image/gif\0A\00"
@.str.10 = [5 x i8] c".ico\00"
@.str.11 = [11 x i8] c"image/ico\0A\00"
@.str.12 = [4 x i8] c".js\00"
@.str.13 = [17 x i8] c"text/javascript\0A\00"
@.str.14 = [5 x i8] c".css\00"
@.str.15 = [10 x i8] c"text/css\0A\00"
@.str.16 = [12 x i8] c"text/plain\0A\00"
define void @apex_http_response(i8* %0, %struct.apex_epoll* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.apex_epoll*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store %struct.apex_epoll* %1, %struct.apex_epoll** %5
store i32 %2, i32* %6
store i8* null, i8** %7
store i32 0, i32* %8
%9 = load i8*, i8** %4
%10 = call i64 @strstr(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %56
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %55
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i64 @strstr(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %54
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %53
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %7
br label %52
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = call i64 @strstr(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8** %7
br label %51
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = call i64 @strstr(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8** %7
br label %50
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = call i64 @strstr(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8** %7
br label %49
48: ; preds = %43
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8** %7
br label %49
49: ; preds = %48, %47
br label %50
50: ; preds = %49, %42
br label %51
51: ; preds = %50, %37
br label %52
52: ; preds = %51, %32
br label %53
53: ; preds = %52, %27
br label %54
54: ; preds = %53, %22
br label %55
55: ; preds = %54, %17
br label %56
56: ; preds = %55, %12
%57 = load i8*, i8** %4
%58 = load i8*, i8** %7
%59 = load %struct.apex_epoll*, %struct.apex_epoll** %5
%60 = load i32, i32* %6
ret void
}

LLVM IR (-O2):
%struct.apex_epoll = type { i32 }
@.str = [6 x i8] c".html\00"
@.str.1 = [11 x i8] c"text/html\0A\00"
@.str.2 = [6 x i8] c".jpeg\00"
@.str.3 = [12 x i8] c"image/jpeg\0A\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [11 x i8] c"image/jpg\0A\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [11 x i8] c"image/png\0A\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [11 x i8] c"image/gif\0A\00"
@.str.10 = [5 x i8] c".ico\00"
@.str.11 = [11 x i8] c"image/ico\0A\00"
@.str.12 = [4 x i8] c".js\00"
@.str.13 = [17 x i8] c"text/javascript\0A\00"
@.str.14 = [5 x i8] c".css\00"
@.str.15 = [10 x i8] c"text/css\0A\00"
@.str.16 = [12 x i8] c"text/plain\0A\00"
define void @apex_http_response(i8* %0, %struct.apex_epoll* %1, i32 %2) {
%4 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %28
6: ; preds = %3
%7 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0)
br label %28
28: ; preds = %24, %21, %18, %15, %12, %9, %6, %3
%29 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %12 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %15 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), %18 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), %21 ], [ %27, %24 ]
tail call void @apex_http_response_file(i8* %0, i8* %29, %struct.apex_epoll* %1, i32 %2)
ret void
}