#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 double clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int color_cvd(char *, int);
int /*<<< orphan*/ printf(char *, ...);
void run_alg(char *mgph, int size) {
  clock_t t1, t2;
  static double maxduration = 0;
  t1 = clock();
  int res = color_cvd(mgph, size);
  t2 = clock();
  if (!res) {
    printf("FALSE with graph of size %d ", size);
    double duration = 1000.0 * (t2 - t1) / CLOCKS_PER_SEC;
    if (maxduration < duration)
      maxduration = duration;
    printf("in %.2f ms (%.2f ms max) ", duration, maxduration);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<run_alg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <color_cvd@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11f4 <run_alg+0xc4>
mov    -0xc(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  0xe6d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e4a(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0x2e91(%rip),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11cb <run_alg+0x9b>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,0x2e75(%rip)
movsd  -0x30(%rbp),%xmm0
movsd  0x2e68(%rip),%xmm1
lea    0xe46(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_alg>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <color_cvd@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <clock@plt>
test   %ebx,%ebx
je     1176 <run_alg+0x36>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe8b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  0xe60(%rip),%xmm0
mov    0x2e41(%rip),%rax
divsd  (%rax),%xmm0
movsd  0x2e95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c5 <run_alg+0x85>
movsd  %xmm0,0x2e87(%rip)
movapd %xmm0,%xmm1
lea    0xe59(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@run_alg.maxduration = internal global double 0.000000e+00
@.str = [29 x i8] c"FALSE with graph of size %d \00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [26 x i8] c"in %.2f ms (%.2f ms max) \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @run_alg(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = call double (...) @clock()
store double %9, double* %5
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @color_cvd(i8* %10, i32 %11)
store i32 %12, i32* %7
%13 = call double (...) @clock()
store double %13, double* %6
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %35, label %16
16: ; preds = %2
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load double, double* %6
%20 = load double, double* %5
%21 = fsub double %19, %20
%22 = fmul double 1.000000e+03, %21
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
store double %24, double* %8
%25 = load double, double* @run_alg.maxduration
%26 = load double, double* %8
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %30
28: ; preds = %16
%29 = load double, double* %8
store double %29, double* @run_alg.maxduration
br label %30
30: ; preds = %28, %16
%31 = load double, double* %8
%32 = load double, double* @run_alg.maxduration
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %31, double %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %30, %2
ret void
}

LLVM IR (-O2):
@run_alg.maxduration = internal unnamed_addr global double 0.000000e+00
@.str = [29 x i8] c"FALSE with graph of size %d \00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [26 x i8] c"in %.2f ms (%.2f ms max) \00"
define void @run_alg(i8* %0, i32 %1) {
%3 = tail call double (...) @clock()
%4 = tail call i32 @color_cvd(i8* %0, i32 %1)
%5 = tail call double (...) @clock()
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %1)
%9 = fsub double %5, %3
%10 = fmul double %9, 1.000000e+03
%11 = load double, double* @CLOCKS_PER_SEC
%12 = fdiv double %10, %11
%13 = load double, double* @run_alg.maxduration
%14 = fcmp olt double %13, %12
br i1 %14, label %15, label %16
15: ; preds = %7
store double %12, double* @run_alg.maxduration
br label %16
16: ; preds = %15, %7
%17 = phi double [ %12, %15 ], [ %13, %7 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %12, double %17)
%19 = tail call i32 @putchar(i32 10)
br label %20
20: ; preds = %16, %2
ret void
}