#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 */
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int PATH_MAX;
int extract_method(char *, char *);
int /*<<< orphan*/ extract_path(char *, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send_response(char *, int, char *);
int /*<<< orphan*/ *strstr(char *, char *);
void handle_request(int sockfd) {
  char buf[512];
  ssize_t size;
  char path[PATH_MAX - 1];
  char method[10];
  int method_len;
  char *req;
  size = recv(sockfd, buf, 512, 0);
  method_len = extract_method(method, buf);
  req = buf + method_len;
  extract_path(req, size, path, PATH_MAX - 1);
  if (strstr(path, "favicon.ico") != NULL) {
    return;
  }
  send_response(method, sockfd, path);
}


x86 assembly (clang, -O0):
<handle_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x220(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x250(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x228(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x214(%rbp)
lea    -0x232(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1050 <extract_method@plt>
mov    -0x250(%rbp),%rdx
mov    %eax,-0x238(%rbp)
lea    -0x210(%rbp),%rax
movslq -0x238(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rdi
mov    -0x214(%rbp),%esi
mov    0x2df2(%rip),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
call   1060 <extract_path@plt>
mov    -0x250(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1234 <handle_request+0xe4>
movl   $0x1,-0x244(%rbp)
jmp    1254 <handle_request+0x104>
mov    -0x250(%rbp),%rdx
lea    -0x232(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <send_response@plt>
movl   $0x0,-0x244(%rbp)
mov    -0x220(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_request>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %edi,%r14d
mov    %rsp,-0x30(%rbp)
mov    0x2e7e(%rip),%r13
mov    0x0(%r13),%eax
add    $0xffffffff,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x240(%rbp),%r15
mov    %r15,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r12d
lea    -0x3a(%rbp),%rdi
mov    %r15,%rsi
call   1050 <extract_method@plt>
cltq
lea    (%rax,%rbp,1),%rdi
add    $0xfffffffffffffdc0,%rdi
mov    0x0(%r13),%ecx
add    $0xffffffff,%ecx
mov    %r12d,%esi
mov    %rbx,%rdx
call   1060 <extract_path@plt>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11f1 <handle_request+0xa1>
lea    -0x3a(%rbp),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1040 <send_response@plt>
mov    -0x30(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [12 x i8] c"favicon.ico\00"
define void @handle_request(i32 %0) {
%2 = alloca i32
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [10 x i8]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %2
%11 = load i32, i32* @PATH_MAX
%12 = sub nsw i32 %11, 1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = alloca i8, i64 %13
store i64 %13, i64* %6
%16 = load i32, i32* %2
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%18 = call i32 @recv(i32 %16, i8* %17, i32 512, i32 0)
store i32 %18, i32* %4
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = call i32 @extract_method(i8* %19, i8* %20)
store i32 %21, i32* %8
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8* %25, i8** %9
%26 = load i8*, i8** %9
%27 = load i32, i32* %4
%28 = load i32, i32* @PATH_MAX
%29 = sub nsw i32 %28, 1
%30 = call i32 @extract_path(i8* %26, i32 %27, i8* %15, i32 %29)
%31 = call i32* @strstr(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %34
33: ; preds = %1
store i32 1, i32* %10
br label %38
34: ; preds = %1
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%36 = load i32, i32* %2
%37 = call i32 @send_response(i8* %35, i32 %36, i8* %15)
store i32 0, i32* %10
br label %38
38: ; preds = %34, %33
%39 = load i8*, i8** %5
%40 = load i32, i32* %10
switch i32 %40, label %42 [
i32 0, label %41
i32 1, label %41
]
41: ; preds = %38, %38
ret void
42: ; preds = %38
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [12 x i8] c"favicon.ico\00"
define void @handle_request(i32 %0) {
%2 = alloca [512 x i8]
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @PATH_MAX
%6 = add nsw i32 %5, -1
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%11 = call i32 @recv(i32 %0, i8* %4, i32 512, i32 0)
%12 = call i32 @extract_method(i8* %10, i8* %4)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %13
%15 = load i32, i32* @PATH_MAX
%16 = add nsw i32 %15, -1
%17 = call i32 @extract_path(i8* %14, i32 %11, i8* %9, i32 %16)
%18 = call i32* @strstr(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 @send_response(i8* %10, i32 %0, i8* %9)
br label %22
22: ; preds = %1, %20
ret void
}