#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ clsCols();
int /*<<< orphan*/ clsRows();
int /*<<< orphan*/ display();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ setup();
int /*<<< orphan*/ setup_gpio();
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  unsigned int i;
  unsigned int secs = 15;
  clock_t cur;
  clock_t end;
  clock_t frameTime, avg;
  double totalSecs;
  setup_gpio();
  setup();
  cur = clock();
  while (i < 100000) {
    display();
    i++;
  }
  end = clock();
  clsCols();
  clsRows();
  usleep(50000);
  totalSecs = (double)(end - cur) / CLOCKS_PER_SEC;
  printf("num frames: %i\n", i);
  printf("seconds: %f\n", totalSecs);
  printf("average FPS: %f\n", (double)i / totalSecs);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf,-0x18(%rbp)
mov    $0x0,%al
call   1030 <setup_gpio@plt>
mov    $0x0,%al
call   1090 <setup@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x186a0,-0x14(%rbp)
jae    11d8 <main+0x58>
mov    $0x0,%al
call   1050 <display@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <main+0x36>
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1040 <clock@plt>
mov    %rax,%rcx
mov    -0x41(%rbp),%al
mov    %rcx,-0x28(%rbp)
call   1070 <clsCols@plt>
mov    -0x41(%rbp),%al
call   1080 <clsRows@plt>
mov    $0xc350,%edi
call   10a0 <usleep@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2dce(%rip),%rax
movsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
lea    0xdca(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xdc9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
divsd  -0x40(%rbp),%xmm0
lea    0xdbd(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <setup_gpio@plt>
xor    %eax,%eax
call   1080 <setup@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <clsCols@plt>
xor    %eax,%eax
call   1070 <clsRows@plt>
mov    $0xc350,%edi
call   1090 <usleep@plt>
sub    %r14,%rbx
cvtsi2sd %rbx,%xmm0
mov    0x2e2b(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
lea    0xe33(%rip),%rdi
xorpd  %xmm0,%xmm0
call   1050 <printf@plt>
lea    0xe33(%rip),%rdi
movsd  (%rsp),%xmm0
call   1050 <printf@plt>
xorpd  %xmm0,%xmm0
divsd  (%rsp),%xmm0
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [16 x i8] c"num frames: %i\0A\00"
@.str.1 = [13 x i8] c"seconds: %f\0A\00"
@.str.2 = [17 x i8] c"average FPS: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 15, i32* %7
%13 = call i32 (...) @setup_gpio()
%14 = call i32 (...) @setup()
%15 = call i64 (...) @clock()
store i64 %15, i64* %8
br label %16
16: ; preds = %19, %2
%17 = load i32, i32* %6
%18 = icmp ult i32 %17, 100000
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 (...) @display()
%21 = load i32, i32* %6
%22 = add i32 %21, 1
store i32 %22, i32* %6
br label %16
23: ; preds = %16
%24 = call i64 (...) @clock()
store i64 %24, i64* %9
%25 = call i32 (...) @clsCols()
%26 = call i32 (...) @clsRows()
%27 = call i32 @usleep(i32 50000)
%28 = load i64, i64* %9
%29 = load i64, i64* %8
%30 = sub nsw i64 %28, %29
%31 = sitofp i64 %30 to double
%32 = load double, double* @CLOCKS_PER_SEC
%33 = fdiv double %31, %32
store double %33, double* %12
%34 = load i32, i32* %6
%35 = uitofp i32 %34 to double
%36 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %35)
%37 = load double, double* %12
%38 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %37)
%39 = load i32, i32* %6
%40 = uitofp i32 %39 to double
%41 = load double, double* %12
%42 = fdiv double %40, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %42)
ret i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [16 x i8] c"num frames: %i\0A\00"
@.str.1 = [13 x i8] c"seconds: %f\0A\00"
@.str.2 = [17 x i8] c"average FPS: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @setup_gpio()
%4 = tail call i32 (...) @setup()
%5 = tail call i64 (...) @clock()
%6 = tail call i64 (...) @clock()
%7 = tail call i32 (...) @clsCols()
%8 = tail call i32 (...) @clsRows()
%9 = tail call i32 @usleep(i32 50000)
%10 = sub nsw i64 %6, %5
%11 = sitofp i64 %10 to double
%12 = load double, double* @CLOCKS_PER_SEC
%13 = fdiv double %11, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double 0.000000e+00)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %13)
%16 = fdiv double 0.000000e+00, %13
%17 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %16)
ret i32 0
}