#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 *, char *);
int main(int argc, char *argv[], char *envp[]) {
  for (int i = 0; i < argc; i++) {
    printf("arg:%s\n", argv[i]);
  }
  for (int i = 0; envp[i] != NULL; i++) {
    printf("env:%s\n", envp[i]);
  }
  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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1163 <main+0x53>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <main+0x21>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a3 <main+0x93>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116a <main+0x5a>
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,%r13
test   %edi,%edi
jle    1145 <main+0x35>
mov    %rsi,%r14
mov    %edi,%r12d
xor    %ebx,%ebx
lea    0xed1(%rip),%r15
nop
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <main+0x20>
mov    0x0(%r13),%rsi
test   %rsi,%rsi
je     1175 <main+0x65>
add    $0x8,%r13
lea    0xeaf(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x0(%r13),%rsi
add    $0x8,%r13
test   %rsi,%rsi
jne    1160 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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