#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int readpoints(float *x, float *y, float *m) {
  int i;
  FILE *fin = fopen("moments.in", "r");
  for (i = 0; !feof(fin); i++) {
    fscanf(fin, "%f", &x[i]);
    fscanf(fin, "%f", &y[i]);
    fscanf(fin, "%f", &m[i]);
  }
  fclose(fin);
  return i;
}


x86 assembly (clang, -O0):
<readpoints>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea5(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1190 <readpoints+0x50>
jmp    11fb <readpoints+0xbb>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe63(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe44(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe25(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <readpoints+0x32>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readpoints>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11d5 <readpoints+0x95>
xor    %ebp,%ebp
lea    0xe8c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1040 <fscanf@plt>
mov    %r12,%rdi
call   1050 <feof@plt>
add    $0x4,%r14
add    $0x4,%r15
add    $0x4,%rbx
add    $0x1,%ebp
test   %eax,%eax
je     1190 <readpoints+0x50>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"moments.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%f\00"
define i32 @readpoints(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32*
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %8
store i32 0, i32* %7
br label %10
10: ; preds = %34, %3
%11 = load i32*, i32** %8
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load i32*, i32** %8
%17 = load float*, float** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
%21 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %20)
%22 = load i32*, i32** %8
%23 = load float*, float** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
%27 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %26)
%28 = load i32*, i32** %8
%29 = load float*, float** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = call i32 @fscanf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %32)
br label %34
34: ; preds = %15
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %10
37: ; preds = %10
%38 = load i32*, i32** %8
%39 = call i32 @fclose(i32* %38)
%40 = load i32, i32* %7
ret i32 %40
}

LLVM IR (-O2):
@.str = [11 x i8] c"moments.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%f\00"
define i32 @readpoints(float* %0, float* %1, float* %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @feof(i32* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %3, %7
%8 = phi i64 [ %15, %7 ], [ 0, %3 ]
%9 = getelementptr inbounds float, float* %0, i64 %8
%10 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %9)
%11 = getelementptr inbounds float, float* %1, i64 %8
%12 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %11)
%13 = getelementptr inbounds float, float* %2, i64 %8
%14 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %13)
%15 = add nuw i64 %8, 1
%16 = tail call i32 @feof(i32* %4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %7
%19 = trunc i64 %15 to i32
br label %20
20: ; preds = %18, %3
%21 = phi i32 [ 0, %3 ], [ %19, %18 ]
%22 = tail call i32 @fclose(i32* %4)
ret i32 %21
}