#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *, double *, double *,
                  double *);
int readUserMotion(double xyz[(3000)][3], char *filename) {
  FILE *fp;
  int numd;
  double t, x, y, z;
  if (NULL == (fp = fopen(filename, "rt")))
    return (-1);
  for (numd = 0; numd < (3000); numd++) {
    if (EOF == fscanf(fp, "%lf,%lf,%lf,%lf", &t, &x, &y, &z))
      break;
    xyz[numd][0] = x;
    xyz[numd][1] = y;
    xyz[numd][2] = z;
  }
  fclose(fp);
  return (numd);
}


x86 assembly (clang, -O0):
<readUserMotion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    116e <readUserMotion+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    122c <readUserMotion+0xfc>
movl   $0x0,-0x24(%rbp)
cmpl   $0xbb8,-0x24(%rbp)
jge    121d <readUserMotion+0xed>
mov    0x2e5f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x48(%rbp),%r9
call   1040 <fscanf@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jne    11c5 <readUserMotion+0x95>
jmp    121d <readUserMotion+0xed>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,0x10(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <readUserMotion+0x45>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readUserMotion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xeb5(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11df <readUserMotion+0xaf>
mov    %rax,%r14
add    $0x10,%rbx
xor    %r15d,%r15d
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r13
mov    0x2e71(%rip),%rax
mov    (%rax),%rbp
mov    %r14,%rdi
lea    0xe7f(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1040 <fscanf@plt>
cmp    %rax,%rbp
je     11d5 <readUserMotion+0xa5>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,-0x10(%rbx)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,-0x8(%rbx)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x1,%r15
add    $0x18,%rbx
cmp    $0xbb8,%r15
jne    1170 <readUserMotion+0x40>
mov    $0xbb8,%r15d
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    11e5 <readUserMotion+0xb5>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@EOF = global i64 0
@.str.1 = [16 x i8] c"%lf,%lf,%lf,%lf\00"
define i32 @readUserMotion([3 x double]* %0, i8* %1) {
%3 = alloca i32
%4 = alloca [3 x double]*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store [3 x double]* %0, [3 x double]** %4
store i8* %1, i8** %5
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = icmp eq i32* null, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %52
16: ; preds = %2
store i32 0, i32* %7
br label %17
17: ; preds = %45, %16
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 3000
br i1 %19, label %20, label %48
20: ; preds = %17
%21 = load i64, i64* @EOF
%22 = load i32*, i32** %6
%23 = call i64 @fscanf(i32* %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %8, double* %9, double* %10, double* %11)
%24 = icmp eq i64 %21, %23
br i1 %24, label %25, label %26
25: ; preds = %20
br label %48
26: ; preds = %20
%27 = load double, double* %9
%28 = load [3 x double]*, [3 x double]** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x double], [3 x double]* %28, i64 %30
%32 = getelementptr inbounds [3 x double], [3 x double]* %31, i64 0, i64 0
store double %27, double* %32
%33 = load double, double* %10
%34 = load [3 x double]*, [3 x double]** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x double], [3 x double]* %34, i64 %36
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 0, i64 1
store double %33, double* %38
%39 = load double, double* %11
%40 = load [3 x double]*, [3 x double]** %4
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0, i64 2
store double %39, double* %44
br label %45
45: ; preds = %26
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %17
48: ; preds = %25, %17
%49 = load i32*, i32** %6
%50 = call i32 @fclose(i32* %49)
%51 = load i32, i32* %7
store i32 %51, i32* %3
br label %52
52: ; preds = %48, %15
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@EOF = global i64 0
@.str.1 = [16 x i8] c"%lf,%lf,%lf,%lf\00"
define i32 @readUserMotion([3 x double]* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %32, label %13
13: ; preds = %2, %18
%14 = phi i64 [ %25, %18 ], [ 0, %2 ]
%15 = load i64, i64* @EOF
%16 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %3, double* %4, double* %5, double* %6)
%17 = icmp eq i64 %15, %16
br i1 %17, label %27, label %18
18: ; preds = %13
%19 = load double, double* %4
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %14, i64 0
store double %19, double* %20
%21 = load double, double* %5
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %14, i64 1
store double %21, double* %22
%23 = load double, double* %6
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %14, i64 2
store double %23, double* %24
%25 = add nuw nsw i64 %14, 1
%26 = icmp eq i64 %25, 3000
br i1 %26, label %29, label %13
27: ; preds = %13
%28 = trunc i64 %14 to i32
br label %29
29: ; preds = %18, %27
%30 = phi i32 [ %28, %27 ], [ 3000, %18 ]
%31 = call i32 @fclose(i32* %11)
br label %32
32: ; preds = %2, %29
%33 = phi i32 [ %30, %29 ], [ -1, %2 ]
ret i32 %33
}