#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void print_cmd(char *cmd, const char *function) {
  char outprint[2048 + 1];
  memset(outprint, 0, 2048 + 1);
  strncpy(outprint, cmd, 2048);
  char *ptr = outprint + strlen(outprint);
  ptr--;
  while (*ptr == ' ') {
    *ptr = '\0';
    ptr--;
  }
  printf("\tif (cliParserAddCmd(mode, head, \"%s\")) return RCPERR;\n", cmd);
  printf("\tif ((node = cliParserFindCmd(mode, head, \"%s\")) == NULL) return "
         "RCPERR;\n",
         cmd);
  printf("\tif (cliAddFunction(mode, node, %s)) return RCPERR;\n\n", function);
}


x86 assembly (clang, -O0):
<print_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x801,%edx
call   1060 <memset@plt>
lea    -0x820(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
lea    -0x820(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x830(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11f1 <print_cmd+0xb1>
mov    -0x828(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x828(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x828(%rbp)
jmp    11bd <print_cmd+0x7d>
mov    -0x8(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cmd>:
push   %r15
push   %r14
push   %rbx
sub    $0x810,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x801,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x20,-0x1(%rsp,%rax,1)
jne    119d <print_cmd+0x5d>
add    %rsp,%rax
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax)
movb   $0x0,(%rax)
cmpb   $0x20,-0x1(%rax)
lea    -0x1(%rax),%rax
je     1190 <print_cmd+0x50>
lea    0xe5c(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
add    $0x810,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"\09if (cliParserAddCmd(mode, head, \22%s\22)) return RCPERR;\0A\00"
@.str.1 = [74 x i8] c"\09if ((node = cliParserFindCmd(mode, head, \22%s\22)) == NULL) return RCPERR;\0A\00"
@.str.2 = [54 x i8] c"\09if (cliAddFunction(mode, node, %s)) return RCPERR;\0A\0A\00"
define void @print_cmd(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2049 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [2049 x i8], [2049 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 2049)
%9 = getelementptr inbounds [2049 x i8], [2049 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @strncpy(i8* %9, i8* %10, i32 2048)
%12 = getelementptr inbounds [2049 x i8], [2049 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [2049 x i8], [2049 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i32 -1
store i8* %18, i8** %6
br label %19
19: ; preds = %24, %2
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i8*, i8** %6
store i8 0, i8* %25
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 -1
store i8* %27, i8** %6
br label %19
28: ; preds = %19
%29 = load i8*, i8** %3
%30 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %3
%32 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %4
%34 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i8* %33)
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"\09if (cliParserAddCmd(mode, head, \22%s\22)) return RCPERR;\0A\00"
@.str.1 = [74 x i8] c"\09if ((node = cliParserFindCmd(mode, head, \22%s\22)) == NULL) return RCPERR;\0A\00"
@.str.2 = [54 x i8] c"\09if (cliAddFunction(mode, node, %s)) return RCPERR;\0A\0A\00"
define void @print_cmd(i8* %0, i8* %1) {
%3 = alloca [2049 x i8]
%4 = getelementptr inbounds [2049 x i8], [2049 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 2049)
%6 = call i32 @strncpy(i8* %4, i8* %0, i32 2048)
%7 = call i32 @strlen(i8* %4)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [2049 x i8], [2049 x i8]* %3, i64 0, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %13, label %18
13: ; preds = %2, %13
%14 = phi i8* [ %15, %13 ], [ %10, %2 ]
store i8 0, i8* %14
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
br i1 %17, label %13, label %18
18: ; preds = %13, %2
%19 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %0)
%20 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%21 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
}