#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*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
void cs_logerr(int ecode, char *caller, char *txtmsg) {
  if (caller != NULL && txtmsg != NULL) {
    if (ecode != -1)
      fprintf(stderr, "%s: %s (%d)\n", caller, txtmsg, ecode);
    else
      fprintf(stderr, "%s: %s\n", caller, txtmsg);
  }
}


x86 assembly (clang, -O0):
<cs_logerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118f <cs_logerr+0x7f>
cmpq   $0x0,-0x18(%rbp)
je     118f <cs_logerr+0x7f>
cmpl   $0xffffffff,-0x4(%rbp)
je     116b <cs_logerr+0x5b>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    118a <cs_logerr+0x7a>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    118f <cs_logerr+0x7f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cs_logerr>:
test   %rsi,%rsi
je     1140 <cs_logerr+0x30>
mov    %rdx,%rcx
test   %rdx,%rdx
je     1140 <cs_logerr+0x30>
mov    %rsi,%rdx
mov    %edi,%r8d
mov    0x2eb6(%rip),%rax
mov    (%rax),%edi
cmp    $0xffffffff,%r8d
je     1141 <cs_logerr+0x31>
lea    0xec7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <fprintf@plt>
ret
lea    0xec5(%rip),%rsi
xor    %eax,%eax
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"%s: %s (%d)\0A\00"
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define void @cs_logerr(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %27
9: ; preds = %3
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %5
%18 = load i8*, i8** %6
%19 = load i32, i32* %4
%20 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18, i32 %19)
br label %26
21: ; preds = %12
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
br label %26
26: ; preds = %21, %15
br label %27
27: ; preds = %26, %9, %3
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"%s: %s (%d)\0A\00"
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define void @cs_logerr(i32 %0, i8* %1, i8* %2) {
%4 = icmp ne i8* %1, null
%5 = icmp ne i8* %2, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = icmp eq i32 %0, -1
%9 = load i32, i32* @stderr
br i1 %8, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32 %0)
br label %14
12: ; preds = %7
%13 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
br label %14
14: ; preds = %10, %12, %3
ret void
}