#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*/ sprintf(char *, char *, char const *, ...);
scalar_t__ strlen(char const *);
int ComposeCommand(const char **cmd, const char **param, char *sendBuf) {
  if (strlen(*param) == 0)
    return -1;
  if (strlen(*param) == 0)
    sprintf(sendBuf, "%s\r\n", *cmd);
  else
    sprintf(sendBuf, "%s %s\r\n", *cmd, *param);
  return 0;
}


x86 assembly (clang, -O0):
<ComposeCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1156 <ComposeCommand+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <ComposeCommand+0x91>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    118a <ComposeCommand+0x6a>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11aa <ComposeCommand+0x8a>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComposeCommand>:
push   %rbx
mov    (%rsi),%rcx
cmpb   $0x0,(%rcx)
je     1134 <ComposeCommand+0x24>
mov    (%rdi),%rax
lea    0xedd(%rip),%rsi
xor    %ebx,%ebx
mov    %rdx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1139 <ComposeCommand+0x29>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s\0D\0A\00"
@.str.1 = [8 x i8] c"%s %s\0D\0A\00"
define i32 @ComposeCommand(i8** %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%8 = load i8**, i8*** %6
%9 = load i8*, i8** %8
%10 = call i64 @strlen(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 -1, i32* %4
br label %31
13: ; preds = %3
%14 = load i8**, i8*** %6
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %30
23: ; preds = %13
%24 = load i8*, i8** %7
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %6
%28 = load i8*, i8** %27
%29 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %28)
br label %30
30: ; preds = %23, %18
store i32 0, i32* %4
br label %31
31: ; preds = %30, %12
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%s %s\0D\0A\00"
define i32 @ComposeCommand(i8** nocapture %0, i8** nocapture %1, i8* nocapture writeonly %2) {
%4 = load i8*, i8** %1
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = load i8*, i8** %0
%9 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %4)
br label %10
10: ; preds = %3, %7
%11 = phi i32 [ 0, %7 ], [ -1, %3 ]
ret i32 %11
}