#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 */
char *FP_strdup(int /*<<< orphan*/ *);
int /*<<< orphan*/ HandleString(char *);
char *LoadInput();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *getenv(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char *ptr, *data = LoadInput();
  int i;
  if (data) {
    ptr = strtok(data, "&");
    while (ptr) {
      HandleString(ptr);
      ptr = strtok(NULL, "&");
    }
    free(data);
  }
  if (getenv("PATH_INFO") != NULL) {
    data = FP_strdup(getenv("PATH_INFO"));
    ptr = strtok(data, "/");
    while (ptr) {
      HandleString(ptr);
      ptr = strtok(NULL, "/");
    }
    free(data);
  }
  for (i = 1; i < argc; i++) {
    HandleString(argv[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <LoadInput@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d6 <main+0x76>
mov    -0x20(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cd <main+0x6d>
mov    -0x18(%rbp),%rdi
call   1060 <HandleString@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe41(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11a0 <main+0x40>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
lea    0xe25(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     124e <main+0xee>
lea    0xe0f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1070 <FP_strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1245 <main+0xe5>
mov    -0x18(%rbp),%rdi
call   1060 <HandleString@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd5(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1218 <main+0xb8>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1280 <main+0x120>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <HandleString@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1255 <main+0xf5>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %edi,%r14d
xor    %eax,%eax
call   1050 <LoadInput@plt>
test   %rax,%rax
je     11bf <main+0x5f>
mov    %rax,%r15
lea    0xe7c(%rip),%rsi
mov    %rax,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     11b7 <main+0x57>
lea    0xe68(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1060 <HandleString@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    11a0 <main+0x40>
mov    %r15,%rdi
call   1040 <free@plt>
lea    0xe3c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     121f <main+0xbf>
mov    %rax,%rdi
call   1070 <FP_strdup@plt>
mov    %rax,%r15
lea    0xe2a(%rip),%rsi
mov    %rax,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     1217 <main+0xb7>
lea    0xe16(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1060 <HandleString@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    1200 <main+0xa0>
mov    %r15,%rdi
call   1040 <free@plt>
cmp    $0x2,%r14d
jl     1242 <main+0xe2>
mov    %r14d,%ebp
mov    $0x1,%ebx
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
call   1060 <HandleString@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1230 <main+0xd0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"&\00"
@.str.1 = [10 x i8] c"PATH_INFO\00"
@.str.2 = [2 x i8] c"/\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* (...) @LoadInput()
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %25
12: ; preds = %2
%13 = load i8*, i8** %7
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %6
br label %15
15: ; preds = %18, %12
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = call i32 @HandleString(i8* %19)
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %6
br label %15
22: ; preds = %15
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %22, %2
%26 = call i32* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %43
28: ; preds = %25
%29 = call i32* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%30 = call i8* @FP_strdup(i32* %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = call i8* @strtok(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %32, i8** %6
br label %33
33: ; preds = %36, %28
%34 = load i8*, i8** %6
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i8*, i8** %6
%38 = call i32 @HandleString(i8* %37)
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %39, i8** %6
br label %33
40: ; preds = %33
%41 = load i8*, i8** %7
%42 = call i32 @free(i8* %41)
br label %43
43: ; preds = %40, %25
store i32 1, i32* %8
br label %44
44: ; preds = %55, %43
%45 = load i32, i32* %8
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i8**, i8*** %5
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 @HandleString(i8* %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %44
58: ; preds = %44
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"&\00"
@.str.1 = [10 x i8] c"PATH_INFO\00"
@.str.2 = [2 x i8] c"/\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i8* (...) @LoadInput()
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i8* [ %11, %8 ], [ %6, %5 ]
%10 = tail call i32 @HandleString(i8* %9)
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %5
%14 = tail call i32 @free(i8* %3)
br label %15
15: ; preds = %13, %2
%16 = tail call i32* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %29, label %18
18: ; preds = %15
%19 = tail call i8* @FP_strdup(i32* %16)
%20 = tail call i8* @strtok(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %27, label %22
22: ; preds = %18, %22
%23 = phi i8* [ %25, %22 ], [ %20, %18 ]
%24 = tail call i32 @HandleString(i8* %23)
%25 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %22
27: ; preds = %22, %18
%28 = tail call i32 @free(i8* %19)
br label %29
29: ; preds = %27, %15
%30 = icmp sgt i32 %0, 1
br i1 %30, label %31, label %40
31: ; preds = %29
%32 = zext i32 %0 to i64
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ 1, %31 ], [ %38, %33 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = tail call i32 @HandleString(i8* %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %32
br i1 %39, label %40, label %33
40: ; preds = %33, %29
ret i32 0
}