#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;
scalar_t__ fread(short *, int, int, int /*<<< orphan*/ *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char **);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int number_of_timesteps(FILE *fp1, int valcell, int binflag) {
  char s2[10];
  short int dummy_int;
  int j;
  j = 0;
  if (binflag != 1) {
    while (fscanf(fp1, "%s", &s2) != EOF)
      j++;
  } else {
    while ((fread(&dummy_int, sizeof(short int), 1, fp1) != 0))
      j++;
  }
  rewind(fp1);
  return (j / valcell);
}


x86 assembly (clang, -O0):
<number_of_timesteps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     118f <number_of_timesteps+0x5f>
jmp    1158 <number_of_timesteps+0x28>
mov    -0x8(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
lea    0xe99(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%rax
je     118a <number_of_timesteps+0x5a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1158 <number_of_timesteps+0x28>
jmp    11c8 <number_of_timesteps+0x98>
jmp    1194 <number_of_timesteps+0x64>
mov    -0x8(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     11c3 <number_of_timesteps+0x93>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1194 <number_of_timesteps+0x64>
jmp    11c8 <number_of_timesteps+0x98>
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x20(%rbp),%eax
cltd
idivl  -0xc(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_of_timesteps>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0xffffffff,%ebp
cmp    $0x1,%edx
jne    117f <number_of_timesteps+0x4f>
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    1160 <number_of_timesteps+0x30>
jmp    11b7 <number_of_timesteps+0x87>
lea    0xe7a(%rip),%r15
lea    0xe(%rsp),%r12
mov    0x2e56(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
add    $0x1,%ebp
cmp    0x0(%r13),%rax
jne    11a0 <number_of_timesteps+0x70>
mov    %rbx,%rdi
call   1040 <rewind@plt>
mov    %ebp,%eax
cltd
idiv   %r14d
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"
@EOF = global i64 0
define i32 @number_of_timesteps(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i8]
%8 = alloca i16
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %9
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %23
12: ; preds = %3
br label %13
13: ; preds = %19, %12
%14 = load i32*, i32** %4
%15 = bitcast [10 x i8]* %7 to i8**
%16 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %15)
%17 = load i64, i64* @EOF
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 1
store i32 %21, i32* %9
br label %13
22: ; preds = %13
br label %32
23: ; preds = %3
br label %24
24: ; preds = %28, %23
%25 = load i32*, i32** %4
%26 = call i64 @fread(i16* %8, i32 2, i32 1, i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %24
31: ; preds = %24
br label %32
32: ; preds = %31, %22
%33 = load i32*, i32** %4
%34 = call i32 @rewind(i32* %33)
%35 = load i32, i32* %9
%36 = load i32, i32* %5
%37 = sdiv i32 %35, %36
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @number_of_timesteps(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [10 x i8]
%5 = alloca i16
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = bitcast i16* %5 to i8*
%8 = icmp eq i32 %2, 1
br i1 %8, label %17, label %9
9: ; preds = %3
%10 = bitcast [10 x i8]* %4 to i8**
br label %11
11: ; preds = %11, %9
%12 = phi i32 [ %16, %11 ], [ 0, %9 ]
%13 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %10)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
%16 = add nuw nsw i32 %12, 1
br i1 %15, label %22, label %11
17: ; preds = %3, %17
%18 = phi i32 [ %21, %17 ], [ 0, %3 ]
%19 = call i64 @fread(i16* %5, i32 2, i32 1, i32* %0)
%20 = icmp eq i64 %19, 0
%21 = add nuw nsw i32 %18, 1
br i1 %20, label %22, label %17
22: ; preds = %11, %17
%23 = phi i32 [ %18, %17 ], [ %12, %11 ]
%24 = call i32 @rewind(i32* %0)
%25 = sdiv i32 %23, %1
ret i32 %25
}