#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*/ consolemanager_println(char *);
void cmd_test(int argc, char *argv[]) {
  if (argc == 0) {
    consolemanager_println("No argument");
    return;
  }
  consolemanager_println("Arguments list:");
  for (int i = 0; i < argc; i++) {
    consolemanager_println(argv[i]);
  }
}


x86 assembly (clang, -O0):
<cmd_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113a <cmd_test+0x2a>
lea    0xed0(%rip),%rdi
call   1030 <consolemanager_println@plt>
jmp    1178 <cmd_test+0x68>
lea    0xecb(%rip),%rdi
call   1030 <consolemanager_println@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1178 <cmd_test+0x68>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <consolemanager_println@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <cmd_test+0x3d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_test>:
test   %edi,%edi
je     1157 <cmd_test+0x47>
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xee8(%rip),%rdi
call   1030 <consolemanager_println@plt>
test   %ebp,%ebp
jle    1152 <cmd_test+0x42>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <consolemanager_println@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <cmd_test+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xea2(%rip),%rdi
jmp    1030 <consolemanager_println@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"No argument\00"
@.str.1 = [16 x i8] c"Arguments list:\00"
define void @cmd_test(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @consolemanager_println(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %18
6: ; preds = %2
%7 = tail call i32 @consolemanager_println(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @consolemanager_println(i8* %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %6, %4
ret void
}