#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*/ memset(char ***, char, int);
int get_request_path(char request[65536], char *filepath) {
  char *toreturn[1024];
  memset(&toreturn, ' ', 1024);
  int index;
  for (index = 0; index < 1024; index++) {
    if (request[index + 5] == ' ') {
      return index;
    } else
      *(filepath + index) = request[index + 5];
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_request_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x2020(%rbp),%rdi
mov    $0x20,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
movl   $0x0,-0x2024(%rbp)
cmpl   $0x400,-0x2024(%rbp)
jge    11b8 <get_request_path+0xa8>
mov    -0x10(%rbp),%rax
mov    -0x2024(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    117e <get_request_path+0x6e>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <get_request_path+0xaf>
mov    -0x10(%rbp),%rax
mov    -0x2024(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x2024(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11a4 <get_request_path+0x94>
mov    -0x2024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2024(%rbp)
jmp    1143 <get_request_path+0x33>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_request_path>:
push   %r14
push   %rbx
sub    $0x2008,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x20,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x5(%rbx,%rax,1),%ecx
cmp    $0x20,%cl
je     1174 <get_request_path+0x64>
mov    %cl,(%r14,%rax,1)
movzbl 0x6(%rbx,%rax,1),%ecx
cmp    $0x20,%cl
je     1170 <get_request_path+0x60>
mov    %cl,0x1(%r14,%rax,1)
add    $0x2,%rax
cmp    $0x400,%rax
jne    1140 <get_request_path+0x30>
mov    $0xffffffff,%eax
jmp    1174 <get_request_path+0x64>
add    $0x1,%rax
add    $0x2008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @get_request_path(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8*]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = bitcast [1024 x i8*]* %6 to i8***
%9 = call i32 @memset(i8*** %8, i8 signext 32, i32 1024)
store i32 0, i32* %7
br label %10
10: ; preds = %36, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 1024
br i1 %12, label %13, label %39
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = load i32, i32* %7
store i32 %23, i32* %3
br label %40
24: ; preds = %13
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %10
39: ; preds = %10
store i32 -1, i32* %3
br label %40
40: ; preds = %39, %22
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @get_request_path(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [1024 x i8*]
%4 = bitcast [1024 x i8*]* %3 to i8*
%5 = bitcast [1024 x i8*]* %3 to i8***
%6 = call i32 @memset(i8*** %5, i8 signext 32, i32 1024)
br label %7
7: ; preds = %20, %2
%8 = phi i64 [ 0, %2 ], [ %22, %20 ]
%9 = add nuw nsw i64 %8, 5
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %24, label %13
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 %11, i8* %14
%15 = or i64 %8, 1
%16 = add nuw nsw i64 %8, 6
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = getelementptr inbounds i8, i8* %1, i64 %15
store i8 %18, i8* %21
%22 = add nuw nsw i64 %8, 2
%23 = icmp eq i64 %22, 1024
br i1 %23, label %27, label %7
24: ; preds = %13, %7
%25 = phi i64 [ %8, %7 ], [ %15, %13 ]
%26 = trunc i64 %25 to i32
br label %27
27: ; preds = %20, %24
%28 = phi i32 [ %26, %24 ], [ -1, %20 ]
ret i32 %28
}