#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 **__environ;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i = 0;
  char **index = __environ;
  fprintf(stderr, "argc=%d\n", argc);
  for (i = 0; i < argc; i++) {
    fprintf(stderr, "argv[%d]='%s'\n", i, argv[i]);
  }
  i = 0;
  while (*index) {
    fprintf(stderr, "environ[%d]='%s'\n", i++, *index++);
  }
  exit(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)
movl   $0x0,-0x14(%rbp)
mov    0x2eb4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <main+0x8c>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <main+0x4c>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11fa <main+0xda>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%rcx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b3 <main+0x93>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x2ec1(%rip),%rax
mov    (%rax),%r12
mov    0x2e97(%rip),%r13
mov    0x0(%r13),%edi
lea    0xeb4(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebx,%ebx
jle    118d <main+0x6d>
mov    %ebx,%ebp
lea    0xea7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%edi
mov    (%r15,%rbx,8),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <main+0x50>
mov    (%r12),%rcx
test   %rcx,%rcx
je     11be <main+0x9e>
lea    0xe7b(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x0(%r13),%edi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x8(%r12,%rbx,8),%rcx
add    $0x1,%rbx
test   %rcx,%rcx
jne    11a0 <main+0x80>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@__environ = global i8** null
@stderr = global i32 0
@.str = [9 x i8] c"argc=%d\0A\00"
@.str.1 = [15 x i8] c"argv[%d]='%s'\0A\00"
@.str.2 = [18 x i8] c"environ[%d]='%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i8**, i8*** @__environ
store i8** %8, i8*** %7
%9 = load i32, i32* @stderr
%10 = load i32, i32* %4
%11 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %6
br label %12
12: ; preds = %25, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i32, i32* %6
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %12
28: ; preds = %12
store i32 0, i32* %6
br label %29
29: ; preds = %33, %28
%30 = load i8**, i8*** %7
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
%37 = load i8**, i8*** %7
%38 = getelementptr inbounds i8*, i8** %37, i32 1
store i8** %38, i8*** %7
%39 = load i8*, i8** %37
%40 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %35, i8* %39)
br label %29
41: ; preds = %29
%42 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@__environ = global i8** null
@stderr = global i32 0
@.str = [9 x i8] c"argc=%d\0A\00"
@.str.1 = [15 x i8] c"argv[%d]='%s'\0A\00"
@.str.2 = [18 x i8] c"environ[%d]='%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8**, i8*** @__environ
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %12
9: ; preds = %12, %2
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, null
br i1 %11, label %31, label %21
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %19, %12 ]
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds i8*, i8** %1, i64 %13
%16 = load i8*, i8** %15
%17 = trunc i64 %13 to i32
%18 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %16)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %9, label %12
21: ; preds = %9, %21
%22 = phi i8* [ %29, %21 ], [ %10, %9 ]
%23 = phi i8** [ %27, %21 ], [ %3, %9 ]
%24 = phi i32 [ %26, %21 ], [ 0, %9 ]
%25 = load i32, i32* @stderr
%26 = add nuw nsw i32 %24, 1
%27 = getelementptr inbounds i8*, i8** %23, i64 1
%28 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24, i8* %22)
%29 = load i8*, i8** %27
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %21
31: ; preds = %21, %9
%32 = tail call i32 @exit(i32 0)
unreachable
}