#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*/ method;

/* Variables and functions */
int /*<<< orphan*/ deleted(char *, int);
int /*<<< orphan*/ deletef(char *, int);
int /*<<< orphan*/ getd(char *, int);
int /*<<< orphan*/ getf(char *, int);
int /*<<< orphan*/ postd(char *, int);
int /*<<< orphan*/ postf(char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ putd(char *, int);
int /*<<< orphan*/ putf(char *, int);
long read(int, char *, int);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void request(int socketfd) {
  long len;
  char method[262144], *uri, *rest;
  len = read(socketfd, method, sizeof(method) - 1);
  if (len == 0 || len == -1)
    return;
  method[len] = 0;
  uri = strchr(method, ' ');
  *uri = 0;
  uri += 2;
  rest = strchr(uri, ' ');
  *rest = 0;
  printf("\n%s %s", method, uri);
  if (!*uri || uri[strlen(uri) - 1] == '/') {
    if (strcmp(method, "GET") == 0)
      getd(uri, socketfd);
    if (strcmp(method, "PUT") == 0)
      putd(uri, socketfd);
    if (strcmp(method, "POST") == 0)
      postd(uri, socketfd);
    if (strcmp(method, "DELETE") == 0)
      deleted(uri, socketfd);
  } else {
    if (strcmp(method, "GET") == 0)
      getf(uri, socketfd);
    if (strcmp(method, "PUT") == 0)
      putf(uri, socketfd);
    if (strcmp(method, "POST") == 0)
      postf(uri, socketfd);
    if (strcmp(method, "DELETE") == 0)
      deletef(uri, socketfd);
  }
}


x86 assembly (clang, -O0):
<request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40030,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40010(%rbp),%rsi
mov    $0x3ffff,%edx
call   10e0 <read@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     120c <request+0x3c>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
jne    1211 <request+0x41>
jmp    143d <request+0x26d>
mov    -0x10(%rbp),%rax
movb   $0x0,-0x40010(%rbp,%rax,1)
lea    -0x40010(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <strchr@plt>
mov    %rax,-0x40018(%rbp)
mov    -0x40018(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40018(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40018(%rbp)
mov    -0x40018(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <strchr@plt>
mov    %rax,-0x40020(%rbp)
mov    -0x40020(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x40010(%rbp),%rsi
mov    -0x40018(%rbp),%rdx
lea    0xd78(%rip),%rdi
call   10b0 <printf@plt>
mov    -0x40018(%rbp),%rax
cmpb   $0x0,(%rax)
je     12d3 <request+0x103>
mov    -0x40018(%rbp),%rax
mov    %rax,-0x40028(%rbp)
mov    -0x40018(%rbp),%rdi
call   1090 <strlen@plt>
mov    %eax,%ecx
mov    -0x40028(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1388 <request+0x1b8>
lea    -0x40010(%rbp),%rdi
lea    0xd26(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    12ff <request+0x12f>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <getd@plt>
lea    -0x40010(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    132b <request+0x15b>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <putd@plt>
lea    -0x40010(%rbp),%rdi
lea    0xcd6(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    1357 <request+0x187>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10d0 <postd@plt>
lea    -0x40010(%rbp),%rdi
lea    0xcaf(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    1383 <request+0x1b3>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <deleted@plt>
jmp    143d <request+0x26d>
lea    -0x40010(%rbp),%rdi
lea    0xc71(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    13b4 <request+0x1e4>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <getf@plt>
lea    -0x40010(%rbp),%rdi
lea    0xc49(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    13e0 <request+0x210>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <putf@plt>
lea    -0x40010(%rbp),%rdi
lea    0xc21(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    140c <request+0x23c>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10c0 <postf@plt>
lea    -0x40010(%rbp),%rdi
lea    0xbfa(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    1438 <request+0x268>
mov    -0x40018(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <deletef@plt>
jmp    143d <request+0x26d>
add    $0x40030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<request>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x40008,%rsp
mov    %edi,%r14d
mov    %rsp,%rsi
mov    $0x3ffff,%edx
call   10e0 <read@plt>
lea    0x1(%rax),%rcx
cmp    $0x2,%rcx
jb     1355 <request+0x185>
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   10a0 <strchr@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x2(%rax),%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   10a0 <strchr@plt>
movb   $0x0,(%rax)
lea    0xdd0(%rip),%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   10b0 <printf@plt>
cmpb   $0x0,0x2(%rbx)
je     1257 <request+0x87>
mov    %r15,%rdi
call   1090 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r15,1)
jne    12d9 <request+0x109>
lea    0xda9(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1276 <request+0xa6>
mov    %r15,%rdi
mov    %r14d,%esi
call   1070 <getd@plt>
lea    0xd8e(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1295 <request+0xc5>
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <putd@plt>
lea    0xd73(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    12b4 <request+0xe4>
mov    %r15,%rdi
mov    %r14d,%esi
call   10d0 <postd@plt>
lea    0xd59(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1355 <request+0x185>
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <deleted@plt>
jmp    1355 <request+0x185>
lea    0xd27(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    12f8 <request+0x128>
mov    %r15,%rdi
mov    %r14d,%esi
call   1080 <getf@plt>
lea    0xd0c(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1317 <request+0x147>
mov    %r15,%rdi
mov    %r14d,%esi
call   1050 <putf@plt>
lea    0xcf1(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1336 <request+0x166>
mov    %r15,%rdi
mov    %r14d,%esi
call   10c0 <postf@plt>
lea    0xcd7(%rip),%rsi
mov    %rsp,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1355 <request+0x185>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <deletef@plt>
add    $0x40008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\0A%s %s\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [4 x i8] c"PUT\00"
@.str.3 = [5 x i8] c"POST\00"
@.str.4 = [7 x i8] c"DELETE\00"
define void @request(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca [262144 x i8]
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%9 = call i64 @read(i32 %7, i8* %8, i32 262143)
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %12, %1
br label %109
16: ; preds = %12
%17 = load i64, i64* %3
%18 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%20 = call i8* @strchr(i8* %19, i8 signext 32)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
store i8 0, i8* %21
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8* %23, i8** %5
%24 = load i8*, i8** %5
%25 = call i8* @strchr(i8* %24, i8 signext 32)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
store i8 0, i8* %26
%27 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%28 = load i8*, i8** %5
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %28)
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %16
%34 = load i8*, i8** %5
%35 = load i8*, i8** %5
%36 = call i32 @strlen(i8* %35)
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %34, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 47
br i1 %42, label %43, label %76
43: ; preds = %33, %16
%44 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i8*, i8** %5
%49 = load i32, i32* %2
%50 = call i32 @getd(i8* %48, i32 %49)
br label %51
51: ; preds = %47, %43
%52 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i8*, i8** %5
%57 = load i32, i32* %2
%58 = call i32 @putd(i8* %56, i32 %57)
br label %59
59: ; preds = %55, %51
%60 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i8*, i8** %5
%65 = load i32, i32* %2
%66 = call i32 @postd(i8* %64, i32 %65)
br label %67
67: ; preds = %63, %59
%68 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %67
%72 = load i8*, i8** %5
%73 = load i32, i32* %2
%74 = call i32 @deleted(i8* %72, i32 %73)
br label %75
75: ; preds = %71, %67
br label %109
76: ; preds = %33
%77 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = load i8*, i8** %5
%82 = load i32, i32* %2
%83 = call i32 @getf(i8* %81, i32 %82)
br label %84
84: ; preds = %80, %76
%85 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = load i8*, i8** %5
%90 = load i32, i32* %2
%91 = call i32 @putf(i8* %89, i32 %90)
br label %92
92: ; preds = %88, %84
%93 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %100
96: ; preds = %92
%97 = load i8*, i8** %5
%98 = load i32, i32* %2
%99 = call i32 @postf(i8* %97, i32 %98)
br label %100
100: ; preds = %96, %92
%101 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %100
%105 = load i8*, i8** %5
%106 = load i32, i32* %2
%107 = call i32 @deletef(i8* %105, i32 %106)
br label %108
108: ; preds = %104, %100
br label %109
109: ; preds = %15, %108, %75
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0A%s %s\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [4 x i8] c"PUT\00"
@.str.3 = [5 x i8] c"POST\00"
@.str.4 = [7 x i8] c"DELETE\00"
define void @request(i32 %0) {
%2 = alloca [262144 x i8]
%3 = getelementptr inbounds [262144 x i8], [262144 x i8]* %2, i64 0, i64 0
%4 = call i64 @read(i32 %0, i8* %3, i32 262143)
%5 = add i64 %4, 1
%6 = icmp ult i64 %5, 2
br i1 %6, label %62, label %7
7: ; preds = %1
%8 = getelementptr inbounds [262144 x i8], [262144 x i8]* %2, i64 0, i64 %4
store i8 0, i8* %8
%9 = call i8* @strchr(i8* %3, i8 signext 32)
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = call i8* @strchr(i8* %10, i8 signext 32)
store i8 0, i8* %11
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %10)
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %7
%16 = call i32 @strlen(i8* %10)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %10, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 47
br i1 %21, label %22, label %42
22: ; preds = %15, %7
%23 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @getd(i8* %10, i32 %0)
br label %27
27: ; preds = %25, %22
%28 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @putd(i8* %10, i32 %0)
br label %32
32: ; preds = %30, %27
%33 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @postd(i8* %10, i32 %0)
br label %37
37: ; preds = %35, %32
%38 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %62
40: ; preds = %37
%41 = call i32 @deleted(i8* %10, i32 %0)
br label %62
42: ; preds = %15
%43 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @getf(i8* %10, i32 %0)
br label %47
47: ; preds = %45, %42
%48 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @putf(i8* %10, i32 %0)
br label %52
52: ; preds = %50, %47
%53 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @postf(i8* %10, i32 %0)
br label %57
57: ; preds = %55, %52
%58 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @deletef(i8* %10, i32 %0)
br label %62
62: ; preds = %40, %37, %60, %57, %1
ret void
}