#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*/ print_libco_opts();
int /*<<< orphan*/ printf(char *, double);
double time_co_switch();
double time_func();
int main(void) {
  double func_rate = time_func();
  double co_rate = time_co_switch();
  print_libco_opts();
  printf("%6.2f M function calls per sec\n", func_rate / 1000000);
  printf("%6.2f M co_switch()x2  per sec\n", co_rate / 1000000);
  printf("Function call is %.1fX faster than two co_switch() calls.\n\n",
         func_rate / co_rate);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <time_func@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <time_co_switch@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <print_libco_opts@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <time_func@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <time_co_switch@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <print_libco_opts@plt>
movsd  0x10(%rsp),%xmm0
divsd  0xe8d(%rip),%xmm0
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xe73(%rip),%xmm0
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%6.2f M function calls per sec\0A\00"
@.str.1 = [32 x i8] c"%6.2f M co_switch()x2 per sec\0A\00"
@.str.2 = [60 x i8] c"Function call is %.1fX faster than two co_switch() calls.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call double (...) @time_func()
store double %4, double* %2
%5 = call double (...) @time_co_switch()
store double %5, double* %3
%6 = call i32 (...) @print_libco_opts()
%7 = load double, double* %2
%8 = fdiv double %7, 1.000000e+06
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %8)
%10 = load double, double* %3
%11 = fdiv double %10, 1.000000e+06
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = load double, double* %2
%14 = load double, double* %3
%15 = fdiv double %13, %14
%16 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"%6.2f M function calls per sec\0A\00"
@.str.1 = [32 x i8] c"%6.2f M co_switch()x2 per sec\0A\00"
@.str.2 = [60 x i8] c"Function call is %.1fX faster than two co_switch() calls.\0A\0A\00"
define i32 @main() {
%1 = tail call double (...) @time_func()
%2 = tail call double (...) @time_co_switch()
%3 = tail call i32 (...) @print_libco_opts()
%4 = fdiv double %1, 1.000000e+06
%5 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %4)
%6 = fdiv double %2, 1.000000e+06
%7 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %6)
%8 = fdiv double %1, %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), double %8)
ret i32 0
}