#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 /*<<< orphan*/ BIGNUM;

/* Variables and functions */
scalar_t__ BN_set_bit(int /*<<< orphan*/ *, int const);
int /*<<< orphan*/ BN_zero(int /*<<< orphan*/ *);
int /*<<< orphan*/ bn_check_top(int /*<<< orphan*/ *);
int BN_GF2m_arr2poly(const int p[], BIGNUM *a) {
  int i;
  bn_check_top(a);
  BN_zero(a);
  for (i = 0; p[i] != -1; i++) {
    if (BN_set_bit(a, p[i]) == 0)
      return 0;
  }
  bn_check_top(a);
  return 1;
}


x86 assembly (clang, -O0):
<BN_GF2m_arr2poly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <bn_check_top@plt>
mov    -0x18(%rbp),%rdi
call   1050 <BN_zero@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     11a8 <BN_GF2m_arr2poly+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <BN_set_bit@plt>
cmp    $0x0,%rax
jne    1195 <BN_GF2m_arr2poly+0x65>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <BN_GF2m_arr2poly+0x88>
jmp    119a <BN_GF2m_arr2poly+0x6a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <BN_GF2m_arr2poly+0x29>
mov    -0x18(%rbp),%rdi
call   1030 <bn_check_top@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_GF2m_arr2poly>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <bn_check_top@plt>
mov    %r14,%rdi
call   1050 <BN_zero@plt>
mov    (%rbx),%esi
cmp    $0xffffffff,%esi
je     1178 <BN_GF2m_arr2poly+0x48>
add    $0x4,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <BN_set_bit@plt>
test   %rax,%rax
je     1187 <BN_GF2m_arr2poly+0x57>
mov    (%rbx),%esi
add    $0x4,%rbx
cmp    $0xffffffff,%esi
jne    1160 <BN_GF2m_arr2poly+0x30>
mov    %r14,%rdi
call   1030 <bn_check_top@plt>
mov    $0x1,%eax
jmp    1189 <BN_GF2m_arr2poly+0x59>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @BN_GF2m_arr2poly(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = call i32 @bn_check_top(i32* %7)
%9 = load i32*, i32** %5
%10 = call i32 @BN_zero(i32* %9)
store i32 0, i32* %6
br label %11
11: ; preds = %29, %2
%12 = load i32*, i32** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = load i32*, i32** %5
%20 = load i32*, i32** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i64 @BN_set_bit(i32* %19, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 0, i32* %3
br label %35
28: ; preds = %18
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %11
32: ; preds = %11
%33 = load i32*, i32** %5
%34 = call i32 @bn_check_top(i32* %33)
store i32 1, i32* %3
br label %35
35: ; preds = %32, %27
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @BN_GF2m_arr2poly(i32* nocapture %0, i32* %1) {
%3 = tail call i32 @bn_check_top(i32* %1)
%4 = tail call i32 @BN_zero(i32* %1)
%5 = load i32, i32* %0
%6 = icmp eq i32 %5, -1
br i1 %6, label %17, label %11
7: ; preds = %11
%8 = getelementptr inbounds i32, i32* %0, i64 %16
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, -1
br i1 %10, label %17, label %11
11: ; preds = %2, %7
%12 = phi i64 [ %16, %7 ], [ 0, %2 ]
%13 = phi i32 [ %9, %7 ], [ %5, %2 ]
%14 = tail call i64 @BN_set_bit(i32* %1, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = add nuw i64 %12, 1
br i1 %15, label %19, label %7
17: ; preds = %7, %2
%18 = tail call i32 @bn_check_top(i32* %1)
br label %19
19: ; preds = %11, %17
%20 = phi i32 [ 1, %17 ], [ 0, %11 ]
ret i32 %20
}