#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*/ fflush(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ stdout;
scalar_t__ strgetfloat(char **, double *);
int read_rotation_data(FILE *fpr, float **rotdat) {
  char *q, temp[200];
  float *p;
  double d;
  double lasttime = -1.0;
  int arraysize = 100, n = 0;
  if ((*rotdat = (float *)malloc(arraysize * sizeof(float))) == NULL) {
    fprintf(stdout, "ERROR: Insufficient memory to store rotation data\n");
    fflush(stdout);
    return -1;
  }
  p = *rotdat;
  while (fgets(temp, 200, fpr) == temp) {
    q = temp;
    while (strgetfloat(&q, &d)) {
      if (d <= lasttime) {
        fprintf(stdout,
                "ERROR: Times not increasing (at %lf) in rotation data file\n",
                d);
        fflush(stdout);
        return -1;
      }
      lasttime = d;
      *p = (float)d;
      p++;
      n++;
      if (n >= arraysize) {
        arraysize += 100;
        if ((*rotdat = (float *)realloc((char *)(*rotdat),
                                        arraysize * sizeof(float))) == NULL) {
          fprintf(
              stdout,
              "ERROR: Insufficient memory to expand store of rotation data\n");
          fflush(stdout);
          return -1;
        }
      }
    }
  }
  return n;
}


