#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double pi_parallel(int, unsigned long long);
int /*<<< orphan*/ print_results(double, struct timeval, struct timeval);
int /*<<< orphan*/ scanf(char *, int *, unsigned long long *);
int main() {
  int nthreads;
  unsigned long long n;
  struct timeval start, end;
  double pi;
  scanf("%d %llu", &nthreads, &n);
  gettimeofday(&start, NULL);
  pi = pi_parallel(nthreads, n);
  gettimeofday(&end, NULL);
  print_results(pi, start, end);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <scanf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <pi_parallel@plt>
movsd  %xmm0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <print_results@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xeb5(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1050 <scanf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x14(%rsp),%edi
mov    0x20(%rsp),%rsi
call   1060 <pi_parallel@plt>
movsd  %xmm0,0x18(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
movsd  0x18(%rsp),%xmm0
call   1030 <print_results@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [8 x i8] c"%d %llu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %2, i64* %3)
%8 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%9 = load i32, i32* %2
%10 = load i64, i64* %3
%11 = call double @pi_parallel(i32 %9, i64 %10)
store double %11, double* %6
%12 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%13 = load double, double* %6
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @print_results(double %13, i32 %15, i32 %17)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [8 x i8] c"%d %llu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast i32* %1 to i8*
%6 = bitcast i64* %2 to i8*
%7 = bitcast %struct.timeval* %3 to i8*
%8 = bitcast %struct.timeval* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %1, i64* %2)
%10 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%11 = load i32, i32* %1
%12 = load i64, i64* %2
%13 = call double @pi_parallel(i32 %11, i64 %12)
%14 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @print_results(double %13, i32 %16, i32 %18)
ret i32 0
}