#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 BUFSIZ;
int /*<<< orphan*/ printf(char *, ...);
void main(int argc, char *argv[], char *envv[]) {
  int i;
  char curdir[BUFSIZ];
  printf("Content-type: text/plain\n\n");
  for (i = 0; i < argc; i++) {
    printf("argv[%d]: %s\n", i, argv[i]);
  }
  for (i = 0; envv[i]; i++) {
    printf("env[%d]: %s\n", i, envv[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <main+0x73>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <main+0x3c>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c8 <main+0xb8>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <main+0x7a>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%ebx
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    1169 <main+0x49>
mov    %ebx,%r13d
lea    0xeb5(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r12,%rbx,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <main+0x30>
mov    (%r14),%rdx
test   %rdx,%rdx
je     119a <main+0x7a>
lea    0xe96(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r14,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    1180 <main+0x60>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [27 x i8] c"Content-type: text/plain\0A\0A\00"
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@.str.2 = [13 x i8] c"env[%d]: %s\0A\00"
define void @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%10 = load i32, i32* @BUFSIZ
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i8, i64 %11
store i64 %11, i64* %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %15
15: ; preds = %27, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %7
%21 = load i8**, i8*** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %15
30: ; preds = %15
store i32 0, i32* %7
br label %31
31: ; preds = %46, %30
%32 = load i8**, i8*** %6
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %49
38: ; preds = %31
%39 = load i32, i32* %7
%40 = load i8**, i8*** %6
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %39, i8* %44)
br label %46
46: ; preds = %38
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %31
49: ; preds = %31
%50 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@.str.2 = [13 x i8] c"env[%d]: %s\0A\00"
@str = [26 x i8] c"Content-type: text/plain\0A\00"
define void @main(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %11, %3
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, null
br i1 %10, label %28, label %19
11: ; preds = %6, %11
%12 = phi i64 [ 0, %6 ], [ %17, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = trunc i64 %12 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %14)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %8, label %11
19: ; preds = %8, %19
%20 = phi i64 [ %24, %19 ], [ 0, %8 ]
%21 = phi i8* [ %26, %19 ], [ %9, %8 ]
%22 = trunc i64 %20 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8* %21)
%24 = add nuw i64 %20, 1
%25 = getelementptr inbounds i8*, i8** %2, i64 %24
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %19
28: ; preds = %19, %8
ret void
}