#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*/ EXIT_FAILURE;
double *alloc_doubles(unsigned int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
size_t fread(double *, int, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
double *read_doubles(unsigned card, FILE *f) {
  double *val;
  size_t nbyte;
  val = alloc_doubles(card);
  nbyte = fread(val, sizeof(double), card, f);
  if (nbyte != card * sizeof(double)) {
    printf("fatal error: input size mismatches description. exit.");
    exit(EXIT_FAILURE);
  }
  return val;
}


x86 assembly (clang, -O0):
<read_doubles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <alloc_doubles@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x8,%esi
call   1030 <fread@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x3,%rcx
cmp    %rcx,%rax
je     11a2 <read_doubles+0x62>
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_doubles>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
call   1040 <alloc_doubles@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x8,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %ebp,%ecx
shl    $0x3,%rcx
cmp    %rcx,%rax
jne    1176 <read_doubles+0x36>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"fatal error: input size mismatches description. exit.\00"
@EXIT_FAILURE = global i32 0
define double* @read_doubles(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca double*
%6 = alloca i64
store i32 %0, i32* %3
store i32* %1, i32** %4
%7 = load i32, i32* %3
%8 = call double* @alloc_doubles(i32 %7)
store double* %8, double** %5
%9 = load double*, double** %5
%10 = load i32, i32* %3
%11 = load i32*, i32** %4
%12 = call i64 @fread(double* %9, i32 8, i32 %10, i32* %11)
store i64 %12, i64* %6
%13 = load i64, i64* %6
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = icmp ne i64 %13, %16
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load double*, double** %5
ret double* %23
}

LLVM IR (-O2):
@.str = [54 x i8] c"fatal error: input size mismatches description. exit.\00"
@EXIT_FAILURE = global i32 0
define double* @read_doubles(i32 %0, i32* nocapture %1) {
%3 = tail call double* @alloc_doubles(i32 %0)
%4 = tail call i64 @fread(double* %3, i32 8, i32 %0, i32* %1)
%5 = zext i32 %0 to i64
%6 = shl nuw nsw i64 %5, 3
%7 = icmp eq i64 %4, %6
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
ret double* %3
}