#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*/ STDERR_FILENO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
char *strerror(int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char const *, int);
void errexit(const char *prog, const char *reason) {
  char *errstr = strerror(errno);
  write(STDERR_FILENO, prog, strlen(prog));
  write(STDERR_FILENO, ": ", 2);
  write(STDERR_FILENO, reason, strlen(reason));
  write(STDERR_FILENO, ": ", 2);
  write(STDERR_FILENO, errstr, strlen(errstr));
  write(STDERR_FILENO, "\n", 1);
  exit(1);
}


x86 assembly (clang, -O0):
<errexit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<errexit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%r14
mov    0x2e72(%rip),%r12
mov    (%r12),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    (%r12),%edi
lea    0xe77(%rip),%rbx
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    (%r12),%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    (%r12),%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    (%r12),%edi
lea    0xe21(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@STDERR_FILENO = global i32 0
@.str = [3 x i8] c": \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @errexit(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i32, i32* @errno
%7 = call i8* @strerror(i32 %6)
store i8* %7, i8** %5
%8 = load i32, i32* @STDERR_FILENO
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @write(i32 %8, i8* %9, i32 %11)
%13 = load i32, i32* @STDERR_FILENO
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = load i32, i32* @STDERR_FILENO
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @write(i32 %15, i8* %16, i32 %18)
%20 = load i32, i32* @STDERR_FILENO
%21 = call i32 @write(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%22 = load i32, i32* @STDERR_FILENO
%23 = load i8*, i8** %5
%24 = load i8*, i8** %5
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @write(i32 %22, i8* %23, i32 %25)
%27 = load i32, i32* @STDERR_FILENO
%28 = call i32 @write(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%29 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@errno = global i32 0
@STDERR_FILENO = global i32 0
@.str = [3 x i8] c": \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @errexit(i8* %0, i8* %1) {
%3 = load i32, i32* @errno
%4 = tail call i8* @strerror(i32 %3)
%5 = load i32, i32* @STDERR_FILENO
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @write(i32 %5, i8* %0, i32 %6)
%8 = load i32, i32* @STDERR_FILENO
%9 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = load i32, i32* @STDERR_FILENO
%11 = tail call i32 @strlen(i8* %1)
%12 = tail call i32 @write(i32 %10, i8* %1, i32 %11)
%13 = load i32, i32* @STDERR_FILENO
%14 = tail call i32 @write(i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = load i32, i32* @STDERR_FILENO
%16 = tail call i32 @strlen(i8* %4)
%17 = tail call i32 @write(i32 %15, i8* %4, i32 %16)
%18 = load i32, i32* @STDERR_FILENO
%19 = tail call i32 @write(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%20 = tail call i32 @exit(i32 1)
unreachable
}