#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 getFistIndex(char *, char *);
char *getSubString(char *, scalar_t__, scalar_t__);
scalar_t__ strlen(char *);
char *GetPathByRequest(char *HTTP_Request) {
  int start, stop;
  start = getFistIndex(HTTP_Request, "GET ");
  stop = getFistIndex(HTTP_Request, " HTTP");
  if (start >= 0 && stop >= 0)
    return getSubString(HTTP_Request, start + strlen("GET "),
                        stop - start - strlen("GET "));
  return NULL;
}


x86 assembly (clang, -O0):
<GetPathByRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <getFistIndex@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <getFistIndex@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11d5 <GetPathByRequest+0xa5>
cmpl   $0x0,-0x18(%rbp)
jl     11d5 <GetPathByRequest+0xa5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe73(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    %rax,-0x30(%rbp)
lea    0xe4d(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    %rax,%rdx
call   1040 <getSubString@plt>
mov    %rax,-0x8(%rbp)
jmp    11dd <GetPathByRequest+0xad>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetPathByRequest>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rsi
call   1040 <getFistIndex@plt>
mov    %eax,%ebp
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1040 <getFistIndex@plt>
test   %ebp,%ebp
js     1168 <GetPathByRequest+0x48>
test   %eax,%eax
js     1168 <GetPathByRequest+0x48>
mov    %ebp,%esi
add    $0x4,%rsi
sub    %ebp,%eax
movslq %eax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <getSubString@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"GET \00"
@.str.1 = [6 x i8] c" HTTP\00"
define i8* @GetPathByRequest(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @getFistIndex(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @getFistIndex(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %1
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = add nsw i64 %18, %19
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = sub nsw i64 %24, %25
%27 = call i8* @getSubString(i8* %16, i64 %20, i64 %26)
store i8* %27, i8** %2
br label %29
28: ; preds = %12, %1
store i8* null, i8** %2
br label %29
29: ; preds = %28, %15
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [5 x i8] c"GET \00"
@.str.1 = [6 x i8] c" HTTP\00"
define i8* @GetPathByRequest(i8* %0) {
%2 = tail call i32 @getFistIndex(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @getFistIndex(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp sgt i32 %2, -1
%5 = icmp sgt i32 %3, -1
%6 = select i1 %4, i1 %5, i1 false
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = zext i32 %2 to i64
%9 = add nuw nsw i64 %8, 4
%10 = sub nsw i32 %3, %2
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, -4
%13 = tail call i8* @getSubString(i8* %0, i64 %9, i64 %12)
br label %14
14: ; preds = %1, %7
%15 = phi i8* [ %13, %7 ], [ null, %1 ]
ret i8* %15
}