#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[]) {
  int i = 0;
  printf("command: %s\n", argv[i++]);
  while (i < argc) {
    printf("parameter %d: %s\n", i, argv[i++]);
  }
}


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    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1189 <main+0x79>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1151 <main+0x41>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rsi
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%ebp
jl     115a <main+0x4a>
mov    %ebp,%ebp
mov    $0x1,%esi
lea    0xecd(%rip),%r14
lea    0x1(%rsi),%rbx
mov    (%r15,%rsi,8),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rsi
cmp    %rbx,%rbp
jne    1140 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"command: %s\0A\00"
@.str.1 = [18 x i8] c"parameter %d: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i8**, i8*** %5
%8 = load i32, i32* %6
%9 = add nsw i32 %8, 1
store i32 %9, i32* %6
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8*, i8** %7, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %18, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i32, i32* %6
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %25)
br label %14
27: ; preds = %14
%28 = load i32, i32* %3
ret i32 %28
}

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