#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
char *thisprogname();
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void v(int is_croak, int use_errno, int exit_code, const char *fmt,
       va_list ap) {
  fprintf(stderr, "%s: ", thisprogname());
  if (fmt != NULL) {
    vfprintf(stderr, fmt, ap);
    if (use_errno >= 0)
      fprintf(stderr, ": ");
  }
  if (use_errno >= 0)
    fprintf(stderr, "%s\n", strerror(use_errno));
  else
    fprintf(stderr, "\n");
  if (is_croak)
    exit(exit_code);
}


x86 assembly (clang, -O0):
<v>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <thisprogname@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11d6 <v+0x86>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <vfprintf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11d1 <v+0x81>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d6 <v+0x86>
cmpl   $0x0,-0x8(%rbp)
jl     120d <v+0xbd>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1224 <v+0xd4>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
je     1236 <v+0xe6>
mov    -0xc(%rbp),%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r12d
mov    %rcx,%rbp
mov    %edx,0x4(%rsp)
mov    %esi,%r13d
mov    %edi,%r15d
mov    0x2e6e(%rip),%r14
mov    (%r14),%ebx
xor    %eax,%eax
call   1040 <thisprogname@plt>
lea    0xe7d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %rbp,%rbp
je     11ba <v+0x6a>
mov    (%r14),%edi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <vfprintf@plt>
test   %r13d,%r13d
js     11f1 <v+0xa1>
mov    (%r14),%edi
lea    0xe51(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11bf <v+0x6f>
test   %r13d,%r13d
js     11f1 <v+0xa1>
mov    (%r14),%ebx
mov    %r13d,%edi
call   1070 <strerror@plt>
lea    0xe34(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
jne    1207 <v+0xb7>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%edi
lea    0xe0c(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
je     11e2 <v+0x92>
mov    0x4(%rsp),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [3 x i8] c": \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @v(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i32, i32* @stderr
%12 = call i8* (...) @thisprogname()
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %9
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %27
16: ; preds = %5
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %9
%19 = load i32, i32* %10
%20 = call i32 @vfprintf(i32 %17, i8* %18, i32 %19)
%21 = load i32, i32* %7
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %23, %16
br label %27
27: ; preds = %26, %5
%28 = load i32, i32* %7
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i32, i32* %7
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %38
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %35, %30
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %8
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %38
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 = [4 x i8] c"%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @v(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = load i32, i32* @stderr
%7 = tail call i8* (...) @thisprogname()
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i8* %3, null
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 @vfprintf(i32 %11, i8* %3, i32 %4)
%13 = icmp sgt i32 %1, -1
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %19
17: ; preds = %5
%18 = icmp sgt i32 %1, -1
br i1 %18, label %19, label %23
19: ; preds = %14, %17
%20 = load i32, i32* @stderr
%21 = tail call i8* @strerror(i32 %1)
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %26
23: ; preds = %10, %17
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %23, %19
%27 = icmp eq i32 %0, 0
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @exit(i32 %2)
unreachable
30: ; preds = %26
ret void
}