#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 */
scalar_t__ read(int /*<<< orphan*/, char *, int);
char **afl_init_argv(int *argc) {
  static char in_buf[100000];
  static char *ret[1000];
  char *ptr = in_buf;
  int rc = 0;
  if (read(0, in_buf, 100000 - 2) < 0)
    ;
  while (*ptr) {
    ret[rc] = ptr;
    if (ret[rc][0] == 0x02 && !ret[rc][1])
      ret[rc]++;
    rc++;
    while (*ptr)
      ptr++;
    ptr++;
  }
  *argc = rc;
  return ret;
}


x86 assembly (clang, -O0):
<afl_init_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %edi,%edi
lea    0x2f09(%rip),%rsi
mov    $0x1869e,%edx
call   1030 <read@plt>
cmp    $0x0,%rax
jge    1150 <afl_init_argv+0x40>
jmp    1150 <afl_init_argv+0x40>
jmp    1155 <afl_init_argv+0x45>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ff <afl_init_argv+0xef>
mov    -0x10(%rbp),%rdx
movslq -0x14(%rbp),%rcx
lea    0x1b56f(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movslq -0x14(%rbp),%rcx
lea    0x1b560(%rip),%rax
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2,%eax
jne    11c7 <afl_init_argv+0xb7>
movslq -0x14(%rbp),%rcx
lea    0x1b545(%rip),%rax
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,0x1(%rax)
jne    11c7 <afl_init_argv+0xb7>
movslq -0x14(%rbp),%rcx
lea    0x1b52c(%rip),%rax
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
lea    0x1b51d(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ee <afl_init_argv+0xde>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11d0 <afl_init_argv+0xc0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1155 <afl_init_argv+0x45>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
lea    0x1b4d1(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<afl_init_argv>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0x2f21(%rip),%rbx
xor    %r15d,%r15d
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1869e,%edx
call   1030 <read@plt>
cmpb   $0x0,0x2f08(%rip)
je     1182 <afl_init_argv+0x72>
xor    %r15d,%r15d
lea    0x1b59c(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,(%rax,%r15,8)
cmpb   $0x2,(%rbx)
jne    1170 <afl_init_argv+0x60>
cmpb   $0x0,0x1(%rbx)
jne    1170 <afl_init_argv+0x60>
lea    0x1(%rbx),%rcx
mov    %rcx,(%rax,%r15,8)
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <afl_init_argv+0x60>
add    $0x1,%r15
cmpb   $0x0,(%rbx)
jne    1150 <afl_init_argv+0x40>
mov    %r15d,(%r14)
lea    0x1b554(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@afl_init_argv.in_buf = internal global [100000 x i8] zeroinitializer
@afl_init_argv.ret = internal global [1000 x i8*] zeroinitializer
define i8** @afl_init_argv(i32* nocapture writeonly %0) {
%2 = tail call i64 @read(i32 0, i8* getelementptr inbounds ([100000 x i8], [100000 x i8]* @afl_init_argv.in_buf, i64 0, i64 0), i32 99998)
%3 = load i8, i8* getelementptr inbounds ([100000 x i8], [100000 x i8]* @afl_init_argv.in_buf, i64 0, i64 0)
%4 = icmp eq i8 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %1, %22
%6 = phi i64 [ %23, %22 ], [ 0, %1 ]
%7 = phi i8* [ %21, %22 ], [ getelementptr inbounds ([100000 x i8], [100000 x i8]* @afl_init_argv.in_buf, i64 0, i64 0), %1 ]
%8 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* @afl_init_argv.ret, i64 0, i64 %6
store i8* %7, i8** %8
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* %12, i8** %8
br label %16
16: ; preds = %15, %11, %5
br label %17
17: ; preds = %16, %17
%18 = phi i8* [ %21, %17 ], [ %7, %16 ]
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
%21 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %20, label %22, label %17
22: ; preds = %17
%23 = add nuw i64 %6, 1
%24 = load i8, i8* %21
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %5
26: ; preds = %22
%27 = trunc i64 %23 to i32
br label %28
28: ; preds = %26, %1
%29 = phi i32 [ 0, %1 ], [ %27, %26 ]
store i32 %29, i32* %0
ret i8** getelementptr inbounds ([1000 x i8*], [1000 x i8*]* @afl_init_argv.ret, i64 0, i64 0)
}