#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int ld_enc_ieeeff(char *ieee_fn, float *farr, int elements, char *errmsg) {
  char *func = "ld_enc_ieeeff";
  FILE *infile = 0;
  int stat = 0;
  {};
  if (farr == NULL) {
    {};
    sprintf(errmsg, "%s:  unexpected null Float array\n", func);
    stat = 3;
    goto BYE;
  }
  infile = fopen(ieee_fn, "r");
  if (infile == NULL) {
    {};
    sprintf(errmsg, "%s: Failed to open %s\n", func, ieee_fn);
    stat = 1;
    goto BYE;
  }
  {};
  if (fread(farr, sizeof(float), elements, infile) != elements) {
    {};
    sprintf(errmsg, "%s: failed to load %s (expecting %d float elements)\n",
            func, ieee_fn, elements);
    stat = 2;
  } else {
  };
BYE:
  if (infile)
    fclose(infile);
  {};
  return (stat);
}


x86 assembly (clang, -O0):
<ld_enc_ieeeff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <ld_enc_ieeeff+0x5e>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x3,-0x34(%rbp)
jmp    1235 <ld_enc_ieeeff+0xf5>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e3 <ld_enc_ieeeff+0xa3>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x1,-0x34(%rbp)
jmp    1235 <ld_enc_ieeeff+0xf5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
call   1030 <fread@plt>
cmp    -0x14(%rbp),%eax
je     122b <ld_enc_ieeeff+0xeb>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x2,-0x34(%rbp)
jmp    1230 <ld_enc_ieeeff+0xf0>
jmp    1230 <ld_enc_ieeeff+0xf0>
jmp    1235 <ld_enc_ieeeff+0xf5>
cmpq   $0x0,-0x30(%rbp)
je     1249 <ld_enc_ieeeff+0x109>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ld_enc_ieeeff>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
test   %rsi,%rsi
je     11b4 <ld_enc_ieeeff+0x74>
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xed0(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d3 <ld_enc_ieeeff+0x93>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %r12d,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
xor    %ebp,%ebp
cmp    %r12d,%eax
je     11aa <ld_enc_ieeeff+0x6a>
lea    0xebb(%rip),%rsi
lea    0xe6b(%rip),%rdx
mov    %r14,%rdi
mov    %r15,%rcx
mov    %r12d,%r8d
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    $0x2,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11f3 <ld_enc_ieeeff+0xb3>
lea    0xe53(%rip),%rsi
lea    0xe3e(%rip),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    $0x3,%ebp
jmp    11f3 <ld_enc_ieeeff+0xb3>
lea    0xe58(%rip),%rsi
lea    0xe1f(%rip),%rdx
mov    %r14,%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"ld_enc_ieeeff\00"
@.str.1 = [34 x i8] c"%s: unexpected null Float array\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"%s: Failed to open %s\0A\00"
@.str.4 = [53 x i8] c"%s: failed to load %s (expecting %d float elements)\0A\00"
define i32 @ld_enc_ieeeff(i8* %0, float* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
store i8* %0, i8** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %9
store i32* null, i32** %10
store i32 0, i32* %11
%12 = load float*, float** %6
%13 = icmp eq float* %12, null
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 3, i32* %11
br label %43
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %10
%21 = load i32*, i32** %10
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = load i8*, i8** %5
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %25, i8* %26)
store i32 1, i32* %11
br label %43
28: ; preds = %18
%29 = load float*, float** %6
%30 = load i32, i32* %7
%31 = load i32*, i32** %10
%32 = call i32 @fread(float* %29, i32 4, i32 %30, i32* %31)
%33 = load i32, i32* %7
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %28
%36 = load i8*, i8** %8
%37 = load i8*, i8** %9
%38 = load i8*, i8** %5
%39 = load i32, i32* %7
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %37, i8* %38, i32 %39)
store i32 2, i32* %11
br label %42
41: ; preds = %28
br label %42
42: ; preds = %41, %35
br label %43
43: ; preds = %42, %23, %14
%44 = load i32*, i32** %10
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32*, i32** %10
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* %11
ret i32 %50
}

LLVM IR (-O2):
@.str = [14 x i8] c"ld_enc_ieeeff\00"
@.str.1 = [34 x i8] c"%s: unexpected null Float array\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"%s: Failed to open %s\0A\00"
@.str.4 = [53 x i8] c"%s: failed to load %s (expecting %d float elements)\0A\00"
define i32 @ld_enc_ieeeff(i8* %0, float* %1, i32 %2, i8* nocapture writeonly %3) {
%5 = icmp eq float* %1, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
8: ; preds = %4
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %21
13: ; preds = %8
%14 = tail call i32 @fread(float* %1, i32 4, i32 %2, i32* %9)
%15 = icmp eq i32 %14, %2
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
br label %18
18: ; preds = %13, %16
%19 = phi i32 [ 2, %16 ], [ 0, %13 ]
%20 = tail call i32 @fclose(i32* %9)
br label %21
21: ; preds = %11, %6, %18
%22 = phi i32 [ %19, %18 ], [ 1, %11 ], [ 3, %6 ]
ret i32 %22
}