#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*/ logm(int, char *, char const *, ...);
int /*<<< orphan*/ strerror(int);
void log_perr(int priority, const char msg[], int fault_errno) {
  if (!fault_errno)
    logm(priority, "%s", msg);
  else
    logm(priority, "%s: %s", msg, strerror(fault_errno));
}


x86 assembly (clang, -O0):
<log_perr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1156 <log_perr+0x36>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1030 <logm@plt>
jmp    1183 <log_perr+0x63>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <logm@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_perr>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edx,%edx
je     114e <log_perr+0x2e>
mov    %edx,%edi
call   1040 <strerror@plt>
lea    0xec6(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <logm@plt>
lea    0xeaf(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <logm@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"%s: %s\00"
define void @log_perr(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i32, i32* %4
%11 = load i8*, i8** %5
%12 = call i32 (i32, i8*, i8*, ...) @logm(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %19
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = call i32 @strerror(i32 %16)
%18 = call i32 (i32, i8*, i8*, ...) @logm(i32 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
br label %19
19: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"%s: %s\00"
define void @log_perr(i32 %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i32, i8*, i8*, ...) @logm(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %10
7: ; preds = %3
%8 = tail call i32 @strerror(i32 %2)
%9 = tail call i32 (i32, i8*, i8*, ...) @logm(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %8)
br label %10
10: ; preds = %7, %5
ret void
}