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


x86 assembly (clang, -O0):
<perr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    $0x2,%edi
call   1030 <write@plt>
mov    $0x2,%edx
lea    0xe75(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
mov    $0x2,%edi
call   1030 <write@plt>
mov    $0x2,%edi
lea    0xe44(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<perr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe8a(%rip),%rsi
mov    $0x2,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0x2,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe60(%rip),%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

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

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