#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 */
#define EACCES 137
#define EAGAIN 136
#define EBADF 135
#define EINVAL 134
#define ENFILE 133
#define ENODEV 132
#define ENOMEM 131
#define EOVERFLOW 130
#define EPERM 129
#define ETXTBSY 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int parse_error(void *rc) {
  intptr_t irc = (intptr_t)rc;
  switch (irc) {
  case EACCES:
    fprintf(stderr,
            "A file descriptor refers to a non-regular file.  Or a file "
            "mapping was requested, but fd is not open for reading.  Or "
            "MAP_SHARED was requested and PROT_WRITE is set, but fd is not "
            "open in read/write (O_RDWR) mode.  Or PROT_WRITE is set, but "
            "the file is append-only.\n");
    return 1;
    break;
  case EAGAIN:
    fprintf(stderr,
            "The file has been locked, or too much memory has been locked"
            "(see setrlimit(2)).\n");
    return 1;
    break;
  case EBADF:
    fprintf(
        stderr,
        "fd is not a valid file descriptor (and MAP_ANONYMOUS was not set\n");
    return 1;
    break;
  case EINVAL:
    fprintf(stderr, "We don't like addr, length, or offset (e.g., they are too "
                    "large, or not aligned on a page boundary).\n");
    return 1;
    break;
  case ENFILE:
    fprintf(stderr, "The system-wide limit on the total number of open files "
                    "has been reached.\n");
    return 1;
    break;
  case ENODEV:
    fprintf(stderr, "The underlying filesystem of the specified file does not "
                    "support memory mapping.\n");
    return 1;
    break;
  case ENOMEM:
    fprintf(stderr, "No memory is available.\n");
    return 1;
    break;
  case EPERM:
    fprintf(stderr,
            "The prot argument asks for PROT_EXEC but the mapped area"
            "belongs to a file on a filesystem that was mounted no-exec.\n");
    return 1;
    break;
  case ETXTBSY:
    fprintf(stderr, "MAP_DENYWRITE was set but the object specified by fd is "
                    "open for writing.\n");
    return 1;
    break;
  case EOVERFLOW:
    fprintf(stderr,
            "On 32-bit architecture together with the large file extension "
            "(i.e., using 64-bit off_t): the number of pages used for "
            "length plus number of pages used for offset would overflow "
            "unsigned long (32 bits).\n");
    return 1;
    break;
  default:
    return 0;
    break;
  }
}


x86 assembly (clang, -O0):
<parse_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffff80,%rax
mov    %rax,-0x20(%rbp)
sub    $0x9,%rax
ja     1298 <parse_error+0x188>
mov    -0x20(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xeca(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xfb4(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xfe4(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0x1005(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0x104a(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0x1074(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0x10a5(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0x109d(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0x10f1(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0x111b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129f <parse_error+0x18f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_error>:
add    $0xffffffffffffff80,%rdi
xor    %eax,%eax
cmp    $0x9,%rdi
ja     1142 <parse_error+0x32>
push   %rax
lea    0x1324(%rip),%rax
movslq (%rax,%rdi,4),%rsi
add    %rax,%rsi
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [267 x i8] c"A file descriptor refers to a non-regular file. Or a file mapping was requested, but fd is not open for reading. Or MAP_SHARED was requested and PROT_WRITE is set, but fd is not open in read/write (O_RDWR) mode. Or PROT_WRITE is set, but the file is append-only.\0A\00"
@.str.1 = [81 x i8] c"The file has been locked, or too much memory has been locked(see setrlimit(2)).\0A\00"
@.str.2 = [66 x i8] c"fd is not a valid file descriptor (and MAP_ANONYMOUS was not set\0A\00"
@.str.3 = [102 x i8] c"We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).\0A\00"
@.str.4 = [75 x i8] c"The system-wide limit on the total number of open files has been reached.\0A\00"
@.str.5 = [82 x i8] c"The underlying filesystem of the specified file does not support memory mapping.\0A\00"
@.str.6 = [25 x i8] c"No memory is available.\0A\00"
@.str.7 = [117 x i8] c"The prot argument asks for PROT_EXEC but the mapped areabelongs to a file on a filesystem that was mounted no-exec.\0A\00"
@.str.8 = [75 x i8] c"MAP_DENYWRITE was set but the object specified by fd is open for writing.\0A\00"
@.str.9 = [204 x i8] c"On 32-bit architecture together with the large file extension (i.e., using 64-bit off_t): the number of pages used for length plus number of pages used for offset would overflow unsigned long (32 bits).\0A\00"
define i32 @parse_error(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = ptrtoint i8* %5 to i64
store i64 %6, i64* %4
%7 = load i64, i64* %4
switch i64 %7, label %38 [
i64 137, label %8
i64 136, label %11
i64 135, label %14
i64 134, label %17
i64 133, label %20
i64 132, label %23
i64 131, label %26
i64 129, label %29
i64 128, label %32
i64 130, label %35
]
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([267 x i8], [267 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %39
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %39
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %39
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %39
20: ; preds = %1
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %39
23: ; preds = %1
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %39
26: ; preds = %1
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %39
29: ; preds = %1
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %2
br label %39
32: ; preds = %1
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %39
35: ; preds = %1
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([204 x i8], [204 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %2
br label %39
38: ; preds = %1
store i32 0, i32* %2
br label %39
39: ; preds = %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [267 x i8] c"A file descriptor refers to a non-regular file. Or a file mapping was requested, but fd is not open for reading. Or MAP_SHARED was requested and PROT_WRITE is set, but fd is not open in read/write (O_RDWR) mode. Or PROT_WRITE is set, but the file is append-only.\0A\00"
@.str.1 = [81 x i8] c"The file has been locked, or too much memory has been locked(see setrlimit(2)).\0A\00"
@.str.2 = [66 x i8] c"fd is not a valid file descriptor (and MAP_ANONYMOUS was not set\0A\00"
@.str.3 = [102 x i8] c"We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).\0A\00"
@.str.4 = [75 x i8] c"The system-wide limit on the total number of open files has been reached.\0A\00"
@.str.5 = [82 x i8] c"The underlying filesystem of the specified file does not support memory mapping.\0A\00"
@.str.6 = [25 x i8] c"No memory is available.\0A\00"
@.str.7 = [117 x i8] c"The prot argument asks for PROT_EXEC but the mapped areabelongs to a file on a filesystem that was mounted no-exec.\0A\00"
@.str.8 = [75 x i8] c"MAP_DENYWRITE was set but the object specified by fd is open for writing.\0A\00"
@.str.9 = [204 x i8] c"On 32-bit architecture together with the large file extension (i.e., using 64-bit off_t): the number of pages used for length plus number of pages used for offset would overflow unsigned long (32 bits).\0A\00"
@reltable.parse_error = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([75 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([117 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([204 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([82 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([75 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([102 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([66 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([81 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([267 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.parse_error to i64)) to i32)]
define i32 @parse_error(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = add i64 %2, -128
%4 = icmp ult i64 %3, 10
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = shl i64 %3, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.parse_error to i8*), i64 %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* %7)
br label %10
10: ; preds = %1, %5
%11 = phi i32 [ 0, %1 ], [ 1, %5 ]
ret i32 %11
}