x86 assembly (clang, -O0):
<read_rotation_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
movl   $0x64,-0x10c(%rbp)
movl   $0x0,-0x110(%rbp)
movslq -0x10c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11eb <read_rotation_data+0x8b>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1372 <read_rotation_data+0x212>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xf8(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc8,%esi
call   1040 <fgets@plt>
lea    -0xf0(%rbp),%rcx
cmp    %rcx,%rax
jne    1369 <read_rotation_data+0x209>
lea    -0xf0(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1030 <strgetfloat@plt>
cmp    $0x0,%rax
je     1364 <read_rotation_data+0x204>
movsd  -0x100(%rbp),%xmm1
ff
movsd  -0x108(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jb     1296 <read_rotation_data+0x136>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
movsd  -0x100(%rbp),%xmm0
ff
lea    0xdc6(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1372 <read_rotation_data+0x212>
movsd  -0x100(%rbp),%xmm0
ff
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0x100(%rbp),%xmm0
ff
cvtsd2ss %xmm0,%xmm0
mov    -0xf8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0xf8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xf8(%rbp)
mov    -0x110(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110(%rbp)
mov    -0x110(%rbp),%eax
cmp    -0x10c(%rbp),%eax
jl     135f <read_rotation_data+0x1ff>
mov    -0x10c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x10c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
movslq -0x10c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    135a <read_rotation_data+0x1fa>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1372 <read_rotation_data+0x212>
jmp    135f <read_rotation_data+0x1ff>
jmp    1229 <read_rotation_data+0xc9>
jmp    11f9 <read_rotation_data+0x99>
mov    -0x110(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_rotation_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%r15
mov    %rdi,%rbp
mov    $0x190,%edi
call   1060 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1260 <read_rotation_data+0x100>
mov    %rax,%rbx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0xc8,%esi
mov    %rbp,0x8(%rsp)
mov    %rbp,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
cmp    %r14,%rax
jne    129c <read_rotation_data+0x13c>
mov    %r14,%rcx
movsd  0xe40(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x64,%r14d
xor    %ebp,%ebp
lea    0x18(%rsp),%r13
lea    0x10(%rsp),%r12
mov    %rcx,0x18(%rsp)
jmp    11e4 <read_rotation_data+0x84>
xchg   %ax,%ax
add    $0x4,%rbx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strgetfloat@plt>
test   %rax,%rax
je     123b <read_rotation_data+0xdb>
movsd  (%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jae    1279 <read_rotation_data+0x119>
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,(%rbx)
add    $0x1,%ebp
cmp    %r14d,%ebp
movsd  %xmm0,(%rsp)
jl     11e0 <read_rotation_data+0x80>
mov    (%r15),%rdi
lea    0x190(,%r14,4),%esi
call   1080 <realloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     12b0 <read_rotation_data+0x150>
add    $0x64,%r14d
jmp    11e0 <read_rotation_data+0x80>
lea    0x20(%rsp),%rdi
mov    $0xc8,%esi
mov    0x8(%rsp),%rdx
call   1040 <fgets@plt>
lea    0x20(%rsp),%rcx
cmp    %rcx,%rax
jne    129c <read_rotation_data+0x13c>
mov    %rcx,0x18(%rsp)
jmp    11e4 <read_rotation_data+0x84>
mov    0x2d79(%rip),%rbx
mov    (%rbx),%edi
lea    0xd98(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1290 <read_rotation_data+0x130>
mov    0x2d60(%rip),%rbx
mov    (%rbx),%edi
lea    0xdb2(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d29(%rip),%rbx
mov    (%rbx),%edi
lea    0xdb7(%rip),%rsi
jmp    1270 <read_rotation_data+0x110>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [51 x i8] c"ERROR: Insufficient memory to store rotation data\0A\00"
@.str.1 = [60 x i8] c"ERROR: Times not increasing (at %lf) in rotation data file\0A\00"
@.str.2 = [61 x i8] c"ERROR: Insufficient memory to expand store of rotation data\0A\00"
define i32 @read_rotation_data(i32* %0, float** %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca float**
%6 = alloca i8*
%7 = alloca [200 x i8]
%8 = alloca float*
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store float** %1, float*** %5
store double -1.000000e+00, double* %10
store i32 100, i32* %11
store i32 0, i32* %12
%13 = load i32, i32* %11
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to float*
%19 = load float**, float*** %5
store float* %18, float** %19
%20 = icmp eq float* %18, null
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i32, i32* @stdout
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
store i32 -1, i32* %3
br label %86
26: ; preds = %2
%27 = load float**, float*** %5
%28 = load float*, float** %27
store float* %28, float** %8
br label %29
29: ; preds = %83, %26
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%31 = load i32*, i32** %4
%32 = call i8* @fgets(i8* %30, i32 200, i32* %31)
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%34 = icmp eq i8* %32, %33
br i1 %34, label %35, label %84
35: ; preds = %29
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
store i8* %36, i8** %6
br label %37
37: ; preds = %82, %35
%38 = call i64 @strgetfloat(i8** %6, double* %9)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %83
40: ; preds = %37
%41 = load double, double* %9
%42 = load double, double* %10
%43 = fcmp ole double %41, %42
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* @stdout
%46 = load double, double* %9
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), double %46)
%48 = load i32, i32* @stdout
%49 = call i32 @fflush(i32 %48)
store i32 -1, i32* %3
br label %86
50: ; preds = %40
%51 = load double, double* %9
store double %51, double* %10
%52 = load double, double* %9
%53 = fptrunc double %52 to float
%54 = load float*, float** %8
store float %53, float* %54
%55 = load float*, float** %8
%56 = getelementptr inbounds float, float* %55, i32 1
store float* %56, float** %8
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
%59 = load i32, i32* %12
%60 = load i32, i32* %11
%61 = icmp sge i32 %59, %60
br i1 %61, label %62, label %82
62: ; preds = %50
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 100
store i32 %64, i32* %11
%65 = load float**, float*** %5
%66 = load float*, float** %65
%67 = bitcast float* %66 to i8*
%68 = load i32, i32* %11
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 4
%71 = trunc i64 %70 to i32
%72 = call i64 @realloc(i8* %67, i32 %71)
%73 = inttoptr i64 %72 to float*
%74 = load float**, float*** %5
store float* %73, float** %74
%75 = icmp eq float* %73, null
br i1 %75, label %76, label %81
76: ; preds = %62
%77 = load i32, i32* @stdout
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* @stdout
%80 = call i32 @fflush(i32 %79)
store i32 -1, i32* %3
br label %86
81: ; preds = %62
br label %82
82: ; preds = %81, %50
br label %37
83: ; preds = %37
br label %29
84: ; preds = %29
%85 = load i32, i32* %12
store i32 %85, i32* %3
br label %86
86: ; preds = %84, %76, %44, %21
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [51 x i8] c"ERROR: Insufficient memory to store rotation data\0A\00"
@.str.1 = [60 x i8] c"ERROR: Times not increasing (at %lf) in rotation data file\0A\00"
@.str.2 = [61 x i8] c"ERROR: Insufficient memory to expand store of rotation data\0A\00"
define i32 @read_rotation_data(i32* nocapture %0, float** nocapture %1) {
%3 = alloca i8*
%4 = alloca [200 x i8]
%5 = alloca double
%6 = bitcast i8** %3 to i8*
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%8 = bitcast double* %5 to i8*
%9 = tail call i64 @malloc(i32 400)
%10 = inttoptr i64 %9 to float*
store float* %10, float** %1
%11 = icmp eq i64 %9, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = call i8* @fgets(i8* %7, i32 200, i32* %0)
%14 = icmp eq i8* %13, %7
br i1 %14, label %15, label %69
15: ; preds = %12
%16 = bitcast float** %1 to i8**
br label %29
17: ; preds = %2
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
br label %69
22: ; preds = %65, %29
%23 = phi float* [ %33, %29 ], [ %50, %65 ]
%24 = phi double [ %32, %29 ], [ %41, %65 ]
%25 = phi i32 [ %31, %29 ], [ %66, %65 ]
%26 = phi i32 [ %30, %29 ], [ %51, %65 ]
%27 = call i8* @fgets(i8* %7, i32 200, i32* %0)
%28 = icmp eq i8* %27, %7
br i1 %28, label %29, label %69
29: ; preds = %15, %22
%30 = phi i32 [ 0, %15 ], [ %26, %22 ]
%31 = phi i32 [ 100, %15 ], [ %25, %22 ]
%32 = phi double [ -1.000000e+00, %15 ], [ %24, %22 ]
%33 = phi float* [ %10, %15 ], [ %23, %22 ]
store i8* %7, i8** %3
%34 = call i64 @strgetfloat(i8** %3, double* %5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %22, label %36
36: ; preds = %29, %65
%37 = phi i32 [ %51, %65 ], [ %30, %29 ]
%38 = phi i32 [ %66, %65 ], [ %31, %29 ]
%39 = phi double [ %41, %65 ], [ %32, %29 ]
%40 = phi float* [ %50, %65 ], [ %33, %29 ]
%41 = load double, double* %5
%42 = fcmp ugt double %41, %39
br i1 %42, label %48, label %43
43: ; preds = %36
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), double %41)
%46 = load i32, i32* @stdout
%47 = call i32 @fflush(i32 %46)
br label %69
48: ; preds = %36
%49 = fptrunc double %41 to float
store float %49, float* %40
%50 = getelementptr inbounds float, float* %40, i64 1
%51 = add nsw i32 %37, 1
%52 = icmp slt i32 %51, %38
br i1 %52, label %65, label %53
53: ; preds = %48
%54 = add nsw i32 %38, 100
%55 = load i8*, i8** %16
%56 = shl i32 %54, 2
%57 = call i64 @realloc(i8* %55, i32 %56)
%58 = inttoptr i64 %57 to float*
store float* %58, float** %1
%59 = icmp eq i64 %57, 0
br i1 %59, label %60, label %65
60: ; preds = %53
%61 = load i32, i32* @stdout
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%63 = load i32, i32* @stdout
%64 = call i32 @fflush(i32 %63)
br label %69
65: ; preds = %53, %48
%66 = phi i32 [ %54, %53 ], [ %38, %48 ]
%67 = call i64 @strgetfloat(i8** %3, double* %5)
%68 = icmp eq i64 %67, 0
br i1 %68, label %22, label %36
69: ; preds = %22, %12, %60, %43, %17
%70 = phi i32 [ -1, %17 ], [ -1, %43 ], [ -1, %60 ], [ 0, %12 ], [ %26, %22 ]
ret i32 %70
}