#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 /*<<< orphan*/ abort();
int /*<<< orphan*/ printf(char *, unsigned long, ...);
int /*<<< orphan*/ psx_read(char const *, unsigned long, int);
int psx_read_frame(const char *spi_device, unsigned long block,
                   unsigned long frame) {
  if (!(block < 16)) {
    printf("psx_read_frame() not a block No. : %ld", block);
    abort();
  }
  if (!(frame < 64)) {
    printf("psx_read_frame() not a frame No. : %ld", frame);
    abort();
  }
  printf("psx_read_frame() block %ld, frame %ld\n", block, frame);
  psx_read(spi_device, block * 8 * 1024 + frame * 128, 128);
}


x86 assembly (clang, -O0):
<psx_read_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x10,-0x18(%rbp)
jb     1168 <psx_read_frame+0x38>
mov    -0x18(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
cmpq   $0x40,-0x20(%rbp)
jb     118c <psx_read_frame+0x5c>
mov    -0x20(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
shl    $0x3,%rsi
shl    $0xa,%rsi
mov    -0x20(%rbp),%rax
shl    $0x7,%rax
add    %rax,%rsi
mov    $0x80,%edx
call   1050 <psx_read@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psx_read_frame>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x10,%rsi
jae    117e <psx_read_frame+0x4e>
mov    %rdx,%rbx
cmp    $0x40,%rdx
jae    118a <psx_read_frame+0x5a>
mov    %rdi,%r15
lea    0xefd(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
shl    $0xd,%r14
shl    $0x7,%rbx
add    %r14,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x80,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <psx_read@plt>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
jmp    1194 <psx_read_frame+0x64>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"psx_read_frame() not a block No. : %ld\00"
@.str.1 = [39 x i8] c"psx_read_frame() not a frame No. : %ld\00"
@.str.2 = [39 x i8] c"psx_read_frame() block %ld, frame %ld\0A\00"
define i32 @psx_read_frame(i8* %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %6
%9 = icmp ult i64 %8, 16
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i64, i64* %6
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %3
%15 = load i64, i64* %7
%16 = icmp ult i64 %15, 64
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i64, i64* %7
%19 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %14
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i64 %22, i64 %23)
%25 = load i8*, i8** %5
%26 = load i64, i64* %6
%27 = mul i64 %26, 8
%28 = mul i64 %27, 1024
%29 = load i64, i64* %7
%30 = mul i64 %29, 128
%31 = add i64 %28, %30
%32 = call i32 @psx_read(i8* %25, i64 %31, i32 128)
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [39 x i8] c"psx_read_frame() not a block No. : %ld\00"
@.str.1 = [39 x i8] c"psx_read_frame() not a frame No. : %ld\00"
@.str.2 = [39 x i8] c"psx_read_frame() block %ld, frame %ld\0A\00"
define i32 @psx_read_frame(i8* %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %1, 16
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %1)
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %3
%9 = icmp ult i64 %2, 64
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %2)
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %8
%14 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i64 %1, i64 %2)
%15 = shl nuw nsw i64 %1, 13
%16 = shl nuw nsw i64 %2, 7
%17 = add nuw nsw i64 %16, %15
%18 = tail call i32 @psx_read(i8* %0, i64 %17, i32 128)
ret i32 undef
}