#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__ built_in(char *, int);
int /*<<< orphan*/ cannot_do(int);
int /*<<< orphan*/ do_404(char *, int);
int /*<<< orphan*/ do_cat(char *, int);
int /*<<< orphan*/ do_ls(char *, int);
scalar_t__ isadir(char *);
scalar_t__ not_exist(char *);
int /*<<< orphan*/ sanitize(char *);
int sscanf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void process_rq(char *rq, int fd) {
  char cmd[1024], arg[1024];
  if (sscanf(rq, "%s %s", cmd, arg) != 2)
    return;
  sanitize(arg);
  if (strcmp(cmd, "GET") != 0)
    cannot_do(fd);
  else if (built_in(arg, fd))
    ;
  else if (not_exist(arg))
    do_404(arg, fd);
  else if (isadir(arg))
    do_ls(arg, fd);
  else
    do_cat(arg, fd);
}


x86 assembly (clang, -O0):
<process_rq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    -0x810(%rbp),%rcx
lea    0xe35(%rip),%rsi
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
je     11de <process_rq+0x3e>
jmp    12a4 <process_rq+0x104>
lea    -0x810(%rbp),%rdi
call   10c0 <sanitize@plt>
lea    -0x410(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1214 <process_rq+0x74>
mov    -0xc(%rbp),%edi
call   1050 <cannot_do@plt>
jmp    12a4 <process_rq+0x104>
lea    -0x810(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1090 <built_in@plt>
cmp    $0x0,%rax
je     1232 <process_rq+0x92>
jmp    129f <process_rq+0xff>
lea    -0x810(%rbp),%rdi
call   1070 <not_exist@plt>
cmp    $0x0,%rax
je     125c <process_rq+0xbc>
lea    -0x810(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <do_404@plt>
jmp    129a <process_rq+0xfa>
lea    -0x810(%rbp),%rdi
call   1060 <isadir@plt>
cmp    $0x0,%rax
je     1286 <process_rq+0xe6>
lea    -0x810(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10a0 <do_ls@plt>
jmp    1295 <process_rq+0xf5>
lea    -0x810(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <do_cat@plt>
jmp    129a <process_rq+0xfa>
jmp    129f <process_rq+0xff>
jmp    12a4 <process_rq+0x104>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_rq>:
push   %rbx
sub    $0x800,%rsp
mov    %esi,%ebx
lea    0xe4f(%rip),%rsi
lea    0x400(%rsp),%rdx
mov    %rsp,%rcx
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
jne    1233 <process_rq+0x93>
mov    %rsp,%rdi
call   10c0 <sanitize@plt>
lea    0xe31(%rip),%rsi
lea    0x400(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11f0 <process_rq+0x50>
mov    %ebx,%edi
call   1050 <cannot_do@plt>
jmp    1233 <process_rq+0x93>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1090 <built_in@plt>
test   %rax,%rax
jne    1233 <process_rq+0x93>
mov    %rsp,%rdi
call   1070 <not_exist@plt>
mov    %rsp,%rdi
test   %rax,%rax
je     1218 <process_rq+0x78>
mov    %ebx,%esi
call   1030 <do_404@plt>
jmp    1233 <process_rq+0x93>
call   1060 <isadir@plt>
mov    %rsp,%rdi
mov    %ebx,%esi
test   %rax,%rax
je     122e <process_rq+0x8e>
call   10a0 <do_ls@plt>
jmp    1233 <process_rq+0x93>
call   1040 <do_cat@plt>
add    $0x800,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [4 x i8] c"GET\00"
define void @process_rq(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
br label %51
13: ; preds = %2
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @sanitize(i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %4
%21 = call i32 @cannot_do(i32 %20)
br label %51
22: ; preds = %13
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = load i32, i32* %4
%25 = call i64 @built_in(i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %50
28: ; preds = %22
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%30 = call i64 @not_exist(i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* %4
%35 = call i32 @do_404(i8* %33, i32 %34)
br label %49
36: ; preds = %28
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%38 = call i64 @isadir(i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%42 = load i32, i32* %4
%43 = call i32 @do_ls(i8* %41, i32 %42)
br label %48
44: ; preds = %36
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%46 = load i32, i32* %4
%47 = call i32 @do_cat(i8* %45, i32 %46)
br label %48
48: ; preds = %44, %40
br label %49
49: ; preds = %48, %32
br label %50
50: ; preds = %49, %27
br label %51
51: ; preds = %12, %50, %19
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [4 x i8] c"GET\00"
define void @process_rq(i8* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %30
9: ; preds = %2
%10 = call i32 @sanitize(i8* %6)
%11 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @cannot_do(i32 %1)
br label %30
15: ; preds = %9
%16 = call i64 @built_in(i8* %6, i32 %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = call i64 @not_exist(i8* %6)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 @do_404(i8* %6, i32 %1)
br label %30
23: ; preds = %18
%24 = call i64 @isadir(i8* %6)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @do_ls(i8* %6, i32 %1)
br label %30
28: ; preds = %23
%29 = call i32 @do_cat(i8* %6, i32 %1)
br label %30
30: ; preds = %13, %21, %28, %26, %15, %2
ret void
}