#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 */
int /*<<< orphan*/ comm_mpi();
int luby_mis(unsigned int, int const *, int);
scalar_t__ mpi_max_int(int /*<<< orphan*/, int);
unsigned luby_color(unsigned nneigh, int const neigh[]) {
  unsigned color;
  unsigned mycolor = 0;
  int colored;
  int in_set;
  colored = 0;
  color = 0;
  while (mpi_max_int(comm_mpi(), !colored)) {
    in_set = luby_mis(nneigh, neigh, !colored);
    if (in_set) {
      mycolor = color;
      colored = 1;
    }
    ++color;
  }
  return mycolor;
}


x86 assembly (clang, -O0):
<luby_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <comm_mpi@plt>
mov    %eax,%edi
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1030 <mpi_max_int@plt>
cmp    $0x0,%rax
je     11bc <luby_color+0x8c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
call   1050 <luby_mis@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11ae <luby_color+0x7e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <luby_color+0x24>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luby_color>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
xor    %r13d,%r13d
xor    %eax,%eax
call   1040 <comm_mpi@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <mpi_max_int@plt>
test   %rax,%rax
je     11ad <luby_color+0x7d>
mov    $0x1,%ebp
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <luby_mis@plt>
test   %eax,%eax
cmovne %ebx,%r13d
mov    $0x1,%eax
cmovne %eax,%r12d
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <comm_mpi@plt>
xor    %ebp,%ebp
test   %r12d,%r12d
sete   %bpl
mov    %eax,%edi
mov    %ebp,%esi
call   1030 <mpi_max_int@plt>
test   %rax,%rax
jne    1170 <luby_color+0x40>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @luby_color(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %5
br label %9
9: ; preds = %29, %2
%10 = call i32 (...) @comm_mpi()
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
%14 = zext i1 %13 to i32
%15 = call i64 @mpi_max_int(i32 %10, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %32
17: ; preds = %9
%18 = load i32, i32* %3
%19 = load i32*, i32** %4
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
%24 = call i32 @luby_mis(i32 %18, i32* %19, i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = load i32, i32* %5
store i32 %28, i32* %6
store i32 1, i32* %7
br label %29
29: ; preds = %27, %17
%30 = load i32, i32* %5
%31 = add i32 %30, 1
store i32 %31, i32* %5
br label %9
32: ; preds = %9
%33 = load i32, i32* %6
ret i32 %33
}

LLVM IR (-O2):
define i32 @luby_color(i32 %0, i32* %1) {
%3 = tail call i32 (...) @comm_mpi()
%4 = tail call i64 @mpi_max_int(i32 %3, i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %2, %6
%7 = phi i32 [ %18, %6 ], [ 1, %2 ]
%8 = phi i32 [ %15, %6 ], [ 0, %2 ]
%9 = phi i32 [ %14, %6 ], [ 0, %2 ]
%10 = phi i32 [ %13, %6 ], [ 0, %2 ]
%11 = tail call i32 @luby_mis(i32 %0, i32* %1, i32 %7)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 %10, i32 %8
%14 = select i1 %12, i32 %9, i32 1
%15 = add i32 %8, 1
%16 = tail call i32 (...) @comm_mpi()
%17 = icmp eq i32 %14, 0
%18 = zext i1 %17 to i32
%19 = tail call i64 @mpi_max_int(i32 %16, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %6, %2
%22 = phi i32 [ 0, %2 ], [ %13, %6 ]
ret i32 %22
}