#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 strlen(char *);
int GrabPageURL(char *getData, char *ret) {
  int i;
  ret[0] = 0x00;
  for (i = 0; i < strlen(getData); i++) {
    if (getData[i] == '?')
      return 0;
    if (getData[i] == '&')
      return 0;
    if (getData[i] == ' ')
      return 0;
    ret[i] = getData[i];
    ret[i + 1] = 0x00;
  }
  return 0;
}


x86 assembly (clang, -O0):
<GrabPageURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11e2 <GrabPageURL+0xd2>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    116b <GrabPageURL+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <GrabPageURL+0xd9>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x26,%eax
jne    118c <GrabPageURL+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <GrabPageURL+0xd9>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11ad <GrabPageURL+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <GrabPageURL+0xd9>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <GrabPageURL+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GrabPageURL>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,(%rsi)
call   1030 <strlen@plt>
test   %eax,%eax
jle    116e <GrabPageURL+0x5e>
xor    %ebx,%ebx
movabs $0x8000004100000000,%r12
jmp    115d <GrabPageURL+0x4d>
nopl   0x0(%rax,%rax,1)
mov    %al,(%r14,%rbx,1)
movb   $0x0,0x1(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    116e <GrabPageURL+0x5e>
movzbl (%r15,%rbx,1),%eax
cmp    $0x3f,%rax
ja     1140 <GrabPageURL+0x30>
bt     %rax,%r12
jae    1140 <GrabPageURL+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @GrabPageURL(i8* %0, i8* nocapture writeonly %1) {
store i8 0, i8* %1
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %2, %9
%6 = phi i64 [ %11, %9 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 63, label %16
i8 38, label %16
i8 32, label %16
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 %8, i8* %10
%11 = add nuw nsw i64 %6, 1
%12 = getelementptr inbounds i8, i8* %1, i64 %11
store i8 0, i8* %12
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %11, %14
br i1 %15, label %5, label %16
16: ; preds = %5, %5, %5, %9, %2
ret i32 0
}