#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;
size_t fread(double *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
void sync_read(double *buffer, FILE *fp, size_t size, size_t start) {
  size_t out;
  fseek(fp, start * sizeof(double), SEEK_SET);
  out = fread(buffer, sizeof(double), size, fp);
  if (out != size) {
    printf("[ERROR] "
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/lucasb-eyer/OmicABEL/refs/heads/master/"
           "src/wrappers.c"
           ": Read %d elements - %d expected\n",
           (int)out, (int)size);
  }
  return;
}


x86 assembly (clang, -O0):
<sync_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
shl    $0x3,%rsi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x8,%esi
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11a2 <sync_read+0x72>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sync_read>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x0(,%rcx,8),%rsi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1050 <fseek@plt>
mov    %r15,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    %r14,%rax
jne    1175 <sync_read+0x45>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe84(%rip),%rdi
mov    %eax,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [185 x i8] c"[ERROR] /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lucasb-eyer/OmicABEL/refs/heads/master/src/wrappers.c: Read %d elements - %d expected\0A\00"
define void @sync_read(double* %0, i32* %1, i64 %2, i64 %3) {
%5 = alloca double*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store double* %0, double** %5
store i32* %1, i32** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i32*, i32** %6
%11 = load i64, i64* %8
%12 = mul i64 %11, 8
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %10, i64 %12, i32 %13)
%15 = load double*, double** %5
%16 = load i64, i64* %7
%17 = load i32*, i32** %6
%18 = call i64 @fread(double* %15, i32 8, i64 %16, i32* %17)
store i64 %18, i64* %9
%19 = load i64, i64* %9
%20 = load i64, i64* %7
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %28
22: ; preds = %4
%23 = load i64, i64* %9
%24 = trunc i64 %23 to i32
%25 = load i64, i64* %7
%26 = trunc i64 %25 to i32
%27 = call i32 @printf(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %26)
br label %28
28: ; preds = %22, %4
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [185 x i8] c"[ERROR] /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lucasb-eyer/OmicABEL/refs/heads/master/src/wrappers.c: Read %d elements - %d expected\0A\00"
define void @sync_read(double* nocapture %0, i32* nocapture %1, i64 %2, i64 %3) {
%5 = shl i64 %3, 3
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %1, i64 %5, i32 %6)
%8 = tail call i64 @fread(double* %0, i32 8, i64 %2, i32* %1)
%9 = icmp eq i64 %8, %2
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = trunc i64 %8 to i32
%12 = trunc i64 %2 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
br label %14
14: ; preds = %10, %4
ret void
}