#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 shared {
  int dummy;
};

/* Variables and functions */
scalar_t__ getIndex(char *, char *);
int /*<<< orphan*/ processFileRequest(char *, int);
int /*<<< orphan*/ processPostRequest(char *, int, struct shared *);
int /*<<< orphan*/ processStartRecRequest(char *, int, struct shared *,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ processStatusJSONRequest(char *, int, struct shared *);
int /*<<< orphan*/ processStatusRequest(char *, int, struct shared *);
int /*<<< orphan*/ processStopRecRequest(char *, int, struct shared *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ processVideoRequest(char *, int, struct shared *);
int /*<<< orphan*/ return404(char *, int, char *);
void processHttpRequest(char *buffer, int csock, struct shared *global) {
  if (getIndex("GET /web/", buffer) == 0) {
    processFileRequest(buffer, csock);
  } else if (getIndex("GET /status HTTP/1.1", buffer) == 0) {
    processStatusRequest(buffer, csock, global);
  } else if (getIndex("GET /startrec HTTP/1.1", buffer) == 0) {
    processStartRecRequest(buffer, csock, global, NULL);
  } else if (getIndex("GET /stoprec HTTP/1.1", buffer) == 0) {
    processStopRecRequest(buffer, csock, global, NULL);
  } else if (getIndex("GET /video HTTP/1.1", buffer) == 0) {
    processVideoRequest(buffer, csock, global);
  } else if (getIndex("GET /favicon.ico HTTP/1.", buffer) == 0) {
    return404(buffer, csock, "We don't do Favicons =)");
  } else if (getIndex("GET /jstatus HTTP/1.1", buffer) == 0) {
    processStatusJSONRequest(buffer, csock, global);
  } else if (getIndex("POST /action HTTP/1.1", buffer) == 0) {
    processPostRequest(buffer, csock, global);
  } else {
    return404(buffer, csock, "Unknown request");
  }
}


x86 assembly (clang, -O0):
<processHttpRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    11ce <processHttpRequest+0x3e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <processFileRequest@plt>
jmp    1358 <processHttpRequest+0x1c8>
mov    -0x8(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    11fd <processHttpRequest+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1060 <processStatusRequest@plt>
jmp    1353 <processHttpRequest+0x1c3>
mov    -0x8(%rbp),%rsi
lea    0xe17(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    1230 <processHttpRequest+0xa0>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <processStartRecRequest@plt>
jmp    134e <processHttpRequest+0x1be>
mov    -0x8(%rbp),%rsi
lea    0xdfb(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    1263 <processHttpRequest+0xd3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <processStopRecRequest@plt>
jmp    1349 <processHttpRequest+0x1b9>
mov    -0x8(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    1292 <processHttpRequest+0x102>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   10a0 <processVideoRequest@plt>
jmp    1344 <processHttpRequest+0x1b4>
mov    -0x8(%rbp),%rsi
lea    0xdc3(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    12c4 <processHttpRequest+0x134>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xdbf(%rip),%rdx
call   1030 <return404@plt>
jmp    133f <processHttpRequest+0x1af>
mov    -0x8(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    12f3 <processHttpRequest+0x163>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1090 <processStatusJSONRequest@plt>
jmp    133a <processHttpRequest+0x1aa>
mov    -0x8(%rbp),%rsi
lea    0xda9(%rip),%rdi
call   10b0 <getIndex@plt>
cmp    $0x0,%rax
jne    1322 <processHttpRequest+0x192>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1080 <processPostRequest@plt>
jmp    1335 <processHttpRequest+0x1a5>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xd8d(%rip),%rdx
call   1030 <return404@plt>
jmp    133a <processHttpRequest+0x1aa>
jmp    133f <processHttpRequest+0x1af>
jmp    1344 <processHttpRequest+0x1b4>
jmp    1349 <processHttpRequest+0x1b9>
jmp    134e <processHttpRequest+0x1be>
jmp    1353 <processHttpRequest+0x1c3>
jmp    1358 <processHttpRequest+0x1c8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processHttpRequest>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     1265 <processHttpRequest+0xd5>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     1273 <processHttpRequest+0xe3>
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     1284 <processHttpRequest+0xf4>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     1297 <processHttpRequest+0x107>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     12aa <processHttpRequest+0x11a>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     12bb <processHttpRequest+0x12b>
lea    0xe5e(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     12d0 <processHttpRequest+0x140>
lea    0xe5c(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <getIndex@plt>
test   %rax,%rax
je     12e1 <processHttpRequest+0x151>
lea    0xe5a(%rip),%rdx
jmp    12c2 <processHttpRequest+0x132>
mov    %rbx,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <processFileRequest@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <processStatusRequest@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <processStartRecRequest@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <processStopRecRequest@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <processVideoRequest@plt>
lea    0xdb7(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <return404@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <processStatusJSONRequest@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <processPostRequest@plt>

LLVM IR (-O0):
%struct.shared = type { i32 }
@.str = [10 x i8] c"GET /web/\00"
@.str.1 = [21 x i8] c"GET /status HTTP/1.1\00"
@.str.2 = [23 x i8] c"GET /startrec HTTP/1.1\00"
@.str.3 = [22 x i8] c"GET /stoprec HTTP/1.1\00"
@.str.4 = [20 x i8] c"GET /video HTTP/1.1\00"
@.str.5 = [25 x i8] c"GET /favicon.ico HTTP/1.\00"
@.str.6 = [24 x i8] c"We don't do Favicons =)\00"
@.str.7 = [22 x i8] c"GET /jstatus HTTP/1.1\00"
@.str.8 = [22 x i8] c"POST /action HTTP/1.1\00"
@.str.9 = [16 x i8] c"Unknown request\00"
define void @processHttpRequest(i8* %0, i32 %1, %struct.shared* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.shared*
store i8* %0, i8** %4
store i32 %1, i32* %5
store %struct.shared* %2, %struct.shared** %6
%7 = load i8*, i8** %4
%8 = call i64 @getIndex(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = call i32 @processFileRequest(i8* %11, i32 %12)
br label %87
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i64 @getIndex(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = load %struct.shared*, %struct.shared** %6
%22 = call i32 @processStatusRequest(i8* %19, i32 %20, %struct.shared* %21)
br label %86
23: ; preds = %14
%24 = load i8*, i8** %4
%25 = call i64 @getIndex(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = load %struct.shared*, %struct.shared** %6
%31 = call i32 @processStartRecRequest(i8* %28, i32 %29, %struct.shared* %30, i32* null)
br label %85
32: ; preds = %23
%33 = load i8*, i8** %4
%34 = call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = load i32, i32* %5
%39 = load %struct.shared*, %struct.shared** %6
%40 = call i32 @processStopRecRequest(i8* %37, i32 %38, %struct.shared* %39, i32* null)
br label %84
41: ; preds = %32
%42 = load i8*, i8** %4
%43 = call i64 @getIndex(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = load i32, i32* %5
%48 = load %struct.shared*, %struct.shared** %6
%49 = call i32 @processVideoRequest(i8* %46, i32 %47, %struct.shared* %48)
br label %83
50: ; preds = %41
%51 = load i8*, i8** %4
%52 = call i64 @getIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i8*, i8** %4
%56 = load i32, i32* %5
%57 = call i32 @return404(i8* %55, i32 %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %82
58: ; preds = %50
%59 = load i8*, i8** %4
%60 = call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i8*, i8** %4
%64 = load i32, i32* %5
%65 = load %struct.shared*, %struct.shared** %6
%66 = call i32 @processStatusJSONRequest(i8* %63, i32 %64, %struct.shared* %65)
br label %81
67: ; preds = %58
%68 = load i8*, i8** %4
%69 = call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %67
%72 = load i8*, i8** %4
%73 = load i32, i32* %5
%74 = load %struct.shared*, %struct.shared** %6
%75 = call i32 @processPostRequest(i8* %72, i32 %73, %struct.shared* %74)
br label %80
76: ; preds = %67
%77 = load i8*, i8** %4
%78 = load i32, i32* %5
%79 = call i32 @return404(i8* %77, i32 %78, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %80
80: ; preds = %76, %71
br label %81
81: ; preds = %80, %62
br label %82
82: ; preds = %81, %54
br label %83
83: ; preds = %82, %45
br label %84
84: ; preds = %83, %36
br label %85
85: ; preds = %84, %27
br label %86
86: ; preds = %85, %18
br label %87
87: ; preds = %86, %10
ret void
}

LLVM IR (-O2):
%struct.shared = type { i32 }
@.str = [10 x i8] c"GET /web/\00"
@.str.1 = [21 x i8] c"GET /status HTTP/1.1\00"
@.str.2 = [23 x i8] c"GET /startrec HTTP/1.1\00"
@.str.3 = [22 x i8] c"GET /stoprec HTTP/1.1\00"
@.str.4 = [20 x i8] c"GET /video HTTP/1.1\00"
@.str.5 = [25 x i8] c"GET /favicon.ico HTTP/1.\00"
@.str.6 = [24 x i8] c"We don't do Favicons =)\00"
@.str.7 = [22 x i8] c"GET /jstatus HTTP/1.1\00"
@.str.8 = [22 x i8] c"POST /action HTTP/1.1\00"
@.str.9 = [16 x i8] c"Unknown request\00"
define void @processHttpRequest(i8* %0, i32 %1, %struct.shared* %2) {
%4 = tail call i64 @getIndex(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @processFileRequest(i8* %0, i32 %1)
br label %45
8: ; preds = %3
%9 = tail call i64 @getIndex(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @processStatusRequest(i8* %0, i32 %1, %struct.shared* %2)
br label %45
13: ; preds = %8
%14 = tail call i64 @getIndex(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @processStartRecRequest(i8* %0, i32 %1, %struct.shared* %2, i32* null)
br label %45
18: ; preds = %13
%19 = tail call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @processStopRecRequest(i8* %0, i32 %1, %struct.shared* %2, i32* null)
br label %45
23: ; preds = %18
%24 = tail call i64 @getIndex(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @processVideoRequest(i8* %0, i32 %1, %struct.shared* %2)
br label %45
28: ; preds = %23
%29 = tail call i64 @getIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @return404(i8* %0, i32 %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %45
33: ; preds = %28
%34 = tail call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @processStatusJSONRequest(i8* %0, i32 %1, %struct.shared* %2)
br label %45
38: ; preds = %33
%39 = tail call i64 @getIndex(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 @processPostRequest(i8* %0, i32 %1, %struct.shared* %2)
br label %45
43: ; preds = %38
%44 = tail call i32 @return404(i8* %0, i32 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %45
45: ; preds = %11, %21, %31, %41, %43, %36, %26, %16, %6
ret void
}