#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*/ pios_fbconsole_write(char *);
int /*<<< orphan*/ printf(char *, ...);
int echoCmd(int argc, char **argv) {
  printf("%d %s\n", argc, argv[0]);
  if (argc > 1) {
    printf("%s\n", argv[1]);
    pios_fbconsole_write(argv[1]);
    pios_fbconsole_write("\n");
  } else {
    pios_fbconsole_write("Usage: ");
    pios_fbconsole_write(argv[0]);
    pios_fbconsole_write(" <something to output>\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<echoCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jle    1185 <echoCmd+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <pios_fbconsole_write@plt>
lea    0xeaa(%rip),%rdi
call   1040 <pios_fbconsole_write@plt>
jmp    11a9 <echoCmd+0x89>
lea    0xe7b(%rip),%rdi
call   1040 <pios_fbconsole_write@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <pios_fbconsole_write@plt>
lea    0xe6b(%rip),%rdi
call   1040 <pios_fbconsole_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echoCmd>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdx
lea    0xebd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     1167 <echoCmd+0x37>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
call   1030 <puts@plt>
lea    0xec0(%rip),%r14
jmp    117a <echoCmd+0x4a>
lea    0xe99(%rip),%rdi
call   1050 <pios_fbconsole_write@plt>
lea    0xe95(%rip),%r14
mov    (%rbx),%rdi
call   1050 <pios_fbconsole_write@plt>
mov    %r14,%rdi
call   1050 <pios_fbconsole_write@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d %s\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"Usage: \00"
@.str.4 = [24 x i8] c" <something to output>\0A\00"
define i32 @echoCmd(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %3)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
br label %12
10: ; preds = %2
%11 = tail call i32 @pios_fbconsole_write(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
%13 = phi i8** [ %1, %10 ], [ %7, %6 ]
%14 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %6 ]
%15 = load i8*, i8** %13
%16 = tail call i32 @pios_fbconsole_write(i8* %15)
%17 = tail call i32 @pios_fbconsole_write(i8* %14)
ret i32 0
}