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

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int open(char *, int, ...);
scalar_t__ parse_float_array(char *, float *, int);
char *readfile(int);
int /*<<< orphan*/ write_float_array(int, float *, int);
void test_float_array() {
  char *p;
  float a[10];
  int i, fd;
  fd = open("testfile", O_WRONLY | O_CREAT | O_TRUNC, 0666);
  assert(fd > 1 && "Couldn't open file to write test output");
  for (i = 0; i < 10; i++) {
    a[i] = (float)i;
  }
  write_float_array(fd, a, 10);
  close(fd);
  fd = open("testfile", O_RDONLY);
  assert(fd > 1 && "Couldn't open file to read test input");
  p = readfile(fd);
  close(fd);
  assert(parse_float_array(p, a, 10) == 0);
  for (i = 0; i < 10; i++) {
    assert(a[i] == ((float)i));
  }
}


x86 assembly (clang, -O0):
<test_float_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
mov    0x2e80(%rip),%rax
or     (%rax),%esi
mov    0x2e6f(%rip),%rax
or     (%rax),%esi
lea    0xe76(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x38(%rbp)
mov    %al,-0x39(%rbp)
jle    11b2 <test_float_array+0x52>
mov    $0x1,%al
mov    %al,-0x39(%rbp)
jmp    11b2 <test_float_array+0x52>
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11ed <test_float_array+0x8d>
cvtsi2ssl -0x34(%rbp),%xmm0
movslq -0x34(%rbp),%rax
movss  %xmm0,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c6 <test_float_array+0x66>
mov    -0x38(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <write_float_array@plt>
mov    -0x38(%rbp),%edi
call   1050 <close@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x38(%rbp)
mov    %al,-0x3a(%rbp)
jle    1239 <test_float_array+0xd9>
mov    $0x1,%al
mov    %al,-0x3a(%rbp)
jmp    1239 <test_float_array+0xd9>
mov    -0x3a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%edi
call   1080 <readfile@plt>
mov    %rax,-0x8(%rbp)
mov    -0x38(%rbp),%edi
call   1050 <close@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <parse_float_array@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    12c0 <test_float_array+0x160>
movslq -0x34(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
cvtsi2ssl -0x34(%rbp),%xmm1
ucomiss %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1284 <test_float_array+0x124>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_float_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0x2e4f(%rip),%rax
mov    0x2e80(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e6d(%rip),%rax
or     (%rax),%esi
lea    0xeb8(%rip),%r14
mov    %r14,%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x2,%eax
setge  %dil
call   1060 <assert@plt>
movaps 0xe4e(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xe53(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x4110000041000000,%rax
mov    %rax,0x20(%rsp)
mov    %rsp,%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <write_float_array@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x2,%eax
setge  %dil
call   1060 <assert@plt>
mov    %ebp,%edi
call   1080 <readfile@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1050 <close@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1030 <parse_float_array@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xorps  %xmm0,%xmm0
cmpeqss (%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xdc7(%rip),%xmm0
cmpeqss 0x4(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xdb0(%rip),%xmm0
cmpeqss 0x8(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd99(%rip),%xmm0
cmpeqss 0xc(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd82(%rip),%xmm0
cmpeqss 0x10(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd6b(%rip),%xmm0
cmpeqss 0x14(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd54(%rip),%xmm0
cmpeqss 0x18(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd3d(%rip),%xmm0
cmpeqss 0x1c(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd26(%rip),%xmm0
cmpeqss 0x20(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
movss  0xd0f(%rip),%xmm0
cmpeqss 0x24(%rsp),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1060 <assert@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"testfile\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [40 x i8] c"Couldn't open file to write test output\00"
@O_RDONLY = global i32 0
@.str.2 = [38 x i8] c"Couldn't open file to read test input\00"
define void @test_float_array() {
%1 = alloca i8*
%2 = alloca [10 x float]
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_CREAT
%7 = or i32 %5, %6
%8 = load i32, i32* @O_TRUNC
%9 = or i32 %7, %8
%10 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 438)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %0
br label %14
14: ; preds = %13, %0
%15 = phi i1 [ false, %0 ], [ true, %13 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i32 0, i32* %3
br label %18
18: ; preds = %27, %14
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %3
%23 = sitofp i32 %22 to float
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %25
store float %23, float* %26
br label %27
27: ; preds = %21
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %18
30: ; preds = %18
%31 = load i32, i32* %4
%32 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%33 = call i32 @write_float_array(i32 %31, float* %32, i32 10)
%34 = load i32, i32* %4
%35 = call i32 @close(i32 %34)
%36 = load i32, i32* @O_RDONLY
%37 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %36)
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 1
br i1 %39, label %40, label %41
40: ; preds = %30
br label %41
41: ; preds = %40, %30
%42 = phi i1 [ false, %30 ], [ true, %40 ]
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* %4
%46 = call i8* @readfile(i32 %45)
store i8* %46, i8** %1
%47 = load i32, i32* %4
%48 = call i32 @close(i32 %47)
%49 = load i8*, i8** %1
%50 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%51 = call i64 @parse_float_array(i8* %49, float* %50, i32 10)
%52 = icmp eq i64 %51, 0
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
store i32 0, i32* %3
br label %55
55: ; preds = %68, %41
%56 = load i32, i32* %3
%57 = icmp slt i32 %56, 10
br i1 %57, label %58, label %71
58: ; preds = %55
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %60
%62 = load float, float* %61
%63 = load i32, i32* %3
%64 = sitofp i32 %63 to float
%65 = fcmp oeq float %62, %64
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
br label %68
68: ; preds = %58
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %55
71: ; preds = %55
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"testfile\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDONLY = global i32 0
define void @test_float_array() {
%1 = alloca [10 x float]
%2 = bitcast [10 x float]* %1 to i8*
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7, i32 438)
%9 = icmp sgt i32 %8, 1
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 0
%13 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 1
%14 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 2
%15 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 3
%16 = bitcast [10 x float]* %1 to <4 x float>*
store <4 x float> <float 0.000000e+00, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>, <4 x float>* %16
%17 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 4
%18 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 5
%19 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 6
%20 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 7
%21 = bitcast float* %17 to <4 x float>*
store <4 x float> <float 4.000000e+00, float 5.000000e+00, float 6.000000e+00, float 7.000000e+00>, <4 x float>* %21
%22 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 8
store float 8.000000e+00, float* %22
%23 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 9
store float 9.000000e+00, float* %23
%24 = call i32 @write_float_array(i32 %8, float* %12, i32 10)
%25 = call i32 @close(i32 %8)
%26 = load i32, i32* @O_RDONLY
%27 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = icmp sgt i32 %27, 1
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i8* @readfile(i32 %27)
%32 = call i32 @close(i32 %27)
%33 = call i64 @parse_float_array(i8* %31, float* %12, i32 10)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load float, float* %12
%38 = fcmp oeq float %37, 0.000000e+00
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load float, float* %13
%42 = fcmp oeq float %41, 1.000000e+00
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load float, float* %14
%46 = fcmp oeq float %45, 2.000000e+00
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load float, float* %15
%50 = fcmp oeq float %49, 3.000000e+00
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load float, float* %17
%54 = fcmp oeq float %53, 4.000000e+00
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load float, float* %18
%58 = fcmp oeq float %57, 5.000000e+00
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load float, float* %19
%62 = fcmp oeq float %61, 6.000000e+00
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load float, float* %20
%66 = fcmp oeq float %65, 7.000000e+00
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = load float, float* %22
%70 = fcmp oeq float %69, 8.000000e+00
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = load float, float* %23
%74 = fcmp oeq float %73, 9.000000e+00
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
ret void
}