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


x86 assembly (clang, -O0):
<log_perr_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    115e <log_perr_str+0x3e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <logm@plt>
jmp    1198 <log_perr_str+0x78>
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %eax,%r8d
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1030 <logm@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_perr_str>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
test   %ecx,%ecx
je     1154 <log_perr_str+0x34>
mov    %ecx,%edi
call   1040 <strerror@plt>
lea    0xeca(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <logm@plt>
lea    0xea5(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <logm@plt>

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

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