#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
scalar_t__ strerror_r(int, char *, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void pr_perror(char *prefix, int error) {
  char buffer[256];
  if (strerror_r(error, buffer, sizeof(buffer))) {
    syslog(LOG_ERR, "%s: %d", prefix, error);
    syslog(LOG_ERR, "(Sorry. I tried to stringify that but it didn't work.)");
  } else {
    syslog(LOG_ERR, "%s: %s", prefix, buffer);
  }
}


x86 assembly (clang, -O0):
<pr_perror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strerror_r@plt>
cmp    $0x0,%rax
je     118a <pr_perror+0x6a>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
jmp    11ac <pr_perror+0x8c>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    -0x110(%rbp),%rcx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_perror>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x100,%edx
call   1030 <strerror_r@plt>
mov    0x2e92(%rip),%r14
mov    (%r14),%edi
test   %rax,%rax
je     1174 <pr_perror+0x54>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
jmp    1188 <pr_perror+0x68>
lea    0xec3(%rip),%rsi
mov    %rsp,%rcx
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <syslog@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LOG_ERR = global i32 0
@.str = [7 x i8] c"%s: %d\00"
@.str.1 = [55 x i8] c"(Sorry. I tried to stringify that but it didn't work.)\00"
@.str.2 = [7 x i8] c"%s: %s\00"
define void @pr_perror(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [256 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i64 @strerror_r(i32 %6, i8* %7, i32 256)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @LOG_ERR
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
%15 = load i32, i32* @LOG_ERR
%16 = call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
br label %22
17: ; preds = %2
%18 = load i32, i32* @LOG_ERR
%19 = load i8*, i8** %3
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20)
br label %22
22: ; preds = %17, %10
ret void
}

LLVM IR (-O2):
@LOG_ERR = global i32 0
@.str = [7 x i8] c"%s: %d\00"
@.str.1 = [55 x i8] c"(Sorry. I tried to stringify that but it didn't work.)\00"
@.str.2 = [7 x i8] c"%s: %s\00"
define void @pr_perror(i8* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i64 @strerror_r(i32 %1, i8* %4, i32 256)
%6 = icmp eq i64 %5, 0
%7 = load i32, i32* @LOG_ERR
br i1 %6, label %12, label %8
8: ; preds = %2
%9 = call i32 (i32, i8*, ...) @syslog(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%10 = load i32, i32* @LOG_ERR
%11 = call i32 (i32, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %2
%13 = call i32 (i32, i8*, ...) @syslog(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %4)
br label %14
14: ; preds = %12, %8
ret void
}