#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*/ GetStringBit(char *, char *, int, int);
scalar_t__ IsEqual(char *, char *);
int strlen(char *);
int GrabGETData(char *src, char *dst) {
  char strBit[100];
  int i, sz, f, n;
  sz = 1;
  n = 0;
  f = 0;
  for (i = 0; i < strlen(src); i++) {
    if (f == 0) {
      GetStringBit(src, strBit, i, 4);
      n = i + 4;
      i += 4;
      if (IsEqual(strBit, "GET "))
        f = 1;
      if (IsEqual(strBit, "POST")) {
        n++;
        i++;
        f = 1;
      }
    } else {
      if (src[i] == ' ') {
        GetStringBit(src, dst, n, sz);
        return 1;
      } else {
        sz++;
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<GrabGETData>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x88(%rbp)
movl   $0x0,-0x90(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jge    12a8 <GrabGETData+0x178>
cmpl   $0x0,-0x8c(%rbp)
jne    123e <GrabGETData+0x10e>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x84(%rbp),%edx
mov    $0x4,%ecx
call   1050 <GetStringBit@plt>
mov    -0x84(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <IsEqual@plt>
cmp    $0x0,%rax
je     11f7 <GrabGETData+0xc7>
movl   $0x1,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1030 <IsEqual@plt>
cmp    $0x0,%rax
je     1239 <GrabGETData+0x109>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    128f <GrabGETData+0x15f>
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    127b <GrabGETData+0x14b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x90(%rbp),%edx
mov    -0x88(%rbp),%ecx
call   1050 <GetStringBit@plt>
movl   $0x1,-0x4(%rbp)
jmp    12af <GrabGETData+0x17f>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    128f <GrabGETData+0x15f>
jmp    1294 <GrabGETData+0x164>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    116b <GrabGETData+0x3b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GrabGETData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0xffffffff,%ecx
test   %eax,%eax
jle    120e <GrabGETData+0xde>
mov    %rbp,0x8(%rsp)
mov    $0x1,%ebp
xor    %r13d,%r13d
lea    0x10(%rsp),%r12
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    11ce <GrabGETData+0x9e>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    $0x4,%ecx
call   1050 <GetStringBit@plt>
mov    %r12,%rdi
lea    0xe73(%rip),%rsi
call   1030 <IsEqual@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r13b
mov    %r12,%rdi
lea    0xe5f(%rip),%rsi
call   1030 <IsEqual@plt>
test   %rax,%rax
je     11e7 <GrabGETData+0xb7>
add    $0x5,%r15d
mov    $0x1,%r14d
mov    %r15d,%r13d
add    $0x1,%r15d
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jge    11f0 <GrabGETData+0xc0>
test   %r14d,%r14d
je     1170 <GrabGETData+0x40>
movslq %r15d,%rax
cmpb   $0x20,(%rbx,%rax,1)
je     11f7 <GrabGETData+0xc7>
add    $0x1,%ebp
mov    $0x1,%r14d
jmp    11bd <GrabGETData+0x8d>
add    $0x4,%r15d
mov    %r13b,%r14b
jmp    11ba <GrabGETData+0x8a>
mov    $0xffffffff,%ecx
jmp    120e <GrabGETData+0xde>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %r13d,%edx
mov    %ebp,%ecx
call   1050 <GetStringBit@plt>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"GET \00"
@.str.1 = [5 x i8] c"POST\00"
define i32 @GrabGETData(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 1, i32* %8
store i32 0, i32* %10
store i32 0, i32* %9
store i32 0, i32* %7
br label %11
11: ; preds = %61, %2
%12 = load i32, i32* %7
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %64
16: ; preds = %11
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = load i32, i32* %7
%23 = call i32 @GetStringBit(i8* %20, i8* %21, i32 %22, i32 4)
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 4
store i32 %25, i32* %10
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 4
store i32 %27, i32* %7
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = call i64 @IsEqual(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %19
store i32 1, i32* %9
br label %32
32: ; preds = %31, %19
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = call i64 @IsEqual(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
store i32 1, i32* %9
br label %41
41: ; preds = %36, %32
br label %60
42: ; preds = %16
%43 = load i8*, i8** %4
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 32
br i1 %49, label %50, label %56
50: ; preds = %42
%51 = load i8*, i8** %4
%52 = load i8*, i8** %5
%53 = load i32, i32* %10
%54 = load i32, i32* %8
%55 = call i32 @GetStringBit(i8* %51, i8* %52, i32 %53, i32 %54)
store i32 1, i32* %3
br label %65
56: ; preds = %42
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %59
59: ; preds = %56
br label %60
60: ; preds = %59, %41
br label %61
61: ; preds = %60
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %11
64: ; preds = %11
store i32 -1, i32* %3
br label %65
65: ; preds = %64, %50
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [5 x i8] c"GET \00"
@.str.1 = [5 x i8] c"POST\00"
define i32 @GrabGETData(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %40
7: ; preds = %2, %32
%8 = phi i32 [ %36, %32 ], [ 0, %2 ]
%9 = phi i32 [ %35, %32 ], [ 0, %2 ]
%10 = phi i32 [ %34, %32 ], [ 1, %2 ]
%11 = phi i32 [ %37, %32 ], [ 0, %2 ]
%12 = icmp eq i32 %9, 0
br i1 %12, label %13, label %23
13: ; preds = %7
%14 = call i32 @GetStringBit(i8* %0, i8* %4, i32 %11, i32 4)
%15 = add nsw i32 %11, 4
%16 = call i64 @IsEqual(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i64 @IsEqual(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %32, label %21
21: ; preds = %13
%22 = add nsw i32 %11, 5
br label %32
23: ; preds = %7
%24 = sext i32 %11 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 32
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @GetStringBit(i8* %0, i8* %1, i32 %8, i32 %10)
br label %40
30: ; preds = %23
%31 = add nsw i32 %10, 1
br label %32
32: ; preds = %30, %21, %13
%33 = phi i32 [ %22, %21 ], [ %15, %13 ], [ %11, %30 ]
%34 = phi i32 [ %10, %21 ], [ %10, %13 ], [ %31, %30 ]
%35 = phi i32 [ 1, %21 ], [ %18, %13 ], [ 1, %30 ]
%36 = phi i32 [ %22, %21 ], [ %15, %13 ], [ %8, %30 ]
%37 = add nsw i32 %33, 1
%38 = call i32 @strlen(i8* %0)
%39 = icmp slt i32 %37, %38
br i1 %39, label %7, label %40
40: ; preds = %32, %2, %28
%41 = phi i32 [ 1, %28 ], [ -1, %2 ], [ -1, %32 ]
ret i32 %41
}