#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__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int number_of_timesteps(FILE *fp1, int valcell) {
  char s2[10];
  int j;
  j = 0;
  while (fscanf(fp1, "%s", s2) != EOF)
    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)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x16(%rbp),%rdx
lea    0xebb(%rip),%rsi
call   1040 <fscanf@plt>
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%rax
je     1168 <number_of_timesteps+0x48>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1136 <number_of_timesteps+0x16>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x1c(%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
lea    0xec0(%rip),%r15
lea    0xe(%rsp),%r12
mov    0x2e9c(%rip),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
add    $0x1,%ebp
cmp    0x0(%r13),%rax
jne    1150 <number_of_timesteps+0x30>
mov    %rbx,%rdi
call   1030 <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) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [10 x i8]
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %13, %2
%8 = load i32*, i32** %3
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
br label %7
16: ; preds = %7
%17 = load i32*, i32** %3
%18 = call i32 @rewind(i32* %17)
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = sdiv i32 %19, %20
ret i32 %21
}

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