#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*/ EACCES;
int /*<<< orphan*/ ENOENT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  fprintf(stderr, "EACCES: %s\n", (char *)strerror(EACCES));
  errno = ENOENT;
  printf("-----------\n");
  perror(argv[0]);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%ecx
mov    0x2e2e(%rip),%rax
mov    %ecx,(%rax)
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <perror@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2e7b(%rip),%rax
mov    (%rax),%ebp
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe8c(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    0x2e42(%rip),%rcx
mov    %eax,(%rcx)
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rdi
call   1050 <perror@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"EACCES: %s\0A\00"
@EACCES = global i32 0
@ENOENT = global i32 0
@errno = global i32 0
@.str.1 = [13 x i8] c"-----------\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @stderr
%7 = load i32, i32* @EACCES
%8 = call i64 @strerror(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @ENOENT
store i32 %11, i32* @errno
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @perror(i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"EACCES: %s\0A\00"
@EACCES = global i32 0
@ENOENT = global i32 0
@errno = global i32 0
@str = [12 x i8] c"-----------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @stderr
%4 = load i32, i32* @EACCES
%5 = tail call i64 @strerror(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @ENOENT
store i32 %8, i32* @errno
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%10 = load i8*, i8** %1
%11 = tail call i32 @perror(i8* %10)
%12 = tail call i32 @exit(i32 0)
unreachable
}