#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 tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print_results(double pi, struct timeval start, struct timeval end) {
  printf("%lf\n", pi);
  int duration = ((end.tv_sec * 1000000 + end.tv_usec) -
                  (start.tv_sec * 1000000 + start.tv_usec));
  printf("%d\n", duration);
}


x86 assembly (clang, -O0):
<print_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%esi
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
imul   $0xf4240,-0x10(%rbp),%eax
add    -0xc(%rbp),%eax
imul   $0xf4240,-0x8(%rbp),%ecx
add    -0x4(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_results>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdi,%r12
shr    $0x20,%r12
mov    %rsi,%rbx
shr    $0x20,%rbx
cvttsd2si %xmm0,%esi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
sub    %r14d,%r15d
imul   $0xf4240,%r15d,%eax
sub    %r12d,%ebx
add    %eax,%ebx
lea    0xeb3(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @print_results(double %0, i64 %1, i64 %2) {
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca double
%7 = alloca i32
%8 = bitcast %struct.timeval* %4 to i64*
store i64 %1, i64* %8
%9 = bitcast %struct.timeval* %5 to i64*
store i64 %2, i64* %9
store double %0, double* %6
%10 = load double, double* %6
%11 = fptosi double %10 to i32
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%14 = load i32, i32* %13
%15 = mul nsw i32 %14, 1000000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%17 = load i32, i32* %16
%18 = add nsw i32 %15, %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = mul nsw i32 %20, 1000000
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%23 = load i32, i32* %22
%24 = add nsw i32 %21, %23
%25 = sub nsw i32 %18, %24
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @print_results(double %0, i64 %1, i64 %2) {
%4 = trunc i64 %1 to i32
%5 = lshr i64 %1, 32
%6 = trunc i64 %5 to i32
%7 = trunc i64 %2 to i32
%8 = lshr i64 %2, 32
%9 = trunc i64 %8 to i32
%10 = fptosi double %0 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = sub i32 %7, %4
%13 = mul i32 %12, 1000000
%14 = sub i32 %9, %6
%15 = add i32 %14, %13
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret void
}