#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 *, unsigned int, ...);
void args_cmd(char *argv[], int argc) {
  unsigned i;
  printf("arguments count: %d\r\n", argc);
  for (i = 0; i < argc; ++i) {
    printf("argument %d: %s\r\n", i, argv[i]);
  }
}


x86 assembly (clang, -O0):
<args_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    116d <args_cmd+0x5d>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <args_cmd+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<args_cmd>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
je     1159 <args_cmd+0x49>
mov    %ebx,%r12d
lea    0xedd(%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    1140 <args_cmd+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"arguments count: %d\0D\0A\00"
@.str.1 = [18 x i8] c"argument %d: %s\0D\0A\00"
define void @args_cmd(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i8**, i8*** %3
%15 = load i32, i32* %5
%16 = zext 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 ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %5
%22 = add i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
ret void
}

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