#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 */
char *easy_printf(char *, size_t, char *, int /*<<< orphan*/);
char *easy_printf_unknown_helper(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
int strlen(char *);
int /*<<< orphan*/ write_error(char *);
void write_error_with_error_number_var_helper(const char *error_message,
                                              va_list va) {
  char *temp_error = easy_printf_unknown_helper(error_message, va);
  size_t size = strlen("%s - ERROR NUMBER: %d") + strlen(temp_error) + 5;
  char *error = easy_printf("%s - ERROR NUMBER: %d", size, temp_error, errno);
  free(temp_error);
  write_error(error);
  free(error);
}


x86 assembly (clang, -O0):
<write_error_with_error_number_var_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <easy_printf_unknown_helper@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x5,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x2e3a(%rip),%rax
mov    (%rax),%ecx
lea    0xe51(%rip),%rdi
call   1060 <easy_printf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1070 <write_error@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_error_with_error_number_var_helper>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
call   1040 <easy_printf_unknown_helper@plt>
mov    %rax,%r12
lea    0xe99(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1050 <strlen@plt>
add    %r15d,%eax
add    $0x5,%eax
movslq %eax,%rsi
mov    0x2e56(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %r12,%rdx
call   1060 <easy_printf@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1070 <write_error@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"%s - ERROR NUMBER: %d\00"
@errno = global i32 0
define void @write_error_with_error_number_var_helper(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i8* @easy_printf_unknown_helper(i8* %8, i32 %9)
store i8* %10, i8** %5
%11 = call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = add nsw i32 %14, 5
%16 = sext i32 %15 to i64
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = load i8*, i8** %5
%19 = load i32, i32* @errno
%20 = call i8* @easy_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %17, i8* %18, i32 %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
%23 = load i8*, i8** %7
%24 = call i32 @write_error(i8* %23)
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s - ERROR NUMBER: %d\00"
@errno = global i32 0
define void @write_error_with_error_number_var_helper(i8* %0, i32 %1) {
%3 = tail call i8* @easy_printf_unknown_helper(i8* %0, i32 %1)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %3)
%6 = add i32 %4, 5
%7 = add i32 %6, %5
%8 = sext i32 %7 to i64
%9 = load i32, i32* @errno
%10 = tail call i8* @easy_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %8, i8* %3, i32 %9)
%11 = tail call i32 @free(i8* %3)
%12 = tail call i32 @write_error(i8* %10)
%13 = tail call i32 @free(i8* %10)
ret void
}