#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*/ LOG_WARNING;
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strerror(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void report(char *logmsg, int errnum) {
  char buf[127];
  int debug;
  if (errnum > 0) {
    sprintf(buf, logmsg, strerror(errnum));
  } else {
    strcpy(buf, logmsg);
  }
  debug = 0;
  if (debug) {
    fputs(buf, stderr);
    fputc('\n', stderr);
  } else {
    syslog(LOG_WARNING, buf);
  }
}


x86 assembly (clang, -O0):
<report>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11b7 <report+0x57>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <strerror@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    %eax,%edx
call   1070 <sprintf@plt>
jmp    11c7 <report+0x67>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
je     120b <report+0xab>
lea    -0x90(%rbp),%rdi
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
jmp    1220 <report+0xc0>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
call   1060 <syslog@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report>:
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
test   %esi,%esi
jle    1165 <report+0x25>
mov    %esi,%edi
call   1060 <strerror@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <sprintf@plt>
jmp    1170 <report+0x30>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <syslog@plt>
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@LOG_WARNING = global i32 0
define void @report(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [127 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = getelementptr inbounds [127 x i8], [127 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @sprintf(i8* %10, i8* %11, i32 %13)
br label %19
15: ; preds = %2
%16 = getelementptr inbounds [127 x i8], [127 x i8]* %5, i64 0, i64 0
%17 = load i8*, i8** %3
%18 = call i32 @strcpy(i8* %16, i8* %17)
br label %19
19: ; preds = %15, %9
store i32 0, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = getelementptr inbounds [127 x i8], [127 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* @stderr
%25 = call i32 @fputs(i8* %23, i32 %24)
%26 = load i32, i32* @stderr
%27 = call i32 @fputc(i8 signext 10, i32 %26)
br label %32
28: ; preds = %19
%29 = load i32, i32* @LOG_WARNING
%30 = getelementptr inbounds [127 x i8], [127 x i8]* %5, i64 0, i64 0
%31 = call i32 @syslog(i32 %29, i8* %30)
br label %32
32: ; preds = %28, %22
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@LOG_WARNING = global i32 0
define void @report(i8* %0, i32 %1) {
%3 = alloca [127 x i8]
%4 = getelementptr inbounds [127 x i8], [127 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @strerror(i32 %1)
%8 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %0, i32 %7)
br label %11
9: ; preds = %2
%10 = call i32 @strcpy(i8* %4, i8* %0)
br label %11
11: ; preds = %6, %9
%12 = load i32, i32* @LOG_WARNING
%13 = call i32 @syslog(i32 %12, i8* %4)
ret void
}