#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 */
void GetEssentialImplicants(bool **primeChart, int cPrimeImplicants,
                            int cMinterms, bool *isEssential) {
  int i, j, nextEssential;
  for (j = 0; j < cMinterms; j++) {
    nextEssential = -1;
    for (i = 0; i < cPrimeImplicants; i++) {
      if (primeChart[i][j] == true) {
        if (nextEssential == -1)
          nextEssential = i;
        else {
          nextEssential = -1;
          break;
        }
      }
    }
    if (nextEssential != -1)
      isEssential[nextEssential] = true;
  }
}


x86 assembly (clang, -O0):
<GetEssentialImplicants>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11be <GetEssentialImplicants+0xbe>
movl   $0xffffffff,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1192 <GetEssentialImplicants+0x92>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    117f <GetEssentialImplicants+0x7f>
cmpl   $0xffffffff,-0x24(%rbp)
jne    116e <GetEssentialImplicants+0x6e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    117a <GetEssentialImplicants+0x7a>
movl   $0xffffffff,-0x24(%rbp)
jmp    1192 <GetEssentialImplicants+0x92>
jmp    117f <GetEssentialImplicants+0x7f>
jmp    1184 <GetEssentialImplicants+0x84>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <GetEssentialImplicants+0x33>
cmpl   $0xffffffff,-0x24(%rbp)
je     11ab <GetEssentialImplicants+0xab>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    11b0 <GetEssentialImplicants+0xb0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1119 <GetEssentialImplicants+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetEssentialImplicants>:
test   %edx,%edx
jle    1162 <GetEssentialImplicants+0x62>
mov    %edx,%r8d
mov    %esi,%r9d
xor    %r10d,%r10d
jmp    1119 <GetEssentialImplicants+0x19>
nop
add    $0x1,%r10
cmp    %r8,%r10
je     1162 <GetEssentialImplicants+0x62>
test   %esi,%esi
jle    1110 <GetEssentialImplicants+0x10>
mov    $0xffffffff,%r11d
xor    %eax,%eax
jmp    1139 <GetEssentialImplicants+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %rax,%r9
je     1150 <GetEssentialImplicants+0x50>
mov    (%rdi,%rax,8),%rdx
cmpl   $0x1,(%rdx,%r10,4)
jne    1130 <GetEssentialImplicants+0x30>
cmp    $0xffffffff,%r11d
jne    1110 <GetEssentialImplicants+0x10>
mov    %eax,%r11d
jmp    1130 <GetEssentialImplicants+0x30>
nop
cmp    $0xffffffff,%r11d
je     1110 <GetEssentialImplicants+0x10>
movslq %r11d,%rax
movl   $0x1,(%rcx,%rax,4)
jmp    1110 <GetEssentialImplicants+0x10>
ret

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

LLVM IR (-O2):
define void @GetEssentialImplicants(i32** nocapture %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %35
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %2 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %32
%11 = phi i64 [ 0, %6 ], [ %33, %32 ]
br i1 %7, label %12, label %32
12: ; preds = %10, %23
%13 = phi i64 [ %25, %23 ], [ 0, %10 ]
%14 = phi i32 [ %24, %23 ], [ -1, %10 ]
%15 = getelementptr inbounds i32*, i32** %0, i64 %13
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 %11
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = icmp eq i32 %14, -1
%22 = trunc i64 %13 to i32
br i1 %21, label %23, label %32
23: ; preds = %20, %12
%24 = phi i32 [ %14, %12 ], [ %22, %20 ]
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %12
27: ; preds = %23
%28 = icmp eq i32 %24, -1
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = sext i32 %24 to i64
%31 = getelementptr inbounds i32, i32* %3, i64 %30
store i32 1, i32* %31
br label %32
32: ; preds = %20, %10, %27, %29
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, %8
br i1 %34, label %35, label %10
35: ; preds = %32, %4
ret void
}