#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 */
float acos(double);
float cosf(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
float sinf(float);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *);
void read_data(FILE *infile, int n, float *x, float *y, float *z) {
  char readline[80];
  float ra, dec, theta, phi, dpi;
  int i = 0;
  dpi = acos(-1.0);
  while (fgets(readline, 80, infile) != NULL) {
    sscanf(readline, "%f %f", &ra, &dec);
    phi = ra * dpi / 180.0;
    theta = (90.0 - dec) * dpi / 180;
    x[i] = sinf(theta) * cosf(phi);
    y[i] = sinf(theta) * sinf(phi);
    z[i] = cosf(theta);
    ++i;
  }
  fclose(infile);
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x98(%rbp)
movsd  0xe70(%rip),%xmm0
call   1060 <acos@plt>
movss  %xmm0,-0x94(%rbp)
ff
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12f6 <read_data+0x196>
lea    -0x80(%rbp),%rdi
lea    0xe54(%rip),%rsi
lea    -0x84(%rbp),%rdx
lea    -0x88(%rbp),%rcx
call   1080 <sscanf@plt>
movss  -0x84(%rbp),%xmm0
ff
mulss  -0x94(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x90(%rbp)
ff
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movsd  0xdf9(%rip),%xmm0
subsd  %xmm1,%xmm0
movss  -0x94(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd5(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x8c(%rbp),%xmm0
ff
call   1030 <sinf@plt>
movss  %xmm0,-0xa0(%rbp)
ff
movss  -0x90(%rbp),%xmm0
ff
call   1050 <cosf@plt>
movaps %xmm0,%xmm1
movss  -0xa0(%rbp),%xmm0
ff
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x98(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x8c(%rbp),%xmm0
ff
call   1030 <sinf@plt>
movss  %xmm0,-0x9c(%rbp)
ff
movss  -0x90(%rbp),%xmm0
ff
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x9c(%rbp),%xmm0
ff
mulss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x98(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x8c(%rbp),%xmm0
ff
call   1050 <cosf@plt>
mov    -0x28(%rbp),%rax
movslq -0x98(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    119d <read_data+0x3d>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbx
movsd  0xe7e(%rip),%xmm0
call   1060 <acos@plt>
movss  %xmm0,0x4(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1298 <read_data+0x138>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %r13d,%r13d
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
lea    0xe52(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1080 <sscanf@plt>
movss  0x14(%rsp),%xmm0
mulss  0x4(%rsp),%xmm0
divss  0xe2b(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe03(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x18(%rsp),%xmm1
divsd  0xdf9(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
call   1030 <sinf@plt>
movss  %xmm0,(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <cosf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%r12,%r13,1)
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%r15,%r13,1)
movss  0x8(%rsp),%xmm0
call   1050 <cosf@plt>
movss  %xmm0,(%r14,%r13,1)
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
add    $0x4,%r13
test   %rax,%rax
jne    11c0 <read_data+0x60>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%f %f\00"
define void @read_data(i32* %0, i32 %1, float* %2, float* %3, float* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca [80 x i8]
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store float* %2, float** %8
store float* %3, float** %9
store float* %4, float** %10
store i32 0, i32* %17
%18 = call float @acos(double -1.000000e+00)
store float %18, float* %16
br label %19
19: ; preds = %24, %5
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%21 = load i32*, i32** %6
%22 = call i32* @fgets(i8* %20, i32 80, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %67
24: ; preds = %19
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float* %12, float* %13)
%27 = load float, float* %12
%28 = load float, float* %16
%29 = fmul float %27, %28
%30 = fpext float %29 to double
%31 = fdiv double %30, 1.800000e+02
%32 = fptrunc double %31 to float
store float %32, float* %15
%33 = load float, float* %13
%34 = fpext float %33 to double
%35 = fsub double 9.000000e+01, %34
%36 = load float, float* %16
%37 = fpext float %36 to double
%38 = fmul double %35, %37
%39 = fdiv double %38, 1.800000e+02
%40 = fptrunc double %39 to float
store float %40, float* %14
%41 = load float, float* %14
%42 = call float @sinf(float %41)
%43 = load float, float* %15
%44 = call float @cosf(float %43)
%45 = fmul float %42, %44
%46 = load float*, float** %8
%47 = load i32, i32* %17
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
store float %45, float* %49
%50 = load float, float* %14
%51 = call float @sinf(float %50)
%52 = load float, float* %15
%53 = call float @sinf(float %52)
%54 = fmul float %51, %53
%55 = load float*, float** %9
%56 = load i32, i32* %17
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %55, i64 %57
store float %54, float* %58
%59 = load float, float* %14
%60 = call float @cosf(float %59)
%61 = load float*, float** %10
%62 = load i32, i32* %17
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds float, float* %61, i64 %63
store float %60, float* %64
%65 = load i32, i32* %17
%66 = add nsw i32 %65, 1
store i32 %66, i32* %17
br label %19
67: ; preds = %19
%68 = load i32*, i32** %6
%69 = call i32 @fclose(i32* %68)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%f %f\00"
define void @read_data(i32* nocapture %0, i32 %1, float* nocapture writeonly %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = alloca [80 x i8]
%7 = alloca float
%8 = alloca float
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%10 = bitcast float* %7 to i8*
%11 = bitcast float* %8 to i8*
%12 = tail call float @acos(double -1.000000e+00)
%13 = call i32* @fgets(i8* %9, i32 80, i32* %0)
%14 = icmp eq i32* %13, null
br i1 %14, label %42, label %15
15: ; preds = %5
%16 = fpext float %12 to double
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %39, %17 ]
%19 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float* %7, float* %8)
%20 = load float, float* %7
%21 = fmul float %12, %20
%22 = fdiv float %21, 1.800000e+02
%23 = load float, float* %8
%24 = fpext float %23 to double
%25 = fsub double 9.000000e+01, %24
%26 = fmul double %25, %16
%27 = fdiv double %26, 1.800000e+02
%28 = fptrunc double %27 to float
%29 = call float @sinf(float %28)
%30 = call float @cosf(float %22)
%31 = fmul float %29, %30
%32 = getelementptr inbounds float, float* %2, i64 %18
store float %31, float* %32
%33 = call float @sinf(float %28)
%34 = call float @sinf(float %22)
%35 = fmul float %33, %34
%36 = getelementptr inbounds float, float* %3, i64 %18
store float %35, float* %36
%37 = call float @cosf(float %28)
%38 = getelementptr inbounds float, float* %4, i64 %18
store float %37, float* %38
%39 = add nuw i64 %18, 1
%40 = call i32* @fgets(i8* %9, i32 80, i32* %0)
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %17
42: ; preds = %17, %5
%43 = call i32 @fclose(i32* %0)
ret void
}