#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int strlen(char const *);
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void venprintf(int status, const char *fmt, va_list ap) {
  vfprintf(stderr, fmt, ap);
  if (fmt[0] && fmt[strlen(fmt) - 1] == ':') {
    fputc(' ', stderr);
    perror(NULL);
  }
  exit(status);
}


x86 assembly (clang, -O0):
<venprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <vfprintf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cd <venprintf+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    11cd <venprintf+0x7d>
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <fputc@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    -0x4(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<venprintf>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e80(%rip),%r14
mov    (%r14),%edi
call   1060 <vfprintf@plt>
cmpb   $0x0,(%rbx)
je     1192 <venprintf+0x42>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x3a,-0x1(%rax,%rbx,1)
jne    1192 <venprintf+0x42>
mov    (%r14),%esi
mov    $0x20,%edi
call   1040 <fputc@plt>
xor    %edi,%edi
call   1050 <perror@plt>
mov    %ebp,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
define void @venprintf(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = call i32 @vfprintf(i32 %7, i8* %8, i32 %9)
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 58
br i1 %25, label %26, label %30
26: ; preds = %16
%27 = load i32, i32* @stderr
%28 = call i32 @fputc(i8 signext 32, i32 %27)
%29 = call i32 @perror(i32* null)
br label %30
30: ; preds = %26, %16, %3
%31 = load i32, i32* %4
%32 = call i32 @exit(i32 %31)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
define void @venprintf(i32 %0, i8* %1, i32 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 @vfprintf(i32 %4, i8* %1, i32 %2)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %3
%9 = tail call i32 @strlen(i8* %1)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 58
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputc(i8 signext 32, i32 %16)
%18 = tail call i32 @perror(i32* null)
br label %19
19: ; preds = %15, %8, %3
%20 = tail call i32 @exit(i32 %0)
unreachable
}