#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 */
int /*<<< orphan*/ error(int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ *strstr(char *, char *);
char *strtok(char *, char *);
bool parse_request_target(char *request_target, char *abs_path, char *query) {
  bool result = false;
  if (strncmp(request_target, "/", 1) == 0) {
    if (strstr(request_target, "\"") == NULL) {
      char *abs_path_token = strtok(request_target, "?");
      if (abs_path_token) {
        char *query_token = strtok(NULL, "");
        if (query_token) {
          strcpy(query, query_token);
        }
      } else {
        abs_path_token = request_target;
      }
      strcpy(abs_path, abs_path_token);
      result = true;
    } else {
      error(400);
    }
  } else {
    error(501);
  }
  return result;
}


x86 assembly (clang, -O0):
<parse_request_target>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1224 <parse_request_target+0xd4>
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    1215 <parse_request_target+0xc5>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f4 <parse_request_target+0xa4>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe35(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11ef <parse_request_target+0x9f>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11fc <parse_request_target+0xac>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x1c(%rbp)
jmp    121f <parse_request_target+0xcf>
mov    $0x190,%edi
call   1050 <error@plt>
jmp    122e <parse_request_target+0xde>
mov    $0x1f5,%edi
call   1050 <error@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_request_target>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe98(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     117e <parse_request_target+0x2e>
mov    $0x1f5,%edi
jmp    1195 <parse_request_target+0x45>
mov    %rbx,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11a8 <parse_request_target+0x58>
mov    $0x190,%edi
call   1060 <error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11e0 <parse_request_target+0x90>
mov    %rax,%r12
lea    0xe3b(%rip),%rsi
xor    %edi,%edi
call   1070 <strtok@plt>
test   %rax,%rax
je     11dd <parse_request_target+0x8d>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x1,%eax
jmp    119c <parse_request_target+0x4c>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c"\22\00"
@.str.2 = [2 x i8] c"?\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @parse_request_target(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i32* @strstr(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %37
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %31
22: ; preds = %17
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = load i8*, i8** %9
%29 = call i32 @strcpy(i8* %27, i8* %28)
br label %30
30: ; preds = %26, %22
br label %33
31: ; preds = %17
%32 = load i8*, i8** %4
store i8* %32, i8** %8
br label %33
33: ; preds = %31, %30
%34 = load i8*, i8** %5
%35 = load i8*, i8** %8
%36 = call i32 @strcpy(i8* %34, i8* %35)
store i32 1, i32* %7
br label %39
37: ; preds = %13
%38 = call i32 @error(i32 400)
br label %39
39: ; preds = %37, %33
br label %42
40: ; preds = %3
%41 = call i32 @error(i32 501)
br label %42
42: ; preds = %40, %39
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.2 = [2 x i8] c"?\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @parse_request_target(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 34)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @strcpy(i8* %2, i8* %13)
br label %17
17: ; preds = %9, %12, %15
%18 = phi i8* [ %10, %15 ], [ %10, %12 ], [ %0, %9 ]
%19 = tail call i32 @strcpy(i8* %1, i8* %18)
br label %24
20: ; preds = %6
%21 = tail call i32 @error(i32 400)
br label %24
22: ; preds = %3
%23 = tail call i32 @error(i32 501)
br label %24
24: ; preds = %17, %20, %22
%25 = phi i32 [ 1, %17 ], [ 0, %20 ], [ 0, %22 ]
ret i32 %25
}