#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_s(char *, ...);
int main(int argc, char *argv[], char *envp[]) {
  for (int i = 0; i < argc; i++) {
    printf_s("%d: %s\n", i, argv[i]);
  }
  printf_s("-----\n");
  char **ppsz = envp;
  while (*ppsz != NULL) {
    printf_s("\t%s\n", *ppsz);
    ppsz++;
  }
  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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1168 <main+0x58>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf_s@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <main+0x21>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf_s@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     11b2 <main+0xa2>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf_s@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    117e <main+0x6e>
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
test   %edi,%edi
jle    1149 <main+0x39>
mov    %rsi,%r14
mov    %edi,%r13d
lea    0xed3(%rip),%r15
xor    %ebx,%ebx
nop
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf_s@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1130 <main+0x20>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf_s@plt>
mov    (%r12),%rsi
test   %rsi,%rsi
je     1187 <main+0x77>
add    $0x8,%r12
lea    0xea4(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf_s@plt>
mov    (%r12),%rsi
add    $0x8,%r12
test   %rsi,%rsi
jne    1170 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d: %s\0A\00"
@.str.1 = [7 x i8] c"-----\0A\00"
@.str.2 = [5 x i8] c"\09%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
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 (i8*, ...) @printf_s(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, 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 (i8*, ...) @printf_s(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8**, i8*** %7
store i8** %27, i8*** %9
br label %28
28: ; preds = %32, %25
%29 = load i8**, i8*** %9
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = load i8**, i8*** %9
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf_s(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i8**, i8*** %9
%37 = getelementptr inbounds i8*, i8** %36, i32 1
store i8** %37, i8*** %9
br label %28
38: ; preds = %28
ret i32 0
}

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