#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 */

/* Variables and functions */
scalar_t__ time(int /*<<< orphan*/ *);
float GetFPSFunc(void) {
  static int init = 0;
  static float numofframes = 0;
  static long time_count = 0;
  long seconds = 0;
  static float fps = 0;
  if (!init) {
    time_count = (unsigned)time(NULL);
    init++;
  }
  numofframes++;
  seconds = ((unsigned)time(NULL) - time_count);
  if (seconds >= 1) {
    fps = (numofframes / seconds);
    seconds = 0;
    numofframes = 0;
    time_count = (unsigned)time(NULL);
  }
  return fps;
}


x86 assembly (clang, -O0):
<GetFPSFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
cmpl   $0x0,0x2f09(%rip)
jne    114e <GetFPSFunc+0x3e>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,%eax
mov    %rax,0x2ef9(%rip)
mov    0x2eeb(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee2(%rip)
movss  0xeaa(%rip),%xmm0
addss  0x2ed6(%rip),%xmm0
movss  %xmm0,0x2ece(%rip)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,%eax
sub    0x2ec0(%rip),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     11c6 <GetFPSFunc+0xb6>
movss  0x2ea5(%rip),%xmm0
cvtsi2ssq -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x2e9f(%rip)
movq   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x2e80(%rip)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,%eax
mov    %rax,0x2e72(%rip)
movss  0x2e72(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFPSFunc>:
push   %rax
cmpl   $0x0,0x2f18(%rip)
jne    1131 <GetFPSFunc+0x21>
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%eax
mov    %rax,0x2f0e(%rip)
addl   $0x1,0x2eff(%rip)
movss  0x2efb(%rip),%xmm0
addss  0xebf(%rip),%xmm0
movss  %xmm0,0x2eeb(%rip)
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%eax
sub    0x2edf(%rip),%rax
jle    1191 <GetFPSFunc+0x81>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x2ec9(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x2ec9(%rip)
movl   $0x0,0x2eb3(%rip)
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%eax
mov    %rax,0x2ea7(%rip)
movss  0x2ea7(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@GetFPSFunc.init = internal global i32 0
@GetFPSFunc.numofframes = internal global float 0.000000e+00
@GetFPSFunc.time_count = internal global i64 0
@GetFPSFunc.fps = internal global float 0.000000e+00
define float @GetFPSFunc() {
%1 = alloca i64
store i64 0, i64* %1
%2 = load i32, i32* @GetFPSFunc.init
%3 = icmp ne i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = zext i32 %6 to i64
store i64 %7, i64* @GetFPSFunc.time_count
%8 = load i32, i32* @GetFPSFunc.init
%9 = add nsw i32 %8, 1
store i32 %9, i32* @GetFPSFunc.init
br label %10
10: ; preds = %4, %0
%11 = load float, float* @GetFPSFunc.numofframes
%12 = fadd float %11, 1.000000e+00
store float %12, float* @GetFPSFunc.numofframes
%13 = call i64 @time(i32* null)
%14 = trunc i64 %13 to i32
%15 = zext i32 %14 to i64
%16 = load i64, i64* @GetFPSFunc.time_count
%17 = sub nsw i64 %15, %16
store i64 %17, i64* %1
%18 = load i64, i64* %1
%19 = icmp sge i64 %18, 1
br i1 %19, label %20, label %28
20: ; preds = %10
%21 = load float, float* @GetFPSFunc.numofframes
%22 = load i64, i64* %1
%23 = sitofp i64 %22 to float
%24 = fdiv float %21, %23
store float %24, float* @GetFPSFunc.fps
store i64 0, i64* %1
store float 0.000000e+00, float* @GetFPSFunc.numofframes
%25 = call i64 @time(i32* null)
%26 = trunc i64 %25 to i32
%27 = zext i32 %26 to i64
store i64 %27, i64* @GetFPSFunc.time_count
br label %28
28: ; preds = %20, %10
%29 = load float, float* @GetFPSFunc.fps
ret float %29
}

LLVM IR (-O2):
@GetFPSFunc.init = internal unnamed_addr global i32 0
@GetFPSFunc.numofframes = internal unnamed_addr global float 0.000000e+00
@GetFPSFunc.time_count = internal unnamed_addr global i64 0
@GetFPSFunc.fps = internal unnamed_addr global float 0.000000e+00
define float @GetFPSFunc() {
%1 = load i32, i32* @GetFPSFunc.init
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i64 @time(i32* null)
%5 = and i64 %4, 4294967295
store i64 %5, i64* @GetFPSFunc.time_count
%6 = load i32, i32* @GetFPSFunc.init
%7 = add nsw i32 %6, 1
store i32 %7, i32* @GetFPSFunc.init
br label %8
8: ; preds = %3, %0
%9 = load float, float* @GetFPSFunc.numofframes
%10 = fadd float %9, 1.000000e+00
store float %10, float* @GetFPSFunc.numofframes
%11 = tail call i64 @time(i32* null)
%12 = and i64 %11, 4294967295
%13 = load i64, i64* @GetFPSFunc.time_count
%14 = sub nsw i64 %12, %13
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %8
%17 = load float, float* @GetFPSFunc.numofframes
%18 = sitofp i64 %14 to float
%19 = fdiv float %17, %18
store float %19, float* @GetFPSFunc.fps
store float 0.000000e+00, float* @GetFPSFunc.numofframes
%20 = tail call i64 @time(i32* null)
%21 = and i64 %20, 4294967295
store i64 %21, i64* @GetFPSFunc.time_count
br label %22
22: ; preds = %16, %8
%23 = load float, float* @GetFPSFunc.fps
ret float %23
}