#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 IDE_read(unsigned long, void *, unsigned long, unsigned long);
int storage_read(unsigned long storage_number, void *dest,
                 unsigned long LBA_addr, unsigned long n) {
  switch (storage_number) {
  case 0:
    return IDE_read(storage_number, dest, LBA_addr, n);
  case 1:
    return IDE_read(storage_number, dest, LBA_addr, n);
  case 2:
    return IDE_read(storage_number, dest, LBA_addr, n);
  case 3:
    return IDE_read(storage_number, dest, LBA_addr, n);
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<storage_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     11c2 <storage_read+0xb2>
mov    -0x30(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <IDE_read@plt>
mov    %eax,-0x4(%rbp)
jmp    11c9 <storage_read+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <IDE_read@plt>
mov    %eax,-0x4(%rbp)
jmp    11c9 <storage_read+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <IDE_read@plt>
mov    %eax,-0x4(%rbp)
jmp    11c9 <storage_read+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <IDE_read@plt>
mov    %eax,-0x4(%rbp)
jmp    11c9 <storage_read+0xb9>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<storage_read>:
cmp    $0x3,%rdi
ja     111b <storage_read+0xb>
jmp    1030 <IDE_read@plt>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @storage_read(i64 %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
store i64 %0, i64* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
%10 = load i64, i64* %6
switch i64 %10, label %35 [
i64 0, label %11
i64 1, label %17
i64 2, label %23
i64 3, label %29
]
11: ; preds = %4
%12 = load i64, i64* %6
%13 = load i8*, i8** %7
%14 = load i64, i64* %8
%15 = load i64, i64* %9
%16 = call i32 @IDE_read(i64 %12, i8* %13, i64 %14, i64 %15)
store i32 %16, i32* %5
br label %36
17: ; preds = %4
%18 = load i64, i64* %6
%19 = load i8*, i8** %7
%20 = load i64, i64* %8
%21 = load i64, i64* %9
%22 = call i32 @IDE_read(i64 %18, i8* %19, i64 %20, i64 %21)
store i32 %22, i32* %5
br label %36
23: ; preds = %4
%24 = load i64, i64* %6
%25 = load i8*, i8** %7
%26 = load i64, i64* %8
%27 = load i64, i64* %9
%28 = call i32 @IDE_read(i64 %24, i8* %25, i64 %26, i64 %27)
store i32 %28, i32* %5
br label %36
29: ; preds = %4
%30 = load i64, i64* %6
%31 = load i8*, i8** %7
%32 = load i64, i64* %8
%33 = load i64, i64* %9
%34 = call i32 @IDE_read(i64 %30, i8* %31, i64 %32, i64 %33)
store i32 %34, i32* %5
br label %36
35: ; preds = %4
store i32 -1, i32* %5
br label %36
36: ; preds = %35, %29, %23, %17, %11
%37 = load i32, i32* %5
ret i32 %37
}

LLVM IR (-O2):
define i32 @storage_read(i64 %0, i8* %1, i64 %2, i64 %3) {
%5 = icmp ult i64 %0, 4
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @IDE_read(i64 %0, i8* %1, i64 %2, i64 %3)
br label %8
8: ; preds = %4, %6
%9 = phi i32 [ -1, %4 ], [ %7, %6 ]
ret i32 %9
}