#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*/ printf(char *, ...);
double run_parallel();
double run_serial();
int main(int argc, char **argv) {
  printf("Integration by trapezoidal rule\n");
  double tserial = run_serial();
  double tparallel = run_parallel();
  printf("Execution time (serial): %.6f\n", tserial);
  printf("Execution time (parallel): %.6f\n", tparallel);
  printf("Speedup: %.2f\n", tserial / tparallel);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <run_serial@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <run_parallel@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xea9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
lea    0xebe(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <run_serial@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <run_parallel@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe8f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xe9b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Integration by trapezoidal rule\0A\00"
@.str.1 = [31 x i8] c"Execution time (serial): %.6f\0A\00"
@.str.2 = [33 x i8] c"Execution time (parallel): %.6f\0A\00"
@.str.3 = [15 x i8] c"Speedup: %.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = call double (...) @run_serial()
store double %9, double* %6
%10 = call double (...) @run_parallel()
store double %10, double* %7
%11 = load double, double* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = load double, double* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = load double, double* %6
%16 = load double, double* %7
%17 = fdiv double %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %17)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Execution time (serial): %.6f\0A\00"
@.str.2 = [33 x i8] c"Execution time (parallel): %.6f\0A\00"
@.str.3 = [15 x i8] c"Speedup: %.2f\0A\00"
@str = [32 x i8] c"Integration by trapezoidal rule\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @run_serial()
%5 = tail call double (...) @run_parallel()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), double %4)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %5)
%8 = fdiv double %4, %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %8)
ret i32 0
}