#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float);
int /*<<< orphan*/ moments(int, float *, float *, float *, float *, float *,
                           float *);
int readpoints(float *, float *, float *);
int main(void) {
  FILE *fout = fopen("moments.out", "w");
  int n;
  float ix = 0, iy = 0, io = 0;
  float x[100], y[100], m[100];
  n = readpoints(x, y, m);
  moments(n, &ix, &iy, &io, x, y, m);
  fprintf(fout, "Ix = %.2f\n", ix);
  fprintf(fout, "Iy = %.2f\n", iy);
  fprintf(fout, "Io = %.2f\n", io);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    -0x1b0(%rbp),%rdi
lea    -0x340(%rbp),%rsi
lea    -0x4d0(%rbp),%rdx
call   1050 <readpoints@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x1b0(%rbp),%r8
lea    -0x340(%rbp),%r9
lea    -0x4d0(%rbp),%rax
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    %rax,(%rsp)
call   1060 <moments@plt>
mov    -0x10(%rbp),%rdi
movss  -0x18(%rbp),%xmm0
lea    0xe33(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movss  -0x1c(%rbp),%xmm0
lea    0xe29(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movss  -0x20(%rbp),%xmm0
lea    0xe1f(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x4e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4d8,%rsp
lea    0xeab(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
lea    0x340(%rsp),%r14
lea    0x1b0(%rsp),%r15
lea    0x20(%rsp),%r12
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <readpoints@plt>
mov    %r12,(%rsp)
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %eax,%edi
mov    %r14,%r8
mov    %r15,%r9
call   1060 <moments@plt>
movss  0x1c(%rsp),%xmm0
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1030 <fprintf@plt>
movss  0x18(%rsp),%xmm0
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1030 <fprintf@plt>
movss  0x14(%rsp),%xmm0
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x4d8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"moments.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"Ix = %.2f\0A\00"
@.str.3 = [11 x i8] c"Iy = %.2f\0A\00"
@.str.4 = [11 x i8] c"Io = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca [100 x float]
%8 = alloca [100 x float]
%9 = alloca [100 x float]
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%11 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 0
%12 = getelementptr inbounds [100 x float], [100 x float]* %8, i64 0, i64 0
%13 = getelementptr inbounds [100 x float], [100 x float]* %9, i64 0, i64 0
%14 = call i32 @readpoints(float* %11, float* %12, float* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 0
%17 = getelementptr inbounds [100 x float], [100 x float]* %8, i64 0, i64 0
%18 = getelementptr inbounds [100 x float], [100 x float]* %9, i64 0, i64 0
%19 = call i32 @moments(i32 %15, float* %4, float* %5, float* %6, float* %16, float* %17, float* %18)
%20 = load i32*, i32** %2
%21 = load float, float* %4
%22 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %21)
%23 = load i32*, i32** %2
%24 = load float, float* %5
%25 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %24)
%26 = load i32*, i32** %2
%27 = load float, float* %6
%28 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), float %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"moments.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"Ix = %.2f\0A\00"
@.str.3 = [11 x i8] c"Iy = %.2f\0A\00"
@.str.4 = [11 x i8] c"Io = %.2f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca [100 x float]
%5 = alloca [100 x float]
%6 = alloca [100 x float]
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%9 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%10 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%11 = bitcast [100 x float]* %4 to i8*
%12 = bitcast [100 x float]* %5 to i8*
%13 = bitcast [100 x float]* %6 to i8*
%14 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 0
%15 = getelementptr inbounds [100 x float], [100 x float]* %5, i64 0, i64 0
%16 = getelementptr inbounds [100 x float], [100 x float]* %6, i64 0, i64 0
%17 = call i32 @readpoints(float* %14, float* %15, float* %16)
%18 = call i32 @moments(i32 %17, float* %1, float* %2, float* %3, float* %14, float* %15, float* %16)
%19 = load float, float* %1
%20 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %19)
%21 = load float, float* %2
%22 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %21)
%23 = load float, float* %3
%24 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), float %23)
ret i32 0
}