#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 extend_coloring(char *, int);
int /*<<< orphan*/ precolor_edges(char *, int, int *, int);
int /*<<< orphan*/ print_adjmatrix(int, char *);
int /*<<< orphan*/ printf(char *, ...);
void run_alg(char *mgph, int size, int cut_edges) {
  int colors[] = {1, 2, 3, 1, 2, 3};
  clock_t t1, t2;
  static double maxduration = 0;
  t1 = clock();
  printf("DEBUG size: %d\n", size);
  print_adjmatrix(size + cut_edges, mgph);
  printf("--------------------------\n");
  precolor_edges(mgph, size, colors, cut_edges);
  print_adjmatrix(size + cut_edges, mgph);
  int res = extend_coloring(mgph, size + cut_edges);
  printf("--------------------------\n");
  print_adjmatrix(size + cut_edges, mgph);
  t2 = clock();
  printf("Result: %s (%4d valid colorings) ", res ? "TRUE " : "FALSE", res);
  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    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <print_adjmatrix@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <precolor_edges@plt>
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <print_adjmatrix@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
call   1070 <extend_coloring@plt>
mov    %eax,-0x44(%rbp)
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <print_adjmatrix@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%ecx
lea    0xe58(%rip),%rsi
lea    0xe4b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x44(%rbp),%edx
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0xdab(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2d88(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0x2ddf(%rip),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    128d <run_alg+0x13d>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,0x2dc3(%rip)
movsd  -0x50(%rbp),%xmm0
movsd  0x2db6(%rip),%xmm1
lea    0xde1(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_alg>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0xe94(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe78(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe77(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    (%r14,%r15,1),%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <print_adjmatrix@plt>
lea    0xeb0(%rip),%r12
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%ecx
call   1080 <precolor_edges@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <print_adjmatrix@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1090 <extend_coloring@plt>
mov    %eax,%r14d
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <print_adjmatrix@plt>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,(%rsp)
test   %r14d,%r14d
lea    0xe36(%rip),%rax
lea    0xe29(%rip),%rsi
cmove  %rax,%rsi
lea    0xdfc(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xda7(%rip),%xmm0
mov    0x2d88(%rip),%rax
divsd  (%rax),%xmm0
movsd  0x2df4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    127e <run_alg+0x10e>
movsd  %xmm0,0x2de6(%rip)
movapd %xmm0,%xmm1
lea    0xde1(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.run_alg.colors = [6 x i32] [i32 1, i32 2, i32 3, i32 1, i32 2, i32 3]
@run_alg.maxduration = internal global double 0.000000e+00
@.str = [16 x i8] c"DEBUG size: %d\0A\00"
@.str.1 = [28 x i8] c"--------------------------\0A\00"
@.str.2 = [34 x i8] c"Result: %s (%4d valid colorings) \00"
@.str.3 = [6 x i8] c"TRUE \00"
@.str.4 = [6 x i8] c"FALSE\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.5 = [26 x i8] c"in %.2f ms (%.2f ms max) \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @run_alg(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [6 x i32]
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = bitcast [6 x i32]* %7 to i8*
%13 = call double (...) @clock()
store double %13, double* %8
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = add nsw i32 %16, %17
%19 = load i8*, i8** %4
%20 = call i32 @print_adjmatrix(i32 %18, i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%25 = load i32, i32* %6
%26 = call i32 @precolor_edges(i8* %22, i32 %23, i32* %24, i32 %25)
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = add nsw i32 %27, %28
%30 = load i8*, i8** %4
%31 = call i32 @print_adjmatrix(i32 %29, i8* %30)
%32 = load i8*, i8** %4
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
%36 = call i32 @extend_coloring(i8* %32, i32 %35)
store i32 %36, i32* %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = add nsw i32 %38, %39
%41 = load i8*, i8** %4
%42 = call i32 @print_adjmatrix(i32 %40, i8* %41)
%43 = call double (...) @clock()
store double %43, double* %9
%44 = load i32, i32* %10
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%48 = load i32, i32* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %47, i32 %48)
%50 = load double, double* %9
%51 = load double, double* %8
%52 = fsub double %50, %51
%53 = fmul double 1.000000e+03, %52
%54 = load double, double* @CLOCKS_PER_SEC
%55 = fdiv double %53, %54
store double %55, double* %11
%56 = load double, double* @run_alg.maxduration
%57 = load double, double* %11
%58 = fcmp olt double %56, %57
br i1 %58, label %59, label %61
59: ; preds = %3
%60 = load double, double* %11
store double %60, double* @run_alg.maxduration
br label %61
61: ; preds = %59, %3
%62 = load double, double* %11
%63 = load double, double* @run_alg.maxduration
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), double %62, double %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.run_alg.colors = [6 x i32] [i32 1, i32 2, i32 3, i32 1, i32 2, i32 3]
@run_alg.maxduration = internal unnamed_addr global double 0.000000e+00
@.str = [16 x i8] c"DEBUG size: %d\0A\00"
@.str.2 = [34 x i8] c"Result: %s (%4d valid colorings) \00"
@.str.3 = [6 x i8] c"TRUE \00"
@.str.4 = [6 x i8] c"FALSE\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.5 = [26 x i8] c"in %.2f ms (%.2f ms max) \00"
@str.7 = [27 x i8] c"--------------------------\00"
define void @run_alg(i8* %0, i32 %1, i32 %2) {
%4 = alloca [6 x i32]
%5 = bitcast [6 x i32]* %4 to i8*
%6 = tail call double (...) @clock()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %1)
%8 = add nsw i32 %2, %1
%9 = tail call i32 @print_adjmatrix(i32 %8, i8* %0)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%12 = call i32 @precolor_edges(i8* %0, i32 %1, i32* %11, i32 %2)
%13 = call i32 @print_adjmatrix(i32 %8, i8* %0)
%14 = call i32 @extend_coloring(i8* %0, i32 %8)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%16 = call i32 @print_adjmatrix(i32 %8, i8* %0)
%17 = call double (...) @clock()
%18 = icmp eq i32 %14, 0
%19 = select i1 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32 %14)
%21 = fsub double %17, %6
%22 = fmul double %21, 1.000000e+03
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = load double, double* @run_alg.maxduration
%26 = fcmp olt double %25, %24
br i1 %26, label %27, label %28
27: ; preds = %3
store double %24, double* @run_alg.maxduration
br label %28
28: ; preds = %27, %3
%29 = phi double [ %24, %27 ], [ %25, %3 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), double %24, double %29)
%31 = call i32 @putchar(i32 10)
ret void
}