#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*/ printf(char *, int, ...);
int main(int argc, char **argv) {
  int i;
  for (i = 0; i < argc; i++) {
    printf("arg%d: %s\n", i, argv[i]);
  }
  char **penv = __environ;
  while (penv && *penv) {
    printf("%s\n", *penv++);
  }
  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)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1164 <main+0x54>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <main+0x1d>
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     1190 <main+0x80>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a0 <main+0x90>
jmp    11c7 <main+0xb7>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%rax
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1172 <main+0x62>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1149 <main+0x39>
mov    %rsi,%r15
mov    %edi,%r12d
lea    0xed7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <main+0x20>
mov    0x2ea8(%rip),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     1186 <main+0x76>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1186 <main+0x76>
add    $0x8,%rbx
lea    0xe9c(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1170 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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