#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 138
#define EAGAIN 137
#define EBUSY 136
#define EFBIG 135
#define EINTR 134
#define EIO 133
#define EISDIR 132
#define ENOENT 131
#define ENOSPC 130
#define EROFS 129
#define ETXTBSY 128
int errno;
int /*<<< orphan*/ set_status_err(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void fileset_status(int errsv) {
  switch (errsv) {
  case ENOENT:
    set_status_err("No such file or directory");
    break;
  case EINTR:
    set_status_err("Interrupted system call");
    break;
  case EIO:
    set_status_err("I/O error");
    break;
  case EAGAIN:
    set_status_err("Try again");
    break;
  case EACCES:
    set_status_err("Permission denied");
    break;
  case EBUSY:
    set_status_err("Resource busy");
    break;
  case EISDIR:
    set_status_err("Is a directory");
    break;
  case ETXTBSY:
    set_status_err("Text file busy");
    break;
  case EFBIG:
    set_status_err("File too large");
    break;
  case ENOSPC:
    set_status_err("No space left on device");
    break;
  case EROFS:
    set_status_err("Read-only file system");
    break;
  default:;
    char temp_status[46];
    for (int i = 0; i < 46; i += 1) {
      temp_status[i] = '\0';
    }
    sprintf(temp_status, "Error %i, consult internet", errno);
    set_status_err(temp_status);
    break;
  }
}


x86 assembly (clang, -O0):
<fileset_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0xa,%eax
ja     120f <fileset_status+0xef>
mov    -0x50(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed1(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xeda(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xee1(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xeda(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xed3(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xed4(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xed1(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xecf(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xecd(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xecb(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
lea    0xed2(%rip),%rdi
call   1040 <set_status_err@plt>
jmp    1259 <fileset_status+0x139>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2e,-0x44(%rbp)
jge    1237 <fileset_status+0x117>
movslq -0x44(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1216 <fileset_status+0xf6>
lea    -0x40(%rbp),%rdi
mov    0x2d9e(%rip),%rax
mov    (%rax),%edx
lea    0xea2(%rip),%rsi
call   1030 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <set_status_err@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fileset_status>:
push   %rbx
sub    $0x30,%rsp
add    $0xffffff80,%edi
cmp    $0xa,%edi
ja     1149 <fileset_status+0x29>
lea    0xecc(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf5d(%rip),%rdi
jmp    11db <fileset_status+0xbb>
xorps  %xmm0,%xmm0
movups %xmm0,0x1e(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
lea    0xf83(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <set_status_err@plt>
add    $0x30,%rsp
pop    %rbx
ret
lea    0xf4d(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xf2c(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xe90(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xeed(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xeb0(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xe8f(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xef0(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xebb(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xe96(%rip),%rdi
jmp    11db <fileset_status+0xbb>
lea    0xe97(%rip),%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1040 <set_status_err@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"No such file or directory\00"
@.str.1 = [24 x i8] c"Interrupted system call\00"
@.str.2 = [10 x i8] c"I/O error\00"
@.str.3 = [10 x i8] c"Try again\00"
@.str.4 = [18 x i8] c"Permission denied\00"
@.str.5 = [14 x i8] c"Resource busy\00"
@.str.6 = [15 x i8] c"Is a directory\00"
@.str.7 = [15 x i8] c"Text file busy\00"
@.str.8 = [15 x i8] c"File too large\00"
@.str.9 = [24 x i8] c"No space left on device\00"
@.str.10 = [22 x i8] c"Read-only file system\00"
@.str.11 = [27 x i8] c"Error %i, consult internet\00"
@errno = global i32 0
define void @fileset_status(i32 %0) {
%2 = alloca i32
%3 = alloca [46 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
switch i32 %5, label %28 [
i32 131, label %6
i32 134, label %8
i32 133, label %10
i32 137, label %12
i32 138, label %14
i32 136, label %16
i32 132, label %18
i32 128, label %20
i32 135, label %22
i32 130, label %24
i32 129, label %26
]
6: ; preds = %1
%7 = call i32 @set_status_err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %45
8: ; preds = %1
%9 = call i32 @set_status_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %45
10: ; preds = %1
%11 = call i32 @set_status_err(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %45
12: ; preds = %1
%13 = call i32 @set_status_err(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %45
14: ; preds = %1
%15 = call i32 @set_status_err(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %45
16: ; preds = %1
%17 = call i32 @set_status_err(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %45
18: ; preds = %1
%19 = call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %45
20: ; preds = %1
%21 = call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %45
22: ; preds = %1
%23 = call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %45
24: ; preds = %1
%25 = call i32 @set_status_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %45
26: ; preds = %1
%27 = call i32 @set_status_err(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %45
28: ; preds = %1
store i32 0, i32* %4
br label %29
29: ; preds = %36, %28
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 46
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [46 x i8], [46 x i8]* %3, i64 0, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %32
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %29
39: ; preds = %29
%40 = getelementptr inbounds [46 x i8], [46 x i8]* %3, i64 0, i64 0
%41 = load i32, i32* @errno
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [46 x i8], [46 x i8]* %3, i64 0, i64 0
%44 = call i32 @set_status_err(i8* %43)
br label %45
45: ; preds = %39, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"No such file or directory\00"
@.str.1 = [24 x i8] c"Interrupted system call\00"
@.str.2 = [10 x i8] c"I/O error\00"
@.str.3 = [10 x i8] c"Try again\00"
@.str.4 = [18 x i8] c"Permission denied\00"
@.str.5 = [14 x i8] c"Resource busy\00"
@.str.6 = [15 x i8] c"Is a directory\00"
@.str.7 = [15 x i8] c"Text file busy\00"
@.str.8 = [15 x i8] c"File too large\00"
@.str.9 = [24 x i8] c"No space left on device\00"
@.str.10 = [22 x i8] c"Read-only file system\00"
@.str.11 = [27 x i8] c"Error %i, consult internet\00"
@errno = global i32 0
define void @fileset_status(i32 %0) {
%2 = alloca [46 x i8]
switch i32 %0, label %25 [
i32 131, label %3
i32 134, label %5
i32 133, label %7
i32 137, label %9
i32 138, label %11
i32 136, label %13
i32 132, label %15
i32 128, label %17
i32 135, label %19
i32 130, label %21
i32 129, label %23
]
3: ; preds = %1
%4 = tail call i32 @set_status_err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %31
5: ; preds = %1
%6 = tail call i32 @set_status_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %31
7: ; preds = %1
%8 = tail call i32 @set_status_err(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %31
9: ; preds = %1
%10 = tail call i32 @set_status_err(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %31
11: ; preds = %1
%12 = tail call i32 @set_status_err(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %31
13: ; preds = %1
%14 = tail call i32 @set_status_err(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %31
15: ; preds = %1
%16 = tail call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %31
17: ; preds = %1
%18 = tail call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %31
19: ; preds = %1
%20 = tail call i32 @set_status_err(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %31
21: ; preds = %1
%22 = tail call i32 @set_status_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %31
23: ; preds = %1
%24 = tail call i32 @set_status_err(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %31
25: ; preds = %1
%26 = getelementptr inbounds [46 x i8], [46 x i8]* %2, i64 0, i64 0
%27 = getelementptr inbounds [46 x i8], [46 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* @errno
%29 = call i32 @sprintf(i8* %27, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %28)
%30 = call i32 @set_status_err(i8* %27)
br label %31
31: ; preds = %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
ret void
}