#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 convert_bitwise(long);
long poss_matches(int *, int);
int simple_iterate(int board[]) {
  int found_match = 0;
  for (int i = 0; i < 81; i++) {
    long match = poss_matches(board, i);
    int power_of_two = match && !(match & (match - 1));
    if (power_of_two) {
      board[i] = convert_bitwise(match);
      found_match = 1;
    }
  }
  return found_match;
}


x86 assembly (clang, -O0):
<simple_iterate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x51,-0x10(%rbp)
jge    11c4 <simple_iterate+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <poss_matches@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
je     117f <simple_iterate+0x5f>
mov    -0x18(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b1 <simple_iterate+0x91>
mov    -0x18(%rbp),%rdi
call   1030 <convert_bitwise@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x1,-0xc(%rbp)
jmp    11b6 <simple_iterate+0x96>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <simple_iterate+0x1a>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_iterate>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    113a <simple_iterate+0x1a>
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x51,%rbx
je     116b <simple_iterate+0x4b>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <poss_matches@plt>
lea    -0x1(%rax),%rcx
test   %rcx,%rax
setne  %cl
test   %rax,%rax
sete   %dl
or     %cl,%dl
jne    1130 <simple_iterate+0x10>
mov    %rax,%rdi
call   1030 <convert_bitwise@plt>
mov    %eax,(%r14,%rbx,4)
mov    $0x1,%ebp
jmp    1130 <simple_iterate+0x10>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @simple_iterate(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %36, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 81
br i1 %9, label %10, label %39
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = load i32, i32* %4
%13 = call i64 @poss_matches(i32* %11, i32 %12)
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i64, i64* %5
%18 = load i64, i64* %5
%19 = sub nsw i64 %18, 1
%20 = and i64 %17, %19
%21 = icmp ne i64 %20, 0
%22 = xor i1 %21, true
br label %23
23: ; preds = %16, %10
%24 = phi i1 [ false, %10 ], [ %22, %16 ]
%25 = zext i1 %24 to i32
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i64, i64* %5
%30 = call i32 @convert_bitwise(i64 %29)
%31 = load i32*, i32** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 %30, i32* %34
store i32 1, i32* %3
br label %35
35: ; preds = %28, %23
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %7
39: ; preds = %7
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @simple_iterate(i32* %0) {
br label %3
2: ; preds = %13
ret i32 %14
3: ; preds = %1, %13
%4 = phi i64 [ 0, %1 ], [ %15, %13 ]
%5 = phi i32 [ 0, %1 ], [ %14, %13 ]
%6 = trunc i64 %4 to i32
%7 = tail call i64 @poss_matches(i32* %0, i32 %6)
%8 = tail call i64 @llvm.ctpop.i64(i64 %7)
%9 = icmp eq i64 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = tail call i32 @convert_bitwise(i64 %7)
%12 = getelementptr inbounds i32, i32* %0, i64 %4
store i32 %11, i32* %12
br label %13
13: ; preds = %3, %10
%14 = phi i32 [ 1, %10 ], [ %5, %3 ]
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 81
br i1 %16, label %2, label %3
}