#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 */
struct BoolExpr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ BX_DecRef(struct BoolExpr *);
struct BoolExpr *BX_IncRef(struct BoolExpr *);
scalar_t__ BX_IsDNF(struct BoolExpr *);
struct BoolExpr *BX_ToDNF(struct BoolExpr *);
struct BoolExpr *_complete_sum(struct BoolExpr *);
struct BoolExpr *BX_CompleteSum(struct BoolExpr *ex) {
  struct BoolExpr *dnf;
  struct BoolExpr *sum;
  if (BX_IsDNF(ex))
    dnf = BX_IncRef(ex);
  else
    do {
      if ((dnf = BX_ToDNF(ex)) == NULL)
        return NULL;
    } while (0);
  do {
    if ((sum = _complete_sum(dnf)) == NULL) {
      BX_DecRef(dnf);
      return NULL;
    }
  } while (0);
  BX_DecRef(dnf);
  return sum;
}


x86 assembly (clang, -O0):
<BX_CompleteSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <BX_IsDNF@plt>
cmp    $0x0,%rax
je     1181 <BX_CompleteSum+0x31>
mov    -0x10(%rbp),%rdi
call   1060 <BX_IncRef@plt>
mov    %rax,-0x18(%rbp)
jmp    11b4 <BX_CompleteSum+0x64>
jmp    1186 <BX_CompleteSum+0x36>
mov    -0x10(%rbp),%rdi
call   1040 <BX_ToDNF@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11aa <BX_CompleteSum+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    11fc <BX_CompleteSum+0xac>
jmp    11af <BX_CompleteSum+0x5f>
jmp    11b4 <BX_CompleteSum+0x64>
jmp    11b9 <BX_CompleteSum+0x69>
mov    -0x18(%rbp),%rdi
call   1070 <_complete_sum@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e6 <BX_CompleteSum+0x96>
mov    -0x18(%rbp),%rdi
call   1050 <BX_DecRef@plt>
movq   $0x0,-0x8(%rbp)
jmp    11fc <BX_CompleteSum+0xac>
jmp    11eb <BX_CompleteSum+0x9b>
mov    -0x18(%rbp),%rdi
call   1050 <BX_DecRef@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BX_CompleteSum>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <BX_IsDNF@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     116e <BX_CompleteSum+0x1e>
call   1060 <BX_IncRef@plt>
mov    %rax,%rbx
jmp    117b <BX_CompleteSum+0x2b>
call   1040 <BX_ToDNF@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1199 <BX_CompleteSum+0x49>
mov    %rbx,%rdi
call   1070 <_complete_sum@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <BX_DecRef@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    1191 <BX_CompleteSum+0x41>

LLVM IR (-O0):
%struct.BoolExpr = type { i32 }
define %struct.BoolExpr* @BX_CompleteSum(%struct.BoolExpr* %0) {
%2 = alloca %struct.BoolExpr*
%3 = alloca %struct.BoolExpr*
%4 = alloca %struct.BoolExpr*
%5 = alloca %struct.BoolExpr*
store %struct.BoolExpr* %0, %struct.BoolExpr** %3
%6 = load %struct.BoolExpr*, %struct.BoolExpr** %3
%7 = call i64 @BX_IsDNF(%struct.BoolExpr* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load %struct.BoolExpr*, %struct.BoolExpr** %3
%11 = call %struct.BoolExpr* @BX_IncRef(%struct.BoolExpr* %10)
store %struct.BoolExpr* %11, %struct.BoolExpr** %4
br label %20
12: ; preds = %1
br label %13
13: ; preds = %12
%14 = load %struct.BoolExpr*, %struct.BoolExpr** %3
%15 = call %struct.BoolExpr* @BX_ToDNF(%struct.BoolExpr* %14)
store %struct.BoolExpr* %15, %struct.BoolExpr** %4
%16 = icmp eq %struct.BoolExpr* %15, null
br i1 %16, label %17, label %18
17: ; preds = %13
store %struct.BoolExpr* null, %struct.BoolExpr** %2
br label %33
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19, %9
br label %21
21: ; preds = %20
%22 = load %struct.BoolExpr*, %struct.BoolExpr** %4
%23 = call %struct.BoolExpr* @_complete_sum(%struct.BoolExpr* %22)
store %struct.BoolExpr* %23, %struct.BoolExpr** %5
%24 = icmp eq %struct.BoolExpr* %23, null
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load %struct.BoolExpr*, %struct.BoolExpr** %4
%27 = call i32 @BX_DecRef(%struct.BoolExpr* %26)
store %struct.BoolExpr* null, %struct.BoolExpr** %2
br label %33
28: ; preds = %21
br label %29
29: ; preds = %28
%30 = load %struct.BoolExpr*, %struct.BoolExpr** %4
%31 = call i32 @BX_DecRef(%struct.BoolExpr* %30)
%32 = load %struct.BoolExpr*, %struct.BoolExpr** %5
store %struct.BoolExpr* %32, %struct.BoolExpr** %2
br label %33
33: ; preds = %29, %25, %17
%34 = load %struct.BoolExpr*, %struct.BoolExpr** %2
ret %struct.BoolExpr* %34
}

LLVM IR (-O2):
%struct.BoolExpr = type { i32 }
define %struct.BoolExpr* @BX_CompleteSum(%struct.BoolExpr* %0) {
%2 = tail call i64 @BX_IsDNF(%struct.BoolExpr* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call %struct.BoolExpr* @BX_IncRef(%struct.BoolExpr* %0)
br label %9
6: ; preds = %1
%7 = tail call %struct.BoolExpr* @BX_ToDNF(%struct.BoolExpr* %0)
%8 = icmp eq %struct.BoolExpr* %7, null
br i1 %8, label %13, label %9
9: ; preds = %4, %6
%10 = phi %struct.BoolExpr* [ %5, %4 ], [ %7, %6 ]
%11 = tail call %struct.BoolExpr* @_complete_sum(%struct.BoolExpr* %10)
%12 = tail call i32 @BX_DecRef(%struct.BoolExpr* %10)
br label %13
13: ; preds = %9, %6
%14 = phi %struct.BoolExpr* [ null, %6 ], [ %11, %9 ]
ret %struct.BoolExpr* %14
}