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


x86 assembly (clang, -O0):
<write_error_with_error_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x5,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    0x2e5d(%rip),%rax
mov    (%rax),%ecx
lea    0xe74(%rip),%rdi
call   1050 <easy_printf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <write_error@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_error_with_error_number>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xeb1(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
add    $0x5,%eax
movslq %eax,%rsi
mov    0x2e6e(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <easy_printf@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <write_error@plt>
mov    %rbx,%rdi
pop    %rbx
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(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %5, %7
%9 = add nsw i32 %8, 5
%10 = sext i32 %9 to i64
store i64 %10, i64* %3
%11 = load i64, i64* %3
%12 = load i8*, i8** %2
%13 = load i32, i32* @errno
%14 = call i8* @easy_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %11, i8* %12, i32 %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @write_error(i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
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(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* %0)
%4 = add i32 %2, 5
%5 = add i32 %4, %3
%6 = sext i32 %5 to i64
%7 = load i32, i32* @errno
%8 = tail call i8* @easy_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %6, i8* %0, i32 %7)
%9 = tail call i32 @write_error(i8* %8)
%10 = tail call i32 @free(i8* %8)
ret void
}