#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 /*<<< orphan*/ ConvertWriteFloat(int, float);
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int);
int main(int argc, char *argv[]) {
  int i;
  float val[8] = {0.1, 0.2, 0.5, -0.5, 0.6, 1.2, 1.8, -0.8};
  int fd;
  fd = open("test.dat", O_WRONLY | O_CREAT);
  for (i = 0; i < 8; i++)
    ConvertWriteFloat(fd, val[i]);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    0x2e76(%rip),%rax
or     (%rax),%esi
lea    0xe95(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11c4 <main+0x94>
mov    -0x44(%rbp),%edi
movslq -0x14(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
call   1030 <ConvertWriteFloat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <main+0x6a>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e98(%rip),%rax
mov    0x2eb9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xed6(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
movss  0xea7(%rip),%xmm0
mov    %eax,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe9c(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe91(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe86(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe7b(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe70(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe65(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
movss  0xe5a(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ConvertWriteFloat@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.val = [8 x float] [float 0x3FB99999A0000000, float 0x3FC99999A0000000, float 5.000000e-01, float -5.000000e-01, float 0x3FE3333340000000, float 0x3FF3333340000000, float 0x3FFCCCCCC0000000, float 0xBFE99999A0000000]
@.str = [9 x i8] c"test.dat\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8 x float]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [8 x float]* %7 to i8*
%10 = load i32, i32* @O_WRONLY
%11 = load i32, i32* @O_CREAT
%12 = or i32 %10, %11
%13 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 %13, i32* %8
store i32 0, i32* %6
br label %14
14: ; preds = %24, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x float], [8 x float]* %7, i64 0, i64 %20
%22 = load float, float* %21
%23 = call i32 @ConvertWriteFloat(i32 %18, float %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %14
27: ; preds = %14
%28 = load i32, i32* %8
%29 = call i32 @close(i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.dat\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @ConvertWriteFloat(i32 %6, float 0x3FB99999A0000000)
%8 = tail call i32 @ConvertWriteFloat(i32 %6, float 0x3FC99999A0000000)
%9 = tail call i32 @ConvertWriteFloat(i32 %6, float 5.000000e-01)
%10 = tail call i32 @ConvertWriteFloat(i32 %6, float -5.000000e-01)
%11 = tail call i32 @ConvertWriteFloat(i32 %6, float 0x3FE3333340000000)
%12 = tail call i32 @ConvertWriteFloat(i32 %6, float 0x3FF3333340000000)
%13 = tail call i32 @ConvertWriteFloat(i32 %6, float 0x3FFCCCCCC0000000)
%14 = tail call i32 @ConvertWriteFloat(i32 %6, float 0xBFE99999A0000000)
%15 = tail call i32 @close(i32 %6)
ret i32 0
}