#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 */
typedef int /*<<< orphan*/ _constant_string;

/* Variables and functions */
int /*<<< orphan*/ nolibc_exit(int);
int /*<<< orphan*/ write_all(int, char *, int);
int /*<<< orphan*/ write_string(int, char const *const);
int /*<<< orphan*/ write_ulong(int, unsigned long);
void _c_start(const void *stack) {
  const unsigned long argc = *(const unsigned long *)stack;
  const char *const *argv = ((const char *const *)stack) + 1;
  const char *const *envp = argv + argc + 1;
  unsigned long i;
  for (i = 0; i < argc; i++) {
    if (!argv[i]) {
      do {
        char _constant_string[] = "Error: NULL argv before end of array\n";
        write_all((2), _constant_string, sizeof(_constant_string) - 1);
      } while (0);
      nolibc_exit(1);
    }
    do {
      char _constant_string[] = "argv[";
      write_all((1), _constant_string, sizeof(_constant_string) - 1);
    } while (0);
    write_ulong(1, i);
    do {
      char _constant_string[] = "] = ";
      write_all((1), _constant_string, sizeof(_constant_string) - 1);
    } while (0);
    write_string(1, argv[i]);
    do {
      char _single_char = ('\n');
      write_all((1), &_single_char, 1);
    } while (0);
  }
  for (i = 0; envp[i]; i++) {
    do {
      char _constant_string[] = "envp[";
      write_all((1), _constant_string, sizeof(_constant_string) - 1);
    } while (0);
    write_ulong(1, i);
    do {
      char _constant_string[] = "] = ";
      write_all((1), _constant_string, sizeof(_constant_string) - 1);
    } while (0);
    write_string(1, envp[i]);
    do {
      char _single_char = ('\n');
      write_all((1), &_single_char, 1);
    } while (0);
  }
  nolibc_exit(0);
}


