#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 main(int argc, char **argv, char **envp) {
  printf("argc=%d\n", argc);
  for (int i = 0; i < argc; i++) {
    printf("argv[%d]=%s\n", i, argv[i]);
  }
  printf("envp=%p\n", envp);
  if (!envp)
    goto out;
  for (char **env = envp; *env != 0; env++) {
    printf("env: %s\n", *env);
  }
out:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1179 <main+0x69>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <main+0x32>
mov    -0x18(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
jne    119b <main+0x8b>
jmp    11dc <main+0xcc>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d7 <main+0xc7>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    11a3 <main+0x93>
jmp    11dc <main+0xcc>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xed8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    1169 <main+0x59>
mov    %ebx,%r13d
lea    0xeca(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <main+0x40>
lea    0xea6(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r12,%r12
je     11b7 <main+0xa7>
mov    (%r12),%rsi
test   %rsi,%rsi
je     11b7 <main+0xa7>
add    $0x8,%r12
lea    0xe8c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r12),%rsi
add    $0x8,%r12
test   %rsi,%rsi
jne    11a0 <main+0x90>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"argc=%d\0A\00"
@.str.1 = [13 x i8] c"argv[%d]=%s\0A\00"
@.str.2 = [9 x i8] c"envp=%p\0A\00"
@.str.3 = [9 x i8] c"env: %s\0A\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
%9 = alloca i8**
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i32, i32* %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %8
br label %12
12: ; preds = %24, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %8
%18 = load i8**, i8*** %6
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %12
27: ; preds = %12
%28 = load i8**, i8*** %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %28)
%30 = load i8**, i8*** %7
%31 = icmp ne i8** %30, null
br i1 %31, label %33, label %32
32: ; preds = %27
br label %47
33: ; preds = %27
%34 = load i8**, i8*** %7
store i8** %34, i8*** %9
br label %35
35: ; preds = %43, %33
%36 = load i8**, i8*** %9
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load i8**, i8*** %9
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %39
%44 = load i8**, i8*** %9
%45 = getelementptr inbounds i8*, i8** %44, i32 1
store i8** %45, i8*** %9
br label %35
46: ; preds = %35
br label %47
47: ; preds = %46, %32
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"argc=%d\0A\00"
@.str.1 = [13 x i8] c"argv[%d]=%s\0A\00"
@.str.2 = [9 x i8] c"envp=%p\0A\00"
@.str.3 = [9 x i8] c"env: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %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 %14
8: ; preds = %14, %3
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2)
%10 = icmp eq i8** %2, null
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %29, label %22
14: ; preds = %6, %14
%15 = phi i64 [ 0, %6 ], [ %20, %14 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = trunc i64 %15 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %17)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %8, label %14
22: ; preds = %11, %22
%23 = phi i8* [ %27, %22 ], [ %12, %11 ]
%24 = phi i8** [ %26, %22 ], [ %2, %11 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%26 = getelementptr inbounds i8*, i8** %24, i64 1
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %22
29: ; preds = %22, %11, %8
ret i32 0
}