#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*/ debug();
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int Parsefile(char *req, char *file) {
  debug();
  printf("req= %s\n\n\n\n", req);
  char *gethost = strstr(req, "/");
  if (gethost != NULL) {
    debug();
    printf("gethost=%s\n\n\n\n", gethost);
    int i = 0;
    int len = strlen(gethost);
    for (i = 0; i < len; i++) {
      if (gethost[i] == ' ')
        break;
    }
    memcpy(file, gethost, i + 1);
    return 1;
  } else
    return -1;
}


x86 assembly (clang, -O0):
<Parsefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1040 <debug@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     121f <Parsefile+0xcf>
mov    $0x0,%al
call   1040 <debug@plt>
mov    -0x20(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1200 <Parsefile+0xb0>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11ed <Parsefile+0x9d>
jmp    1200 <Parsefile+0xb0>
jmp    11f2 <Parsefile+0xa2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c7 <Parsefile+0x77>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
call   1060 <memcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1226 <Parsefile+0xd6>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Parsefile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <debug@plt>
lea    0xe95(%rip),%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d9 <Parsefile+0x89>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <debug@plt>
lea    0xe76(%rip),%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11c2 <Parsefile+0x72>
mov    %eax,%eax
xor    %ebx,%ebx
xchg   %ax,%ax
cmpb   $0x20,(%r15,%rbx,1)
je     11c2 <Parsefile+0x72>
add    $0x1,%rbx
cmp    %rbx,%rax
jne    11b0 <Parsefile+0x60>
mov    %eax,%ebx
add    $0x1,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1070 <memcpy@plt>
mov    $0x1,%eax
jmp    11de <Parsefile+0x8e>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"req= %s\0A\0A\0A\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [15 x i8] c"gethost=%s\0A\0A\0A\0A\00"
define i32 @Parsefile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = call i32 (...) @debug()
%10 = load i8*, i8** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %45
16: ; preds = %2
%17 = call i32 (...) @debug()
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 0, i32* %7
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %8
store i32 0, i32* %7
br label %22
22: ; preds = %36, %16
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %35
34: ; preds = %26
br label %39
35: ; preds = %26
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %22
39: ; preds = %34, %22
%40 = load i8*, i8** %5
%41 = load i8*, i8** %6
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
%44 = call i32 @memcpy(i8* %40, i8* %41, i32 %43)
store i32 1, i32* %3
br label %46
45: ; preds = %2
store i32 -1, i32* %3
br label %46
46: ; preds = %45, %39
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [12 x i8] c"req= %s\0A\0A\0A\0A\00"
@.str.2 = [15 x i8] c"gethost=%s\0A\0A\0A\0A\00"
define i32 @Parsefile(i8* %0, i8* %1) {
%3 = tail call i32 (...) @debug()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 47)
%6 = icmp eq i8* %5, null
br i1 %6, label %28, label %7
7: ; preds = %2
%8 = tail call i32 (...) @debug()
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = tail call i32 @strlen(i8* %5)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = zext i32 %10 to i64
br label %14
14: ; preds = %12, %19
%15 = phi i64 [ 0, %12 ], [ %20, %19 ]
%16 = getelementptr inbounds i8, i8* %5, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %24, label %14
22: ; preds = %14
%23 = trunc i64 %15 to i32
br label %24
24: ; preds = %19, %22, %7
%25 = phi i32 [ 0, %7 ], [ %23, %22 ], [ %10, %19 ]
%26 = add nuw nsw i32 %25, 1
%27 = tail call i32 @memcpy(i8* %1, i8* %5, i32 %26)
br label %28
28: ; preds = %2, %24
%29 = phi i32 [ 1, %24 ], [ -1, %2 ]
ret i32 %29
}