#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ sscanf(char *, char *, double *, double *, double *, double *);
int readUserMotion(double xyz[(3000)][3], const char *filename) {
  FILE *fp;
  int numd;
  char str[(100)];
  double t, x, y, z;
  if (NULL == (fp = fopen(filename, "rt")))
    return (-1);
  for (numd = 0; numd < (3000); numd++) {
    if (fgets(str, (100), fp) == NULL)
      break;
    if (EOF == sscanf(str, "%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    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1181 <readUserMotion+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    1281 <readUserMotion+0x141>
movl   $0x0,-0x24(%rbp)
cmpl   $0xbb8,-0x24(%rbp)
jge    1272 <readUserMotion+0x132>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11b9 <readUserMotion+0x79>
jmp    1272 <readUserMotion+0x132>
mov    0x2e28(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x98(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
lea    -0xa8(%rbp),%r8
lea    -0xb0(%rbp),%r9
call   1050 <sscanf@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
cmp    %rcx,%rax
jne    1211 <readUserMotion+0xd1>
jmp    1272 <readUserMotion+0x132>
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,(%rax)
movsd  -0xa8(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,0x8(%rax)
movsd  -0xb0(%rbp),%xmm0
ff
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    1188 <readUserMotion+0x48>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readUserMotion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     1215 <readUserMotion+0xd5>
mov    %rax,%r14
add    $0x10,%rbx
xor    %r15d,%r15d
lea    0x20(%rsp),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     120b <readUserMotion+0xcb>
mov    0x2e3c(%rip),%rax
mov    (%rax),%rbp
mov    %r12,%rdi
lea    0xe4a(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r13,%r9
call   1050 <sscanf@plt>
cmp    %rax,%rbp
je     120b <readUserMotion+0xcb>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,-0x10(%rbx)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,-0x8(%rbx)
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x1,%r15
add    $0x18,%rbx
cmp    $0xbb8,%r15
jne    1190 <readUserMotion+0x50>
mov    $0xbb8,%r15d
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    121b <readUserMotion+0xdb>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x88,%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 [100 x i8]
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store [3 x double]* %0, [3 x double]** %4
store i8* %1, i8** %5
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* null, %14
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 -1, i32* %3
br label %59
17: ; preds = %2
store i32 0, i32* %7
br label %18
18: ; preds = %52, %17
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 3000
br i1 %20, label %21, label %55
21: ; preds = %18
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%23 = load i32*, i32** %6
%24 = call i32* @fgets(i8* %22, i32 100, i32* %23)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21
br label %55
27: ; preds = %21
%28 = load i64, i64* @EOF
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%30 = call i64 @sscanf(i8* %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %9, double* %10, double* %11, double* %12)
%31 = icmp eq i64 %28, %30
br i1 %31, label %32, label %33
32: ; preds = %27
br label %55
33: ; preds = %27
%34 = load double, double* %10
%35 = load [3 x double]*, [3 x double]** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 0
store double %34, double* %39
%40 = load double, double* %11
%41 = load [3 x double]*, [3 x double]** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 0, i64 1
store double %40, double* %45
%46 = load double, double* %12
%47 = load [3 x double]*, [3 x double]** %4
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 2
store double %46, double* %51
br label %52
52: ; preds = %33
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %18
55: ; preds = %32, %26, %18
%56 = load i32*, i32** %6
%57 = call i32 @fclose(i32* %56)
%58 = load i32, i32* %7
store i32 %58, i32* %3
br label %59
59: ; preds = %55, %16
%60 = load i32, i32* %3
ret i32 %60
}

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 [100 x i8]
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = bitcast double* %6 to i8*
%12 = bitcast double* %7 to i8*
%13 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %39, label %15
15: ; preds = %2, %23
%16 = phi i64 [ %30, %23 ], [ 0, %2 ]
%17 = call i32* @fgets(i8* %8, i32 100, i32* %13)
%18 = icmp eq i32* %17, null
br i1 %18, label %34, label %19
19: ; preds = %15
%20 = load i64, i64* @EOF
%21 = call i64 @sscanf(i8* %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %4, double* %5, double* %6, double* %7)
%22 = icmp eq i64 %20, %21
br i1 %22, label %32, label %23
23: ; preds = %19
%24 = load double, double* %5
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %16, i64 0
store double %24, double* %25
%26 = load double, double* %6
%27 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %16, i64 1
store double %26, double* %27
%28 = load double, double* %7
%29 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %16, i64 2
store double %28, double* %29
%30 = add nuw nsw i64 %16, 1
%31 = icmp eq i64 %30, 3000
br i1 %31, label %36, label %15
32: ; preds = %19
%33 = trunc i64 %16 to i32
br label %36
34: ; preds = %15
%35 = trunc i64 %16 to i32
br label %36
36: ; preds = %23, %34, %32
%37 = phi i32 [ %33, %32 ], [ %35, %34 ], [ 3000, %23 ]
%38 = call i32 @fclose(i32* %13)
br label %39
39: ; preds = %2, %36
%40 = phi i32 [ %37, %36 ], [ -1, %2 ]
ret i32 %40
}