#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int,
                            char const *, char *);
int /*<<< orphan*/ stdout;
char *strerror(int);
void str_error(int errnum, const char *file, int line, const char *func) {
  int size = 256;
  char *err;
  char buf[size * 2];
  err = strerror(errnum);
  snprintf(buf, size * 2, "[ERROR] %s:%i at %s(): %s", file, line, func, err);
  printf("%s\n", buf);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<str_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x100,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%esi
shl    $0x1,%esi
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    -0x30(%rbp),%rax
lea    0xe4e(%rip),%rdx
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
mov    -0x48(%rbp),%rsi
add    $0x10,%rsp
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_error>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
call   1060 <strerror@plt>
mov    %rax,(%rsp)
lea    0xe9b(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %r14,%r9
call   1040 <snprintf@plt>
lea    0xe93(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"[ERROR] %s:%i at %s(): %s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
define void @str_error(i32 %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 256, i32* %9
%13 = load i32, i32* %9
%14 = mul nsw i32 %13, 2
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca i8, i64 %15
store i64 %15, i64* %12
%18 = load i32, i32* %5
%19 = call i8* @strerror(i32 %18)
store i8* %19, i8** %10
%20 = load i32, i32* %9
%21 = mul nsw i32 %20, 2
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load i8*, i8** %8
%25 = load i8*, i8** %10
%26 = call i32 @snprintf(i8* %17, i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23, i8* %24, i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = load i8*, i8** %11
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"[ERROR] %s:%i at %s(): %s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
define void @str_error(i32 %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%7 = tail call i8* @strerror(i32 %0)
%8 = call i32 @snprintf(i8* %6, i32 512, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i8* %3, i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
ret void
}