#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int fread(char *const, unsigned long const, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, unsigned long const, int /*<<< orphan*/);
char read_record(char *const buf, unsigned long const width,
                 unsigned long const item, FILE *stream) {
  if (fseek(stream, item * width, SEEK_SET))
    return 1;
  if (fread(buf, width, 1, stream) != 1)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<read_record>:
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    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
imul   -0x18(%rbp),%rsi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
cmp    $0x0,%rax
je     1166 <read_record+0x46>
movb   $0x1,-0x1(%rbp)
jmp    1192 <read_record+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     118e <read_record+0x6e>
movb   $0x1,-0x1(%rbp)
jmp    1192 <read_record+0x72>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_record>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
imul   %rsi,%rdx
mov    0x2ea7(%rip),%rax
mov    (%rax),%eax
mov    %rcx,%rdi
mov    %rdx,%rsi
mov    %eax,%edx
call   1040 <fseek@plt>
mov    %rax,%rcx
mov    $0x1,%al
test   %rcx,%rcx
jne    116b <read_record+0x4b>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
setne  %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define signext i8 @read_record(i8* %0, i64 %1, i64 %2, i32* %3) {
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i32* %3, i32** %9
%10 = load i32*, i32** %9
%11 = load i64, i64* %8
%12 = load i64, i64* %7
%13 = mul i64 %11, %12
%14 = load i32, i32* @SEEK_SET
%15 = call i64 @fseek(i32* %10, i64 %13, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %4
store i8 1, i8* %5
br label %26
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = load i64, i64* %7
%21 = load i32*, i32** %9
%22 = call i32 @fread(i8* %19, i64 %20, i32 1, i32* %21)
%23 = icmp ne i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %18
store i8 1, i8* %5
br label %26
25: ; preds = %18
store i8 0, i8* %5
br label %26
26: ; preds = %25, %24, %17
%27 = load i8, i8* %5
ret i8 %27
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define signext i8 @read_record(i8* nocapture %0, i64 %1, i64 %2, i32* nocapture %3) {
%5 = mul i64 %2, %1
%6 = load i32, i32* @SEEK_SET
%7 = tail call i64 @fseek(i32* %3, i64 %5, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 @fread(i8* %0, i64 %1, i32 1, i32* %3)
%11 = icmp ne i32 %10, 1
%12 = zext i1 %11 to i8
br label %13
13: ; preds = %9, %4
%14 = phi i8 [ 1, %4 ], [ %12, %9 ]
ret i8 %14
}