#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 /*<<< orphan*/ char_is_one_of(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ get_bookmark(int);
int /*<<< orphan*/ index2mark(int);
scalar_t__ is_bmark_empty(int /*<<< orphan*/);
int init_active_bookmarks(const char marks[], int active_bookmarks[]) {
  int i, x;
  i = 0;
  for (x = 0; x < (61 + 3); ++x) {
    if (!char_is_one_of(marks, index2mark(x)))
      continue;
    if (is_bmark_empty(get_bookmark(x)))
      continue;
    active_bookmarks[i++] = x;
  }
  return i;
}


x86 assembly (clang, -O0):
<init_active_bookmarks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x40,-0x18(%rbp)
jge    11d5 <init_active_bookmarks+0x95>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <index2mark@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <char_is_one_of@plt>
cmp    $0x0,%eax
jne    1191 <init_active_bookmarks+0x51>
jmp    11c7 <init_active_bookmarks+0x87>
mov    -0x18(%rbp),%edi
call   1030 <get_bookmark@plt>
mov    %eax,%edi
call   1060 <is_bmark_empty@plt>
cmp    $0x0,%rax
je     11af <init_active_bookmarks+0x6f>
jmp    11c7 <init_active_bookmarks+0x87>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <init_active_bookmarks+0x1e>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_active_bookmarks>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    1168 <init_active_bookmarks+0x28>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x40,%ebp
je     119d <init_active_bookmarks+0x5d>
mov    %ebp,%edi
call   1040 <index2mark@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <char_is_one_of@plt>
test   %eax,%eax
je     1160 <init_active_bookmarks+0x20>
mov    %ebp,%edi
call   1030 <get_bookmark@plt>
mov    %eax,%edi
call   1060 <is_bmark_empty@plt>
test   %rax,%rax
jne    1160 <init_active_bookmarks+0x20>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %ebp,(%r14,%rax,4)
jmp    1160 <init_active_bookmarks+0x20>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @init_active_bookmarks(i8* %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %17
%4 = phi i32 [ 0, %2 ], [ %19, %17 ]
%5 = phi i32 [ 0, %2 ], [ %18, %17 ]
%6 = tail call i32 @index2mark(i32 %4)
%7 = tail call i32 @char_is_one_of(i8* %0, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %3
%10 = tail call i32 @get_bookmark(i32 %4)
%11 = tail call i64 @is_bmark_empty(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = add nsw i32 %5, 1
%15 = sext i32 %5 to i64
%16 = getelementptr inbounds i32, i32* %1, i64 %15
store i32 %4, i32* %16
br label %17
17: ; preds = %9, %3, %13
%18 = phi i32 [ %5, %9 ], [ %14, %13 ], [ %5, %3 ]
%19 = add nuw nsw i32 %4, 1
%20 = icmp eq i32 %19, 64
br i1 %20, label %21, label %3
21: ; preds = %17
ret i32 %18
}