#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 size_t loff_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int lseek64(int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ merror(char *);
int /*<<< orphan*/ read_block(int, char *, size_t);
void read_into(int fd, int block_id, char *block, size_t block_size) {
  if (lseek64(fd, (loff_t)block_id * block_size, SEEK_SET) == -1) {
    merror("Seeking before reading a block");
  }
  read_block(fd, block, block_size);
}


x86 assembly (clang, -O0):
<read_into>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
movslq -0x8(%rbp),%rsi
imul   -0x18(%rbp),%rsi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
call   1030 <lseek64@plt>
cmp    $0xffffffff,%eax
jne    1175 <read_into+0x45>
lea    0xe90(%rip),%rdi
call   1040 <merror@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <read_block@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_into>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %edi,%ebp
movslq %esi,%rsi
imul   %rcx,%rsi
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
call   1030 <lseek64@plt>
cmp    $0xffffffff,%eax
jne    1162 <read_into+0x32>
lea    0xea3(%rip),%rdi
call   1040 <merror@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <read_block@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [31 x i8] c"Seeking before reading a block\00"
define void @read_into(i32 %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = load i64, i64* %8
%13 = mul i64 %11, %12
%14 = load i32, i32* @SEEK_SET
%15 = call i32 @lseek64(i32 %9, i64 %13, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = call i32 @merror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %4
%20 = load i32, i32* %5
%21 = load i8*, i8** %7
%22 = load i64, i64* %8
%23 = call i32 @read_block(i32 %20, i8* %21, i64 %22)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [31 x i8] c"Seeking before reading a block\00"
define void @read_into(i32 %0, i32 %1, i8* %2, i64 %3) {
%5 = sext i32 %1 to i64
%6 = mul i64 %5, %3
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @lseek64(i32 %0, i64 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @merror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
%13 = tail call i32 @read_block(i32 %0, i8* %2, i64 %3)
ret void
}