#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 */
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
#define EBADF 133
#define EFBIG 132
#define EINVAL 131
#define ENODEV 130
#define ENOSPC 129
#define ESPIPE 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int posix_fallocate(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void posix_fallocate_or_exit(int fd, off_t offset, off_t length) {
  int result = 0;
  result = posix_fallocate(fd, offset, length);
  switch (result) {
  case EBADF:
    fprintf(stderr,
            "Not a valid file descriptor, or not opened for writing.\n");
    break;
  case EFBIG:
    fprintf(stderr, "Offset + length > maximum file size.\n");
    break;
  case EINVAL:
    fprintf(stderr, "Offset was < 0, or length was <= 0.\n");
    break;
  case ENODEV:
    fprintf(stderr, "Not a regular file.\n");
    break;
  case ENOSPC:
    fprintf(stderr, "No space left on device.\n");
    break;
  case ESPIPE:
    fprintf(stderr, "How did a pipe get in here?\n");
    break;
  case 0:
  default:
    return;
  }
  exit(4);
}


x86 assembly (clang, -O0):
<posix_fallocate_or_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <posix_fallocate@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     127a <posix_fallocate_or_exit+0x14a>
jmp    116c <posix_fallocate_or_exit+0x3c>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     1260 <posix_fallocate_or_exit+0x130>
jmp    117f <posix_fallocate_or_exit+0x4f>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1246 <posix_fallocate_or_exit+0x116>
jmp    1192 <posix_fallocate_or_exit+0x62>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
je     122c <posix_fallocate_or_exit+0xfc>
jmp    11a5 <posix_fallocate_or_exit+0x75>
mov    -0x14(%rbp),%eax
sub    $0x83,%eax
je     1212 <posix_fallocate_or_exit+0xe2>
jmp    11b8 <posix_fallocate_or_exit+0x88>
mov    -0x14(%rbp),%eax
sub    $0x84,%eax
je     11f8 <posix_fallocate_or_exit+0xc8>
jmp    11cb <posix_fallocate_or_exit+0x9b>
mov    -0x14(%rbp),%eax
sub    $0x85,%eax
jne    127f <posix_fallocate_or_exit+0x14f>
jmp    11de <posix_fallocate_or_exit+0xae>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <posix_fallocate_or_exit+0x155>
jmp    127f <posix_fallocate_or_exit+0x14f>
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x4,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<posix_fallocate_or_exit>:
push   %rax
call   1040 <posix_fallocate@plt>
add    $0xffffff80,%eax
cmp    $0x6,%eax
jb     1140 <posix_fallocate_or_exit+0x10>
pop    %rax
ret
cltq
lea    0xf87(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"Not a valid file descriptor, or not opened for writing.\0A\00"
@.str.1 = [38 x i8] c"Offset + length > maximum file size.\0A\00"
@.str.2 = [37 x i8] c"Offset was < 0, or length was <= 0.\0A\00"
@.str.3 = [21 x i8] c"Not a regular file.\0A\00"
@.str.4 = [26 x i8] c"No space left on device.\0A\00"
@.str.5 = [29 x i8] c"How did a pipe get in here?\0A\00"
define void @posix_fallocate_or_exit(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @posix_fallocate(i32 %8, i32 %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
switch i32 %12, label %32 [
i32 133, label %13
i32 132, label %16
i32 131, label %19
i32 130, label %22
i32 129, label %25
i32 128, label %28
i32 0, label %31
]
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %33
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %33
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %33
22: ; preds = %3
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %33
25: ; preds = %3
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %33
28: ; preds = %3
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %33
31: ; preds = %3
br label %32
32: ; preds = %3, %31
ret void
33: ; preds = %28, %25, %22, %19, %16, %13
%34 = call i32 @exit(i32 4)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"Not a valid file descriptor, or not opened for writing.\0A\00"
@.str.1 = [38 x i8] c"Offset + length > maximum file size.\0A\00"
@.str.2 = [37 x i8] c"Offset was < 0, or length was <= 0.\0A\00"
@.str.3 = [21 x i8] c"Not a regular file.\0A\00"
@.str.4 = [26 x i8] c"No space left on device.\0A\00"
@.str.5 = [29 x i8] c"How did a pipe get in here?\0A\00"
@reltable.posix_fallocate_or_exit = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([57 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.posix_fallocate_or_exit to i64)) to i32)]
define void @posix_fallocate_or_exit(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @posix_fallocate(i32 %0, i32 %1, i32 %2)
%5 = add i32 %4, -128
%6 = icmp ult i32 %5, 6
br i1 %6, label %8, label %7
7: ; preds = %3
ret void
8: ; preds = %3
%9 = sext i32 %5 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.posix_fallocate_or_exit to i8*), i64 %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* %11)
%14 = tail call i32 @exit(i32 4)
unreachable
}