#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 */

/* Variables and functions */
scalar_t__ isSafe(int, int, int *, int **);
int graphColoring(int ver, int **graph, int m, int solution[], int C) {
  if (ver == C)
    return 1;
  for (int col = 1; col <= m; col++) {
    if (isSafe(ver, col, solution, graph)) {
      solution[ver] = col;
      if (graphColoring(ver + 1, graph, m, solution, C))
        return 1;
      else
        solution[ver] = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<graphColoring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1152 <graphColoring+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11ed <graphColoring+0xcd>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11e6 <graphColoring+0xc6>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1040 <isSafe@plt>
cmp    $0x0,%rax
je     11d3 <graphColoring+0xb3>
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <graphColoring@plt>
cmp    $0x0,%eax
je     11bf <graphColoring+0x9f>
movl   $0x1,-0x4(%rbp)
jmp    11ed <graphColoring+0xcd>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11d3 <graphColoring+0xb3>
jmp    11d8 <graphColoring+0xb8>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1159 <graphColoring+0x39>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<graphColoring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%eax
mov    %r8d,0x4(%rsp)
mov    %rdi,0x8(%rsp)
cmp    %r8d,%edi
je     11e9 <graphColoring+0xc9>
mov    %edx,%ebp
test   %edx,%edx
jle    11dc <graphColoring+0xbc>
mov    %rcx,%rbx
mov    %rsi,%r15
mov    0x8(%rsp),%rax
movslq %eax,%r14
add    $0x1,%eax
mov    %eax,(%rsp)
mov    %ebp,%eax
neg    %eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r13d
xor    %r12d,%r12d
jmp    119d <graphColoring+0x7d>
nopl   0x0(%rax,%rax,1)
cmp    %ebp,%r13d
mov    0x10(%rsp),%rax
lea    0x1(%rax,%r13,1),%eax
lea    0x1(%r13),%ecx
setge  %r12b
mov    %ecx,%r13d
cmp    $0x1,%eax
je     11df <graphColoring+0xbf>
mov    0x8(%rsp),%rdi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1040 <isSafe@plt>
test   %rax,%rax
je     1180 <graphColoring+0x60>
mov    %r13d,(%rbx,%r14,4)
mov    (%rsp),%edi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    0x4(%rsp),%r8d
call   1030 <graphColoring@plt>
test   %eax,%eax
jne    11df <graphColoring+0xbf>
movl   $0x0,(%rbx,%r14,4)
jmp    1180 <graphColoring+0x60>
mov    $0x1,%r12b
not    %r12b
movzbl %r12b,%eax
and    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @graphColoring(i32 %0, i32** %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i32** %1, i32*** %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%13 = load i32, i32* %7
%14 = load i32, i32* %11
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %5
store i32 1, i32* %6
br label %55
17: ; preds = %5
store i32 1, i32* %12
br label %18
18: ; preds = %51, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %9
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %54
22: ; preds = %18
%23 = load i32, i32* %7
%24 = load i32, i32* %12
%25 = load i32*, i32** %10
%26 = load i32**, i32*** %8
%27 = call i64 @isSafe(i32 %23, i32 %24, i32* %25, i32** %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %50
29: ; preds = %22
%30 = load i32, i32* %12
%31 = load i32*, i32** %10
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 %30, i32* %34
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
%37 = load i32**, i32*** %8
%38 = load i32, i32* %9
%39 = load i32*, i32** %10
%40 = load i32, i32* %11
%41 = call i32 @graphColoring(i32 %36, i32** %37, i32 %38, i32* %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %29
store i32 1, i32* %6
br label %55
44: ; preds = %29
%45 = load i32*, i32** %10
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
store i32 0, i32* %48
br label %49
49: ; preds = %44
br label %50
50: ; preds = %49, %22
br label %51
51: ; preds = %50
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
br label %18
54: ; preds = %18
store i32 0, i32* %6
br label %55
55: ; preds = %54, %43, %16
%56 = load i32, i32* %6
ret i32 %56
}

LLVM IR (-O2):
define i32 @graphColoring(i32 %0, i32** %1, i32 %2, i32* %3, i32 %4) {
%6 = icmp eq i32 %0, %4
br i1 %6, label %30, label %7
7: ; preds = %5
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds i32, i32* %3, i64 %8
%10 = icmp slt i32 %2, 1
br i1 %10, label %26, label %11
11: ; preds = %7
%12 = add nsw i32 %0, 1
br label %13
13: ; preds = %11, %22
%14 = phi i1 [ false, %11 ], [ %24, %22 ]
%15 = phi i32 [ 1, %11 ], [ %23, %22 ]
%16 = tail call i64 @isSafe(i32 %0, i32 %15, i32* %3, i32** %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %13
store i32 %15, i32* %9
%19 = tail call i32 @graphColoring(i32 %12, i32** %1, i32 %2, i32* %3, i32 %4)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
store i32 0, i32* %9
br label %22
22: ; preds = %13, %21
%23 = add nuw i32 %15, 1
%24 = icmp sge i32 %15, %2
%25 = icmp eq i32 %15, %2
br i1 %25, label %26, label %13
26: ; preds = %22, %18, %7
%27 = phi i1 [ true, %7 ], [ %14, %18 ], [ %24, %22 ]
%28 = xor i1 %27, true
%29 = zext i1 %28 to i32
br label %30
30: ; preds = %26, %5
%31 = phi i32 [ 1, %5 ], [ %29, %26 ]
ret i32 %31
}