x86 assembly (clang, -O0):
<_c_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1289 <_c_start+0x139>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11ea <_c_start+0x9a>
jmp    11b8 <_c_start+0x68>
lea    -0x50(%rbp),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x26,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rsi
mov    $0x2,%edi
mov    $0x25,%edx
call   1060 <write_all@plt>
mov    $0x1,%edi
call   1070 <nolibc_exit@plt>
jmp    11ef <_c_start+0x9f>
mov    0xe31(%rip),%eax
mov    %eax,-0x56(%rbp)
mov    0xe2b(%rip),%ax
mov    %ax,-0x52(%rbp)
lea    -0x56(%rbp),%rsi
mov    $0x1,%edi
mov    $0x5,%edx
call   1060 <write_all@plt>
mov    -0x28(%rbp),%rsi
mov    $0x1,%edi
call   1030 <write_ulong@plt>
mov    0xe02(%rip),%eax
mov    %eax,-0x5b(%rbp)
mov    0xdfd(%rip),%al
mov    %al,-0x57(%rbp)
lea    -0x5b(%rbp),%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1060 <write_all@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x1,%edi
call   1040 <write_string@plt>
movb   $0xa,-0x5c(%rbp)
mov    $0x1,%edx
lea    -0x5c(%rbp),%rsi
mov    %edx,%edi
call   1060 <write_all@plt>
jmp    1278 <_c_start+0x128>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1192 <_c_start+0x42>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1343 <_c_start+0x1f3>
jmp    12a9 <_c_start+0x159>
mov    0xd82(%rip),%eax
mov    %eax,-0x62(%rbp)
mov    0xd7c(%rip),%ax
mov    %ax,-0x5e(%rbp)
lea    -0x62(%rbp),%rsi
mov    $0x1,%edi
mov    $0x5,%edx
call   1060 <write_all@plt>
mov    -0x28(%rbp),%rsi
mov    $0x1,%edi
call   1030 <write_ulong@plt>
mov    0xd48(%rip),%eax
mov    %eax,-0x67(%rbp)
mov    0xd43(%rip),%al
mov    %al,-0x63(%rbp)
lea    -0x67(%rbp),%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1060 <write_all@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x1,%edi
call   1040 <write_string@plt>
movb   $0xa,-0x68(%rbp)
mov    $0x1,%edx
lea    -0x68(%rbp),%rsi
mov    %edx,%edi
call   1060 <write_all@plt>
jmp    1332 <_c_start+0x1e2>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1291 <_c_start+0x141>
xor    %edi,%edi
call   1070 <nolibc_exit@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_c_start>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
mov    (%rdi),%r12
test   %r12,%r12
je     1232 <_c_start+0xf2>
xor    %ebx,%ebx
movabs $0xa796172726120,%r13
mov    %rsp,%r15
jmp    11e9 <_c_start+0xa9>
movw   $0x5b,0x4(%rsp)
movl   $0x76677261,(%rsp)
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1050 <write_all@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <write_ulong@plt>
movb   $0x0,0x4(%rsp)
movl   $0x203d205d,(%rsp)
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <write_all@plt>
mov    0x8(%r14,%rbx,8),%rsi
mov    $0x1,%edi
call   1040 <write_string@plt>
movb   $0xa,(%rsp)
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <write_all@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1232 <_c_start+0xf2>
cmpq   $0x0,0x8(%r14,%rbx,8)
jne    1170 <_c_start+0x30>
movaps 0xe14(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdf8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %r13,0x1e(%rsp)
mov    $0x2,%edi
mov    %r15,%rsi
mov    $0x25,%edx
call   1050 <write_all@plt>
mov    $0x1,%edi
call   1060 <nolibc_exit@plt>
jmp    1170 <_c_start+0x30>
cmpq   $0x0,0x10(%r14,%r12,8)
je     12cb <_c_start+0x18b>
lea    (%r14,%r12,8),%r15
add    $0x18,%r15
xor    %ebx,%ebx
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
movw   $0x5b,0x4(%rsp)
movl   $0x70766e65,(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <write_all@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <write_ulong@plt>
movb   $0x0,0x4(%rsp)
movl   $0x203d205d,(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <write_all@plt>
mov    -0x8(%r15,%rbx,8),%rsi
mov    $0x1,%edi
call   1040 <write_string@plt>
movb   $0xa,(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <write_all@plt>
cmpq   $0x0,(%r15,%rbx,8)
lea    0x1(%rbx),%rbx
jne    1250 <_c_start+0x110>
xor    %edi,%edi
call   1060 <nolibc_exit@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const._c_start._constant_string = [38 x i8] c"Error: NULL argv before end of array\0A\00"
@__const._c_start._constant_string.1 = [6 x i8] c"argv[\00"
@__const._c_start._constant_string.2 = [5 x i8] c"] = \00"
@__const._c_start._constant_string.3 = [6 x i8] c"envp[\00"
@__const._c_start._constant_string.4 = [5 x i8] c"] = \00"
define void @_c_start(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [38 x i8]
%8 = alloca [6 x i8]
%9 = alloca [5 x i8]
%10 = alloca i8
%11 = alloca [6 x i8]
%12 = alloca [5 x i8]
%13 = alloca i8
store i8* %0, i8** %2
%14 = load i8*, i8** %2
%15 = bitcast i8* %14 to i64*
%16 = load i64, i64* %15
store i64 %16, i64* %3
%17 = load i8*, i8** %2
%18 = bitcast i8* %17 to i8**
%19 = getelementptr inbounds i8*, i8** %18, i64 1
store i8** %19, i8*** %4
%20 = load i8**, i8*** %4
%21 = load i64, i64* %3
%22 = getelementptr inbounds i8*, i8** %20, i64 %21
%23 = getelementptr inbounds i8*, i8** %22, i64 1
store i8** %23, i8*** %5
store i64 0, i64* %6
br label %24
24: ; preds = %62, %1
%25 = load i64, i64* %6
%26 = load i64, i64* %3
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %65
28: ; preds = %24
%29 = load i8**, i8*** %4
%30 = load i64, i64* %6
%31 = getelementptr inbounds i8*, i8** %29, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %41, label %34
34: ; preds = %28
br label %35
35: ; preds = %34
%36 = bitcast [38 x i8]* %7 to i8*
%37 = getelementptr inbounds [38 x i8], [38 x i8]* %7, i64 0, i64 0
%38 = call i32 @write_all(i32 2, i8* %37, i32 37)
br label %39
39: ; preds = %35
%40 = call i32 @nolibc_exit(i32 1)
br label %41
41: ; preds = %39, %28
br label %42
42: ; preds = %41
%43 = bitcast [6 x i8]* %8 to i8*
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%45 = call i32 @write_all(i32 1, i8* %44, i32 5)
br label %46
46: ; preds = %42
%47 = load i64, i64* %6
%48 = call i32 @write_ulong(i32 1, i64 %47)
br label %49
49: ; preds = %46
%50 = bitcast [5 x i8]* %9 to i8*
%51 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%52 = call i32 @write_all(i32 1, i8* %51, i32 4)
br label %53
53: ; preds = %49
%54 = load i8**, i8*** %4
%55 = load i64, i64* %6
%56 = getelementptr inbounds i8*, i8** %54, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @write_string(i32 1, i8* %57)
br label %59
59: ; preds = %53
store i8 10, i8* %10
%60 = call i32 @write_all(i32 1, i8* %10, i32 1)
br label %61
61: ; preds = %59
br label %62
62: ; preds = %61
%63 = load i64, i64* %6
%64 = add i64 %63, 1
store i64 %64, i64* %6
br label %24
65: ; preds = %24
store i64 0, i64* %6
br label %66
66: ; preds = %93, %65
%67 = load i8**, i8*** %5
%68 = load i64, i64* %6
%69 = getelementptr inbounds i8*, i8** %67, i64 %68
%70 = load i8*, i8** %69
%71 = icmp ne i8* %70, null
br i1 %71, label %72, label %96
72: ; preds = %66
br label %73
73: ; preds = %72
%74 = bitcast [6 x i8]* %11 to i8*
%75 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
%76 = call i32 @write_all(i32 1, i8* %75, i32 5)
br label %77
77: ; preds = %73
%78 = load i64, i64* %6
%79 = call i32 @write_ulong(i32 1, i64 %78)
br label %80
80: ; preds = %77
%81 = bitcast [5 x i8]* %12 to i8*
%82 = getelementptr inbounds [5 x i8], [5 x i8]* %12, i64 0, i64 0
%83 = call i32 @write_all(i32 1, i8* %82, i32 4)
br label %84
84: ; preds = %80
%85 = load i8**, i8*** %5
%86 = load i64, i64* %6
%87 = getelementptr inbounds i8*, i8** %85, i64 %86
%88 = load i8*, i8** %87
%89 = call i32 @write_string(i32 1, i8* %88)
br label %90
90: ; preds = %84
store i8 10, i8* %13
%91 = call i32 @write_all(i32 1, i8* %13, i32 1)
br label %92
92: ; preds = %90
br label %93
93: ; preds = %92
%94 = load i64, i64* %6
%95 = add i64 %94, 1
store i64 %95, i64* %6
br label %66
96: ; preds = %66
%97 = call i32 @nolibc_exit(i32 0)
ret void
}

LLVM IR (-O2):
@__const._c_start._constant_string = [38 x i8] c"Error: NULL argv before end of array\0A\00"
@__const._c_start._constant_string.1 = [6 x i8] c"argv[\00"
@__const._c_start._constant_string.3 = [6 x i8] c"envp[\00"
@__const._c_start._constant_string.4 = [5 x i8] c"] = \00"
define void @_c_start(i8* nocapture %0) {
%2 = alloca [38 x i8]
%3 = alloca [6 x i8]
%4 = alloca [5 x i8]
%5 = alloca i8
%6 = alloca [6 x i8]
%7 = alloca [5 x i8]
%8 = alloca i8
%9 = bitcast i8* %0 to i64*
%10 = load i64, i64* %9
%11 = getelementptr inbounds i8, i8* %0, i64 8
%12 = bitcast i8* %11 to i8**
%13 = getelementptr inbounds i8*, i8** %12, i64 %10
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = icmp eq i64 %10, 0
br i1 %15, label %20, label %16
16: ; preds = %1
%17 = getelementptr inbounds [38 x i8], [38 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
br label %26
20: ; preds = %34, %1
%21 = load i8*, i8** %14
%22 = icmp eq i8* %21, null
br i1 %22, label %56, label %23
23: ; preds = %20
%24 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
br label %43
26: ; preds = %16, %34
%27 = phi i64 [ 0, %16 ], [ %41, %34 ]
%28 = getelementptr inbounds i8*, i8** %12, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 @write_all(i32 2, i8* %17, i32 37)
%33 = call i32 @nolibc_exit(i32 1)
br label %34
34: ; preds = %26, %31
%35 = call i32 @write_all(i32 1, i8* %18, i32 5)
%36 = call i32 @write_ulong(i32 1, i64 %27)
%37 = call i32 @write_all(i32 1, i8* %19, i32 4)
%38 = load i8*, i8** %28
%39 = call i32 @write_string(i32 1, i8* %38)
store i8 10, i8* %5
%40 = call i32 @write_all(i32 1, i8* %5, i32 1)
%41 = add nuw i64 %27, 1
%42 = icmp eq i64 %41, %10
br i1 %42, label %20, label %26
43: ; preds = %23, %43
%44 = phi i8** [ %14, %23 ], [ %53, %43 ]
%45 = phi i64 [ 0, %23 ], [ %52, %43 ]
%46 = call i32 @write_all(i32 1, i8* %24, i32 5)
%47 = call i32 @write_ulong(i32 1, i64 %45)
%48 = call i32 @write_all(i32 1, i8* %25, i32 4)
%49 = load i8*, i8** %44
%50 = call i32 @write_string(i32 1, i8* %49)
store i8 10, i8* %8
%51 = call i32 @write_all(i32 1, i8* %8, i32 1)
%52 = add i64 %45, 1
%53 = getelementptr inbounds i8*, i8** %14, i64 %52
%54 = load i8*, i8** %53
%55 = icmp eq i8* %54, null
br i1 %55, label %56, label %43
56: ; preds = %43, %20
%57 = call i32 @nolibc_exit(i32 0)
ret void
}