#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double);
void elapsed_time(int start_new_turn) {
  static clock_t interval;
  if (start_new_turn) {
    interval = clock();
  } else {
    interval = clock() - interval;
    printf("\nWell done in %.3f seconds.\n\n",
           (double)interval / CLOCKS_PER_SEC);
    interval = 0;
  }
}


x86 assembly (clang, -O0):
<elapsed_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1148 <elapsed_time+0x28>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,0x2ef5(%rip)
jmp    1188 <elapsed_time+0x68>
mov    $0x0,%al
call   1030 <clock@plt>
sub    0x2ee2(%rip),%rax
mov    %rax,0x2edb(%rip)
cvtsi2sdq 0x2ed2(%rip),%xmm0
mov    0x2e7b(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,0x2eb0(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elapsed_time>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
test   %ebx,%ebx
jne    115a <elapsed_time+0x3a>
sub    0x2f03(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    %rax,0x2ef7(%rip)
mov    0x2ea0(%rip),%rax
divsd  (%rax),%xmm0
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %rax,0x2ed7(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@elapsed_time.interval = internal global i64 0
@.str = [30 x i8] c"\0AWell done in %.3f seconds.\0A\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @elapsed_time(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i64 (...) @clock()
store i64 %6, i64* @elapsed_time.interval
br label %16
7: ; preds = %1
%8 = call i64 (...) @clock()
%9 = load i64, i64* @elapsed_time.interval
%10 = sub nsw i64 %8, %9
store i64 %10, i64* @elapsed_time.interval
%11 = load i64, i64* @elapsed_time.interval
%12 = sitofp i64 %11 to double
%13 = load double, double* @CLOCKS_PER_SEC
%14 = fdiv double %12, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %14)
store i64 0, i64* @elapsed_time.interval
br label %16
16: ; preds = %7, %5
ret void
}

LLVM IR (-O2):
@elapsed_time.interval = internal unnamed_addr global i64 0
@.str = [30 x i8] c"\0AWell done in %.3f seconds.\0A\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @elapsed_time(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = tail call i64 (...) @clock()
br i1 %2, label %4, label %11
4: ; preds = %1
%5 = load i64, i64* @elapsed_time.interval
%6 = sub nsw i64 %3, %5
store i64 %6, i64* @elapsed_time.interval
%7 = sitofp i64 %6 to double
%8 = load double, double* @CLOCKS_PER_SEC
%9 = fdiv double %7, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %9)
br label %11
11: ; preds = %1, %4
%12 = phi i64 [ 0, %4 ], [ %3, %1 ]
store i64 %12, i64* @elapsed_time.interval
ret void
}