#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, float);
int read(int, ...);
int main(int argc, char **argv) {
  int fd;
  long cnt;
  long scale;
  float tmp;
  int bytes;
  fd = open(argv[1], O_RDONLY);
  read(fd, &cnt, sizeof(long));
  printf("%ld\n", cnt);
  while ((bytes = read(fd, &tmp, sizeof(float))) > 0) {
    printf("%f\n", tmp);
  }
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <read@plt>
cvtsi2ssq -0x20(%rbp),%xmm0
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <read@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jle    11c9 <main+0x89>
movss  -0x2c(%rbp),%xmm0
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <main+0x54>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
mov    %eax,%edi
xor    %eax,%eax
call   1050 <read@plt>
cvtsi2ssq 0x8(%rsp),%xmm0
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <read@plt>
test   %eax,%eax
jle    11d3 <main+0x93>
lea    0xe64(%rip),%r14
lea    0x4(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
mov    $0x4,%edx
mov    %ebx,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <read@plt>
test   %eax,%eax
jg     11b0 <main+0x70>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca float
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = call i32 (i32, ...) @read(i32 %16, i64* %7, i64 8)
%18 = load i64, i64* %7
%19 = sitofp i64 %18 to float
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %19)
br label %21
21: ; preds = %25, %2
%22 = load i32, i32* %6
%23 = call i32 (i32, ...) @read(i32 %22, float* %9, i64 4)
store i32 %23, i32* %10
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load float, float* %9
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %26)
br label %21
28: ; preds = %21
%29 = load i32, i32* %6
%30 = call i32 @close(i32 %29)
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca float
%5 = bitcast i64* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* %8, i32 %9)
%11 = call i32 (i32, ...) @read(i32 %10, i64* %3, i64 8)
%12 = load i64, i64* %3
%13 = sitofp i64 %12 to float
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %13)
%15 = call i32 (i32, ...) @read(i32 %10, float* %4, i64 4)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %2, %17
%18 = load float, float* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %18)
%20 = call i32 (i32, ...) @read(i32 %10, float* %4, i64 4)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %17, label %22
22: ; preds = %17, %2
%23 = call i32 @close(i32 %10)
ret i32 0
}