#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 atof(char *);
int /*<<< orphan*/ fread(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char **);
void read_one_timestep(FILE *fptgrd, float timestep[], int nr_steps, float mult,
                       int binflag) {
  int i;
  short int stmp;
  char ss[10];
  for (i = 0; i < nr_steps; i++) {
    if (binflag != 1) {
      fscanf(fptgrd, "%s", &ss);
      timestep[i] = atof(ss);
    } else {
      fread(&stmp, sizeof(short), 1, fptgrd);
      timestep[i] = (float)stmp / mult;
    }
  }
}


x86 assembly (clang, -O0):
<read_one_timestep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movss  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11db <read_one_timestep+0xab>
cmpl   $0x1,-0x1c(%rbp)
je     1197 <read_one_timestep+0x67>
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0x2c(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    11c8 <read_one_timestep+0x98>
mov    -0x8(%rbp),%rcx
lea    -0x22(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movswl -0x22(%rbp),%eax
cvtsi2ss %eax,%xmm0
divss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    11cd <read_one_timestep+0x9d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <read_one_timestep+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_one_timestep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0x8(%rsp)
test   %edx,%edx
jle    11ba <read_one_timestep+0x8a>
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %edx,%r15d
xor    %r12d,%r12d
lea    0xe(%rsp),%r13
jmp    1198 <read_one_timestep+0x68>
xchg   %ax,%ax
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
movswl 0x6(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0x8(%rsp),%xmm0
movss  %xmm0,(%rbx,%r12,4)
add    $0x1,%r12
cmp    %r12,%r15
je     11ba <read_one_timestep+0x8a>
cmp    $0x1,%r14d
je     1160 <read_one_timestep+0x30>
mov    %rbp,%rdi
lea    0xe58(%rip),%rsi
mov    %r13,%rdx
call   1050 <fscanf@plt>
mov    %r13,%rdi
call   1040 <atof@plt>
jmp    1189 <read_one_timestep+0x59>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @read_one_timestep(i32* %0, float* %1, i32 %2, float %3, i32 %4) {
%6 = alloca i32*
%7 = alloca float*
%8 = alloca i32
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i16
%13 = alloca [10 x i8]
store i32* %0, i32** %6
store float* %1, float** %7
store i32 %2, i32* %8
store float %3, float* %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %14
14: ; preds = %43, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i32*, i32** %6
%23 = bitcast [10 x i8]* %13 to i8**
%24 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %23)
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%26 = call float @atof(i8* %25)
%27 = load float*, float** %7
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
store float %26, float* %30
br label %42
31: ; preds = %18
%32 = load i32*, i32** %6
%33 = call i32 @fread(i16* %12, i32 2, i32 1, i32* %32)
%34 = load i16, i16* %12
%35 = sitofp i16 %34 to float
%36 = load float, float* %9
%37 = fdiv float %35, %36
%38 = load float*, float** %7
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
store float %37, float* %41
br label %42
42: ; preds = %31, %21
br label %43
43: ; preds = %42
%44 = load i32, i32* %11
%45 = add nsw i32 %44, 1
store i32 %45, i32* %11
br label %14
46: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @read_one_timestep(i32* nocapture %0, float* nocapture writeonly %1, i32 %2, float %3, i32 %4) {
%6 = alloca i16
%7 = alloca [10 x i8]
%8 = bitcast i16* %6 to i8*
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %30
11: ; preds = %5
%12 = icmp eq i32 %4, 1
%13 = bitcast [10 x i8]* %7 to i8**
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %11, %25
%16 = phi i64 [ 0, %11 ], [ %28, %25 ]
br i1 %12, label %20, label %17
17: ; preds = %15
%18 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %13)
%19 = call float @atof(i8* %9)
br label %25
20: ; preds = %15
%21 = call i32 @fread(i16* %6, i32 2, i32 1, i32* %0)
%22 = load i16, i16* %6
%23 = sitofp i16 %22 to float
%24 = fdiv float %23, %3
br label %25
25: ; preds = %17, %20
%26 = phi float [ %24, %20 ], [ %19, %17 ]
%27 = getelementptr inbounds float, float* %1, i64 %16
store float %26, float* %27
%28 = add nuw nsw i64 %16, 1
%29 = icmp eq i64 %28, %14
br i1 %29, label %30, label %15
30: ; preds = %25, %5
ret void
}