#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 int uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ check_cnf(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int reduce_by_clause(int *, int /*<<< orphan*/ *, int);
scalar_t__ remove_redundant_clauses(int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ show_clauses(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ show_compact_mask(int *);
int /*<<< orphan*/ stdout;
void make_cnf(int32_t b[8], uint32_t m[8]) {
  uint32_t i, changed;
  for (i = 0; i < 8; i++) {
    m[i] = 0x0f;
  }
  printf("Initial clauses:\n");
  show_clauses(b, m);
  printf("\n");
  do {
    changed = false;
    for (i = 0; i < 8; i++) {
      if (m[i] != 0) {
        changed |= reduce_by_clause(m, b, i);
      }
    }
  } while (changed);
  printf("Simplified clauses:\n");
  show_clauses(b, m);
  show_compact_mask(m);
  printf("\n");
  if (!check_cnf(b, m)) {
    printf("BUG: invalid CNF conversion\n");
    fflush(stdout);
    exit(1);
  }
  while (remove_redundant_clauses(m, b))
    ;
  printf("Reduced clause set:\n");
  show_clauses(b, m);
  show_compact_mask(m);
  printf("\n");
  if (!check_cnf(b, m)) {
    printf("BUG: invalid CNF conversion\n");
    fflush(stdout);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<make_cnf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11be <make_cnf+0x3e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xf,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <make_cnf+0x17>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <show_clauses@plt>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1236 <make_cnf+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1223 <make_cnf+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10a0 <reduce_by_clause@plt>
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1228 <make_cnf+0xa8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f1 <make_cnf+0x71>
jmp    123b <make_cnf+0xbb>
cmpl   $0x0,-0x18(%rbp)
jne    11e3 <make_cnf+0x63>
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <show_clauses@plt>
mov    -0x10(%rbp),%rdi
call   1040 <show_compact_mask@plt>
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <check_cnf@plt>
cmp    $0x0,%eax
jne    12ad <make_cnf+0x12d>
lea    0xd97(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12b2 <make_cnf+0x132>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <remove_redundant_clauses@plt>
cmp    $0x0,%rax
je     12ce <make_cnf+0x14e>
jmp    12b2 <make_cnf+0x132>
lea    0xd6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <show_clauses@plt>
mov    -0x10(%rbp),%rdi
call   1040 <show_compact_mask@plt>
lea    0xd2e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <check_cnf@plt>
cmp    $0x0,%eax
jne    1336 <make_cnf+0x1b6>
lea    0xd0e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_cnf>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movaps 0xe5f(%rip),%xmm0
movups %xmm0,(%rsi)
movups %xmm0,0x10(%rsi)
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <show_clauses@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11d8 <make_cnf+0x48>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
je     12a2 <make_cnf+0x112>
cmpl   $0x0,(%rbx)
mov    $0x0,%ebp
je     11f1 <make_cnf+0x61>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   10b0 <reduce_by_clause@plt>
mov    %eax,%ebp
cmpl   $0x0,0x4(%rbx)
je     1209 <make_cnf+0x79>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0x8(%rbx)
je     1221 <make_cnf+0x91>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0xc(%rbx)
je     1239 <make_cnf+0xa9>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0x10(%rbx)
je     1251 <make_cnf+0xc1>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0x14(%rbx)
je     1269 <make_cnf+0xd9>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0x18(%rbx)
je     1281 <make_cnf+0xf1>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
cmpl   $0x0,0x1c(%rbx)
je     11d0 <make_cnf+0x40>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   10b0 <reduce_by_clause@plt>
or     %eax,%ebp
jmp    11d0 <make_cnf+0x40>
lea    0xd78(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <show_clauses@plt>
mov    %rbx,%rdi
call   1050 <show_compact_mask@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <check_cnf@plt>
test   %eax,%eax
je     132d <make_cnf+0x19d>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <remove_redundant_clauses@plt>
test   %rax,%rax
jne    12e0 <make_cnf+0x150>
lea    0xd3e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <show_clauses@plt>
mov    %rbx,%rdi
call   1050 <show_compact_mask@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <check_cnf@plt>
test   %eax,%eax
je     132d <make_cnf+0x19d>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd15(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Initial clauses:\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [21 x i8] c"Simplified clauses:\0A\00"
@.str.3 = [29 x i8] c"BUG: invalid CNF conversion\0A\00"
@stdout = global i32 0
@.str.4 = [21 x i8] c"Reduced clause set:\0A\00"
define void @make_cnf(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %15, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 15, i32* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %7
18: ; preds = %7
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = load i32*, i32** %4
%22 = call i32 @show_clauses(i32* %20, i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %47, %18
store i32 0, i32* %6
store i32 0, i32* %5
br label %25
25: ; preds = %43, %24
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 8
br i1 %27, label %28, label %46
28: ; preds = %25
%29 = load i32*, i32** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %28
%36 = load i32*, i32** %4
%37 = load i32*, i32** %3
%38 = load i32, i32* %5
%39 = call i32 @reduce_by_clause(i32* %36, i32* %37, i32 %38)
%40 = load i32, i32* %6
%41 = or i32 %40, %39
store i32 %41, i32* %6
br label %42
42: ; preds = %35, %28
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %25
46: ; preds = %25
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = icmp ne i32 %48, 0
br i1 %49, label %24, label %50
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32*, i32** %3
%53 = load i32*, i32** %4
%54 = call i32 @show_clauses(i32* %52, i32* %53)
%55 = load i32*, i32** %4
%56 = call i32 @show_compact_mask(i32* %55)
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%58 = load i32*, i32** %3
%59 = load i32*, i32** %4
%60 = call i32 @check_cnf(i32* %58, i32* %59)
%61 = icmp ne i32 %60, 0
br i1 %61, label %67, label %62
62: ; preds = %50
%63 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%64 = load i32, i32* @stdout
%65 = call i32 @fflush(i32 %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %50
br label %68
68: ; preds = %73, %67
%69 = load i32*, i32** %4
%70 = load i32*, i32** %3
%71 = call i64 @remove_redundant_clauses(i32* %69, i32* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %68
br label %68
74: ; preds = %68
%75 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32*, i32** %3
%77 = load i32*, i32** %4
%78 = call i32 @show_clauses(i32* %76, i32* %77)
%79 = load i32*, i32** %4
%80 = call i32 @show_compact_mask(i32* %79)
%81 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%82 = load i32*, i32** %3
%83 = load i32*, i32** %4
%84 = call i32 @check_cnf(i32* %82, i32* %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %91, label %86
86: ; preds = %74
%87 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%88 = load i32, i32* @stdout
%89 = call i32 @fflush(i32 %88)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %74
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [17 x i8] c"Initial clauses:\00"
@str.5 = [20 x i8] c"Simplified clauses:\00"
@str.7 = [20 x i8] c"Reduced clause set:\00"
@str.8 = [28 x i8] c"BUG: invalid CNF conversion\00"
define void @make_cnf(i32* %0, i32* %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = getelementptr inbounds i32, i32* %1, i64 2
%5 = getelementptr inbounds i32, i32* %1, i64 3
%6 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 15, i32 15, i32 15, i32 15>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %1, i64 4
%8 = getelementptr inbounds i32, i32* %1, i64 5
%9 = getelementptr inbounds i32, i32* %1, i64 6
%10 = getelementptr inbounds i32, i32* %1, i64 7
%11 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 15, i32 15, i32 15, i32 15>, <4 x i32>* %11
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @show_clauses(i32* %0, i32* %1)
%14 = tail call i32 @putchar(i32 10)
br label %15
15: ; preds = %69, %2
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 0)
br label %20
20: ; preds = %15, %18
%21 = phi i32 [ %19, %18 ], [ 0, %15 ]
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 1)
%26 = or i32 %25, %21
br label %27
27: ; preds = %24, %20
%28 = phi i32 [ %26, %24 ], [ %21, %20 ]
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 2)
%33 = or i32 %32, %28
br label %34
34: ; preds = %31, %27
%35 = phi i32 [ %33, %31 ], [ %28, %27 ]
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 3)
%40 = or i32 %39, %35
br label %41
41: ; preds = %38, %34
%42 = phi i32 [ %40, %38 ], [ %35, %34 ]
%43 = load i32, i32* %7
%44 = icmp eq i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %41
%46 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 4)
%47 = or i32 %46, %42
br label %48
48: ; preds = %45, %41
%49 = phi i32 [ %47, %45 ], [ %42, %41 ]
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 0
br i1 %51, label %55, label %52
52: ; preds = %48
%53 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 5)
%54 = or i32 %53, %49
br label %55
55: ; preds = %52, %48
%56 = phi i32 [ %54, %52 ], [ %49, %48 ]
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %55
%60 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 6)
%61 = or i32 %60, %56
br label %62
62: ; preds = %59, %55
%63 = phi i32 [ %61, %59 ], [ %56, %55 ]
%64 = load i32, i32* %10
%65 = icmp eq i32 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %62
%67 = tail call i32 @reduce_by_clause(i32* %1, i32* %0, i32 7)
%68 = or i32 %67, %63
br label %69
69: ; preds = %66, %62
%70 = phi i32 [ %68, %66 ], [ %63, %62 ]
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %15
72: ; preds = %69
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%74 = tail call i32 @show_clauses(i32* %0, i32* %1)
%75 = tail call i32 @show_compact_mask(i32* %1)
%76 = tail call i32 @putchar(i32 10)
%77 = tail call i32 @check_cnf(i32* %0, i32* %1)
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %72
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%81 = load i32, i32* @stdout
%82 = tail call i32 @fflush(i32 %81)
%83 = tail call i32 @exit(i32 1)
unreachable
84: ; preds = %72, %84
%85 = tail call i64 @remove_redundant_clauses(i32* %1, i32* %0)
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %84
87: ; preds = %84
%88 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%89 = tail call i32 @show_clauses(i32* %0, i32* %1)
%90 = tail call i32 @show_compact_mask(i32* %1)
%91 = tail call i32 @putchar(i32 10)
%92 = tail call i32 @check_cnf(i32* %0, i32* %1)
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %87
%95 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%96 = load i32, i32* @stdout
%97 = tail call i32 @fflush(i32 %96)
%98 = tail call i32 @exit(i32 1)
unreachable
99: ; preds = %87
ret void
}