#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*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int);
int tolower(char);
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void output(int errnum, const char *severity, const char *message, va_list ap) {
  const int have_message = ((message != 0) && (message[0] != '\0'));
  fprintf(stderr, "%s: ", severity);
  if (have_message) {
    vfprintf(stderr, message, ap);
  }
  if (errnum != 0) {
    char *errstr = strerror(errnum);
    if (have_message) {
      fputs(", ", stderr);
    }
    fprintf(stderr, "%c%s", tolower(errstr[0]), &errstr[1]);
  }
  fputc('\n', stderr);
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x29(%rbp)
je     1196 <output+0x36>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     11db <output+0x7b>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <vfprintf@plt>
cmpl   $0x0,-0x4(%rbp)
je     1243 <output+0xe3>
mov    -0x4(%rbp),%edi
call   1080 <strerror@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1210 <output+0xb0>
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%edx
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbp
mov    %rsi,%rdx
mov    %edi,%r12d
test   %rbp,%rbp
je     11c7 <output+0x67>
mov    %ecx,%r14d
mov    0x0(%rbp),%bl
mov    0x2e5d(%rip),%r15
mov    (%r15),%edi
lea    0xe73(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %bl,%bl
je     11de <output+0x7e>
mov    (%r15),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1070 <vfprintf@plt>
test   %r12d,%r12d
je     1218 <output+0xb8>
mov    %r12d,%edi
call   1080 <strerror@plt>
mov    %rax,%rbx
mov    (%r15),%esi
lea    0xe45(%rip),%rdi
call   1030 <fputs@plt>
jmp    11ee <output+0x8e>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r12d,%r12d
je     1218 <output+0xb8>
mov    %r12d,%edi
call   1080 <strerror@plt>
mov    %rax,%rbx
mov    0x2deb(%rip),%rax
mov    (%rax),%ebp
movsbl (%rbx),%edi
call   1060 <tolower@plt>
add    $0x1,%rbx
lea    0xdfe(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [5 x i8] c"%c%s\00"
define void @output(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %19
13: ; preds = %4
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %13, %4
%20 = phi i1 [ false, %4 ], [ %18, %13 ]
%21 = zext i1 %20 to i32
store i32 %21, i32* %9
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %6
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = call i32 @vfprintf(i32 %28, i8* %29, i32 %30)
br label %32
32: ; preds = %27, %19
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %52
35: ; preds = %32
%36 = load i32, i32* %5
%37 = call i8* @strerror(i32 %36)
store i8* %37, i8** %10
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %35
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %10
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = call i32 @tolower(i8 signext %47)
%49 = load i8*, i8** %10
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %48, i8* %50)
br label %52
52: ; preds = %43, %32
%53 = load i32, i32* @stderr
%54 = call i32 @fputc(i8 signext 10, i32 %53)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [5 x i8] c"%c%s\00"
define void @output(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = icmp eq i8* %2, null
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
br i1 %8, label %11, label %13
11: ; preds = %6
%12 = icmp eq i32 %0, 0
br i1 %12, label %36, label %23
13: ; preds = %6
%14 = load i32, i32* @stderr
%15 = tail call i32 @vfprintf(i32 %14, i8* %2, i32 %3)
%16 = icmp eq i32 %0, 0
br i1 %16, label %36, label %25
17: ; preds = %4
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
%20 = icmp eq i32 %0, 0
br i1 %20, label %36, label %21
21: ; preds = %17
%22 = tail call i8* @strerror(i32 %0)
br label %29
23: ; preds = %11
%24 = tail call i8* @strerror(i32 %0)
br label %29
25: ; preds = %13
%26 = tail call i8* @strerror(i32 %0)
%27 = load i32, i32* @stderr
%28 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %23, %21, %25
%30 = phi i8* [ %22, %21 ], [ %26, %25 ], [ %24, %23 ]
%31 = load i32, i32* @stderr
%32 = load i8, i8* %30
%33 = tail call i32 @tolower(i8 signext %32)
%34 = getelementptr inbounds i8, i8* %30, i64 1
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33, i8* %34)
br label %36
36: ; preds = %13, %17, %29, %11
%37 = load i32, i32* @stderr
%38 = tail call i32 @fputc(i8 signext 10, i32 %37)
ret void
}