#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 */
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ print_result(long double);
int calculate_result(unsigned long chunk_size, long long total_loops,
                     long diff) {
  if (!diff)
    error("Zero time difference.");
  long double result = (long double)chunk_size;
  result *= (long double)total_loops;
  result *= 1000000.;
  result /= 1048576.;
  result /= (long double)diff;
  print_result(result);
  return (long)(10.0 * result);
}


x86 assembly (clang, -O0):
<calculate_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114b <calculate_result+0x2b>
lea    0xece(%rip),%rdi
call   1040 <error@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
test   %rax,%rax
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x50(%rbp)
lea    0xe98(%rip),%rax
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
fildll -0x48(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
flds   0xe7c(%rip)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
flds   0xe72(%rip)
fdivrp %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
fildll -0x40(%rbp)
fldt   -0x30(%rbp)
fdivp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <print_result@plt>
fldt   -0x30(%rbp)
flds   0xe48(%rip)
fmulp  %st,%st(1)
fnstcw -0x52(%rbp)
movzwl -0x52(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x54(%rbp)
fldcw  -0x54(%rbp)
fistpll -0x38(%rbp)
fldcw  -0x52(%rbp)
mov    -0x38(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_result>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdx,%rdx
jne    1143 <calculate_result+0x23>
lea    0xed6(%rip),%rdi
call   1040 <error@plt>
mov    %rbx,0x20(%rsp)
xor    %eax,%eax
test   %rbx,%rbx
sets   %al
fildll 0x20(%rsp)
lea    0xea5(%rip),%rcx
fadds  (%rcx,%rax,4)
mov    %r14,0x28(%rsp)
fildll 0x28(%rsp)
fmulp  %st,%st(1)
fmuls  0xe99(%rip)
fmuls  0xe97(%rip)
mov    %r15,0x30(%rsp)
fildll 0x30(%rsp)
fdivrp %st,%st(1)
fld    %st(0)
fstpt  0x44(%rsp)
fstpt  (%rsp)
call   1030 <print_result@plt>
fldt   0x44(%rsp)
fmuls  0xe78(%rip)
fnstcw 0x1c(%rsp)
movzwl 0x1c(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1e(%rsp)
fldcw  0x1e(%rsp)
fistpll 0x38(%rsp)
fldcw  0x1c(%rsp)
mov    0x38(%rsp),%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Zero time difference.\00"
define i32 @calculate_result(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca x86_fp80
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = icmp ne i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load i64, i64* %4
%14 = uitofp i64 %13 to x86_fp80
store x86_fp80 %14, x86_fp80* %7
%15 = load i64, i64* %5
%16 = sitofp i64 %15 to x86_fp80
%17 = load x86_fp80, x86_fp80* %7
%18 = fmul x86_fp80 %17, %16
store x86_fp80 %18, x86_fp80* %7
%19 = load x86_fp80, x86_fp80* %7
%20 = fmul x86_fp80 %19, 0xK4012F424000000000000
store x86_fp80 %20, x86_fp80* %7
%21 = load x86_fp80, x86_fp80* %7
%22 = fdiv x86_fp80 %21, 0xK40138000000000000000
store x86_fp80 %22, x86_fp80* %7
%23 = load i64, i64* %6
%24 = sitofp i64 %23 to x86_fp80
%25 = load x86_fp80, x86_fp80* %7
%26 = fdiv x86_fp80 %25, %24
store x86_fp80 %26, x86_fp80* %7
%27 = load x86_fp80, x86_fp80* %7
%28 = call i32 @print_result(x86_fp80 %27)
%29 = load x86_fp80, x86_fp80* %7
%30 = fmul x86_fp80 0xK4002A000000000000000, %29
%31 = fptosi x86_fp80 %30 to i64
%32 = trunc i64 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
@.str = [22 x i8] c"Zero time difference.\00"
define i32 @calculate_result(i64 %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = uitofp i64 %0 to x86_fp80
%9 = sitofp i64 %1 to x86_fp80
%10 = fmul x86_fp80 %8, %9
%11 = fmul x86_fp80 %10, 0xK4012F424000000000000
%12 = fmul x86_fp80 %11, 0xK3FEB8000000000000000
%13 = sitofp i64 %2 to x86_fp80
%14 = fdiv x86_fp80 %12, %13
%15 = tail call i32 @print_result(x86_fp80 %14)
%16 = fmul x86_fp80 %14, 0xK4002A000000000000000
%17 = fptosi x86_fp80 %16 to i64
%18 = trunc i64 %17 to i32
ret i32 %18
}