#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 /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[], char *env[]) {
  int count;
  puts("Commandline:");
  for (count = 0; count < argc; count++)
    printf("%d: %s\n", count, argv[count]);
  puts("\nEnvironment:");
  for (count = 0; env[count]; count++)
    printf("%d: %s\n", count, env[count]);
  putenv("PATH=");
  puts("\nEnvironment after a setenv (\"PATH=\");:");
  for (count = 0; env[count]; count++)
    printf("%d: %s\n", count, env[count]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1192 <main+0x62>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115d <main+0x2d>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11e1 <main+0xb1>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <main+0x75>
lea    0xe3b(%rip),%rdi
call   1050 <putenv@plt>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     123c <main+0x10c>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1200 <main+0xd0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    1177 <main+0x47>
mov    %ebx,%r13d
xor    %ebx,%ebx
lea    0xeb0(%rip),%r12
nopl   (%rax)
mov    (%r15,%rbx,8),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <main+0x30>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%rdx
test   %rdx,%rdx
je     11b8 <main+0x88>
xor    %ebx,%ebx
lea    0xe79(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x8(%r14,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    11a0 <main+0x70>
lea    0xe64(%rip),%rdi
call   1050 <putenv@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%rdx
test   %rdx,%rdx
je     1208 <main+0xd8>
xor    %ebx,%ebx
lea    0xe2c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x8(%r14,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    11f0 <main+0xc0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Commandline:\00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
@.str.2 = [14 x i8] c"\0AEnvironment:\00"
@.str.3 = [6 x i8] c"PATH=\00"
@.str.4 = [40 x i8] c"\0AEnvironment after a setenv (\22PATH=\22);:\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %10
10: ; preds = %22, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %8
%16 = load i8**, i8*** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
br label %10
25: ; preds = %10
%26 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %27
27: ; preds = %42, %25
%28 = load i8**, i8*** %7
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %45
34: ; preds = %27
%35 = load i32, i32* %8
%36 = load i8**, i8*** %7
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %35, i8* %40)
br label %42
42: ; preds = %34
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %27
45: ; preds = %27
%46 = call i32 @putenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %48
48: ; preds = %63, %45
%49 = load i8**, i8*** %7
%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 = icmp ne i8* %53, null
br i1 %54, label %55, label %66
55: ; preds = %48
%56 = load i32, i32* %8
%57 = load i8**, i8*** %7
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %56, i8* %61)
br label %63
63: ; preds = %55
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %48
66: ; preds = %48
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Commandline:\00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
@.str.2 = [14 x i8] c"\0AEnvironment:\00"
@.str.3 = [6 x i8] c"PATH=\00"
@.str.4 = [40 x i8] c"\0AEnvironment after a setenv (\22PATH=\22);:\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = trunc i64 %9 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %11)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %3
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %2
%19 = icmp eq i8* %18, null
br i1 %19, label %29, label %20
20: ; preds = %16, %20
%21 = phi i64 [ %25, %20 ], [ 0, %16 ]
%22 = phi i8* [ %27, %20 ], [ %18, %16 ]
%23 = trunc i64 %21 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %22)
%25 = add nuw i64 %21, 1
%26 = getelementptr inbounds i8*, i8** %2, i64 %25
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %20
29: ; preds = %20, %16
%30 = tail call i32 @putenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%32 = load i8*, i8** %2
%33 = icmp eq i8* %32, null
br i1 %33, label %43, label %34
34: ; preds = %29, %34
%35 = phi i64 [ %39, %34 ], [ 0, %29 ]
%36 = phi i8* [ %41, %34 ], [ %32, %29 ]
%37 = trunc i64 %35 to i32
%38 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %37, i8* %36)
%39 = add nuw i64 %35, 1
%40 = getelementptr inbounds i8*, i8** %2, i64 %39
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %34
43: ; preds = %34, %29
ret i32 0
}