#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
void raw2pts(FILE *ifp, FILE *ofp) {
  fseek(ifp, 0, SEEK_END);
  size_t len = ftell(ifp);
  len /= (3 * sizeof(float));
  fseek(ifp, 0, SEEK_SET);
  float buf[3];
  int i = 0;
  for (i = 0; i < len; ++i) {
    fread(buf, sizeof(float), 3, ifp);
    for (int j = 0; j < 3; ++j) {
      fprintf(ofp, "%20.10f ", buf[j]);
    }
    fprintf(ofp, "\n");
  }
  fprintf(stdout, "--Parsed %d points.\n", len);
}


x86 assembly (clang, -O0):
<raw2pts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1229 <raw2pts+0xe9>
lea    -0x24(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x3,%edx
call   1030 <fread@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1209 <raw2pts+0xc9>
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
movss  -0x24(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0c(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d1 <raw2pts+0x91>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a5 <raw2pts+0x65>
mov    0x2da0(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raw2pts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %r14,%rdi
call   1060 <ftell@plt>
mov    %rax,%r12
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
mov    %rdx,%r15
shr    $0x3,%r15
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
cmp    $0xc,%r12
jb     123d <raw2pts+0xed>
cmp    $0x2,%r15
mov    $0x1,%ebp
cmovae %r15,%rbp
lea    0xc(%rsp),%r12
lea    0xe37(%rip),%r13
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0xffffffffffffffff,%rbp
jne    11d0 <raw2pts+0x80>
mov    0x2d8c(%rip),%rax
mov    (%rax),%rdi
lea    0xdbb(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str = [9 x i8] c"%20.10f \00"
@.str.1 = [2 x i8] c"\0A\00"
@stdout = global i32* null
@.str.2 = [21 x i8] c"--Parsed %d points.\0A\00"
define void @raw2pts(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca [3 x float]
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%9 = load i32*, i32** %3
%10 = load i32, i32* @SEEK_END
%11 = call i32 @fseek(i32* %9, i32 0, i32 %10)
%12 = load i32*, i32** %3
%13 = call i64 @ftell(i32* %12)
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = udiv i64 %14, 12
store i64 %15, i64* %5
%16 = load i32*, i32** %3
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @fseek(i32* %16, i32 0, i32 %17)
store i32 0, i32* %7
store i32 0, i32* %7
br label %19
19: ; preds = %45, %2
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = load i64, i64* %5
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %19
%25 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%26 = load i32*, i32** %3
%27 = call i32 @fread(float* %25, i32 4, i32 3, i32* %26)
store i32 0, i32* %8
br label %28
28: ; preds = %39, %24
%29 = load i32, i32* %8
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %42
31: ; preds = %28
%32 = load i32*, i32** %4
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 %34
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %37)
br label %39
39: ; preds = %31
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %28
42: ; preds = %28
%43 = load i32*, i32** %4
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %42
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %19
48: ; preds = %19
%49 = load i32*, i32** @stdout
%50 = load i64, i64* %5
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %50)
ret void
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str = [9 x i8] c"%20.10f \00"
@stdout = global i32* null
@.str.2 = [21 x i8] c"--Parsed %d points.\0A\00"
define void @raw2pts(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [3 x float]
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = tail call i64 @ftell(i32* %0)
%7 = udiv i64 %6, 12
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i32 0, i32 %8)
%10 = bitcast [3 x float]* %3 to i8*
%11 = icmp ult i64 %6, 12
br i1 %11, label %32, label %12
12: ; preds = %2
%13 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
%14 = call i64 @llvm.umax.i64(i64 %7, i64 1)
%15 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%16 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
br label %17
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %30, %17 ]
%19 = call i32 @fread(float* %13, i32 4, i32 3, i32* %0)
%20 = load float, float* %13
%21 = fpext float %20 to double
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %21)
%23 = load float, float* %15
%24 = fpext float %23 to double
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %24)
%26 = load float, float* %16
%27 = fpext float %26 to double
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %27)
%29 = tail call i32 @fputc(i32 10, i32* %1)
%30 = add nuw nsw i64 %18, 1
%31 = icmp eq i64 %30, %14
br i1 %31, label %32, label %17
32: ; preds = %17, %2
%33 = load i32*, i32** @stdout
%34 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %7)
ret void
}