#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();
long getIOPS(void) {
  long i, j, k, lim;
  double result;
  lim = 100000000;
  clock_t begin, end;
  j = 10;
  begin = clock();
  for (i = 0; i < lim; i++) {
    k = i % j;
  }
  end = clock();
  result = (double)(end - begin) / CLOCKS_PER_SEC;
  k = (long)lim / result;
  return k;
}


x86 assembly (clang, -O0):
<getIOPS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x5f5e100,-0x20(%rbp)
05
movq   $0xa,-0x10(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1168 <getIOPS+0x58>
mov    -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113b <getIOPS+0x2b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e61(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdq -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIOPS>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2eb7(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xec3(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
pop    %rbx
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define i64 @getIOPS() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
store i64 100000000, i64* %4
store i64 10, i64* %2
%8 = call i64 (...) @clock()
store i64 %8, i64* %6
store i64 0, i64* %1
br label %9
9: ; preds = %17, %0
%10 = load i64, i64* %1
%11 = load i64, i64* %4
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i64, i64* %1
%15 = load i64, i64* %2
%16 = srem i64 %14, %15
store i64 %16, i64* %3
br label %17
17: ; preds = %13
%18 = load i64, i64* %1
%19 = add nsw i64 %18, 1
store i64 %19, i64* %1
br label %9
20: ; preds = %9
%21 = call i64 (...) @clock()
store i64 %21, i64* %7
%22 = load i64, i64* %7
%23 = load i64, i64* %6
%24 = sub nsw i64 %22, %23
%25 = sitofp i64 %24 to double
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
store double %27, double* %5
%28 = load i64, i64* %4
%29 = sitofp i64 %28 to double
%30 = load double, double* %5
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i64
store i64 %32, i64* %3
%33 = load i64, i64* %3
ret i64 %33
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define i64 @getIOPS() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sub nsw i64 %2, %1
%4 = sitofp i64 %3 to double
%5 = load double, double* @CLOCKS_PER_SEC
%6 = fdiv double %4, %5
%7 = fdiv double 1.000000e+08, %6
%8 = fptosi double %7 to i64
ret i64 %8
}