#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*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
char *strerror(int);
int /*<<< orphan*/ vsnprintf(char *, int, char *, int /*<<< orphan*/);
void outputError(char *formate, va_list vp, int errorNum) {
  char buf[500];
  char userMsg[500];
  char errorText[500];
  vsnprintf(userMsg, 500, formate, vp);
  snprintf(errorText, 500, "%s", strerror(errorNum));
  snprintf(buf, 500, "ERROR %s: %s\n", errorText, userMsg);
  printf("%s", buf);
}


x86 assembly (clang, -O0):
<outputError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x620,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    $0x1f4,%esi
call   1030 <vsnprintf@plt>
lea    -0x610(%rbp),%rax
mov    %rax,-0x618(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x618(%rbp),%rdi
mov    %rax,%rcx
mov    $0x1f4,%esi
lea    0xe67(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x610(%rbp),%rcx
lea    -0x410(%rbp),%r8
mov    $0x1f4,%esi
lea    0xe42(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x210(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
add    $0x620,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputError>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x5f8,%rsp
mov    %edx,%ebp
mov    %esi,%ecx
mov    %rdi,%rdx
lea    0x200(%rsp),%r14
mov    %r14,%rdi
mov    $0x1f4,%esi
call   1030 <vsnprintf@plt>
mov    %ebp,%edi
call   1060 <strerror@plt>
lea    0xe89(%rip),%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1f4,%esi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xe6d(%rip),%rdx
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
add    $0x5f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"ERROR %s: %s\0A\00"
define void @outputError(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [500 x i8]
%8 = alloca [500 x i8]
%9 = alloca [500 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = call i32 @vsnprintf(i8* %10, i32 500, i8* %11, i32 %12)
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%15 = load i32, i32* %6
%16 = call i8* @strerror(i32 %15)
%17 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 500, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%21 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %18, i32 500, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"ERROR %s: %s\0A\00"
define void @outputError(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = alloca [500 x i8]
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%10 = call i32 @vsnprintf(i8* %8, i32 500, i8* %0, i32 %1)
%11 = tail call i8* @strerror(i32 %2)
%12 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 500, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 500, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %8)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
ret void
}