#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 **sys_errlist;
int sys_nerr;
char *SysErrorMsg(int n) {
  char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
  return (s ? s : "no such error");
}


x86 assembly (clang, -O0):
<SysErrorMsg>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     113e <SysErrorMsg+0x3e>
mov    -0x4(%rbp),%eax
mov    0x2ecd(%rip),%rcx
cmp    (%rcx),%eax
jge    113e <SysErrorMsg+0x3e>
mov    0x2ece(%rip),%rax
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
jmp    114e <SysErrorMsg+0x4e>
lea    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    114e <SysErrorMsg+0x4e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116e <SysErrorMsg+0x6e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    117e <SysErrorMsg+0x7e>
lea    0xe99(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    117e <SysErrorMsg+0x7e>
mov    -0x20(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<SysErrorMsg>:
lea    0xef9(%rip),%rcx
test   %edi,%edi
js     1126 <SysErrorMsg+0x26>
mov    0x2ed6(%rip),%rax
cmp    %edi,(%rax)
jle    1126 <SysErrorMsg+0x26>
mov    0x2edb(%rip),%rax
mov    (%rax),%rax
mov    %edi,%ecx
mov    (%rax,%rcx,8),%rcx
test   %rcx,%rcx
lea    0xede(%rip),%rax
cmovne %rcx,%rax
ret

LLVM IR (-O0):
@sys_nerr = global i32 0
@sys_errlist = global i8** null
@.str = [14 x i8] c"unknown error\00"
@.str.1 = [14 x i8] c"no such error\00"
define i8* @SysErrorMsg(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %1
%7 = load i32, i32* %2
%8 = load i32, i32* @sys_nerr
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i8**, i8*** @sys_errlist
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
br label %17
16: ; preds = %6, %1
br label %17
17: ; preds = %16, %10
%18 = phi i8* [ %15, %10 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %16 ]
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8*, i8** %3
br label %24
23: ; preds = %17
br label %24
24: ; preds = %23, %21
%25 = phi i8* [ %22, %21 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %23 ]
ret i8* %25
}

LLVM IR (-O2):
@sys_nerr = global i32 0
@sys_errlist = global i8** null
@.str = [14 x i8] c"unknown error\00"
@.str.1 = [14 x i8] c"no such error\00"
define i8* @SysErrorMsg(i32 %0) {
%2 = icmp sgt i32 %0, -1
%3 = load i32, i32* @sys_nerr
%4 = icmp sgt i32 %3, %0
%5 = select i1 %2, i1 %4, i1 false
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i8**, i8*** @sys_errlist
%8 = zext i32 %0 to i64
%9 = getelementptr inbounds i8*, i8** %7, i64 %8
%10 = load i8*, i8** %9
br label %11
11: ; preds = %1, %6
%12 = phi i8* [ %10, %6 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ]
%13 = icmp eq i8* %12, null
%14 = select i1 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %12
ret i8* %14
}