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

/* Variables and functions */
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ re_compile_fastmap_aux(unsigned char *, int, unsigned char *,
                                          unsigned char *, unsigned char *);
int re_do_compile_fastmap(unsigned char *buffer, int used, int pos,
                          unsigned char *can_be_null, unsigned char *fastmap) {
  unsigned char small_visited[512], *visited;
  if (used <= sizeof(small_visited))
    visited = small_visited;
  else {
    visited = (unsigned char *)malloc(used);
    if (!visited)
      return 0;
  }
  *can_be_null = 0;
  memset(fastmap, 0, 256);
  memset(visited, 0, used);
  re_compile_fastmap_aux(buffer, pos, visited, can_be_null, fastmap);
  if (visited != small_visited)
    free(visited);
  return 1;
}


x86 assembly (clang, -O0):
<re_do_compile_fastmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x200,%rax
ja     1180 <re_do_compile_fastmap+0x40>
lea    -0x230(%rbp),%rax
mov    %rax,-0x238(%rbp)
jmp    11ae <re_do_compile_fastmap+0x6e>
mov    -0x14(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
jne    11a9 <re_do_compile_fastmap+0x69>
movl   $0x0,-0x4(%rbp)
jmp    121b <re_do_compile_fastmap+0xdb>
jmp    11ae <re_do_compile_fastmap+0x6e>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x238(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x238(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <re_compile_fastmap_aux@plt>
mov    -0x238(%rbp),%rax
lea    -0x230(%rbp),%rcx
cmp    %rcx,%rax
je     1214 <re_do_compile_fastmap+0xd4>
mov    -0x238(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<re_do_compile_fastmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r13
mov    %rsp,%rbx
cmp    $0x201,%esi
jb     1179 <re_do_compile_fastmap+0x39>
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c3 <re_do_compile_fastmap+0x83>
movb   $0x0,(%r15)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <re_compile_fastmap_aux@plt>
mov    $0x1,%ebp
mov    %rsp,%rax
cmp    %rax,%rbx
je     11c5 <re_do_compile_fastmap+0x85>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11c5 <re_do_compile_fastmap+0x85>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @re_do_compile_fastmap(i8* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [512 x i8]
%13 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%14 = load i32, i32* %8
%15 = sext i32 %14 to i64
%16 = icmp ule i64 %15, 512
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
store i8* %18, i8** %13
br label %27
19: ; preds = %5
%20 = load i32, i32* %8
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %13
%23 = load i8*, i8** %13
%24 = icmp ne i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %19
store i32 0, i32* %6
br label %47
26: ; preds = %19
br label %27
27: ; preds = %26, %17
%28 = load i8*, i8** %10
store i8 0, i8* %28
%29 = load i8*, i8** %11
%30 = call i32 @memset(i8* %29, i32 0, i32 256)
%31 = load i8*, i8** %13
%32 = load i32, i32* %8
%33 = call i32 @memset(i8* %31, i32 0, i32 %32)
%34 = load i8*, i8** %7
%35 = load i32, i32* %9
%36 = load i8*, i8** %13
%37 = load i8*, i8** %10
%38 = load i8*, i8** %11
%39 = call i32 @re_compile_fastmap_aux(i8* %34, i32 %35, i8* %36, i8* %37, i8* %38)
%40 = load i8*, i8** %13
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%42 = icmp ne i8* %40, %41
br i1 %42, label %43, label %46
43: ; preds = %27
%44 = load i8*, i8** %13
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %27
store i32 1, i32* %6
br label %47
47: ; preds = %46, %25
%48 = load i32, i32* %6
ret i32 %48
}

LLVM IR (-O2):
define i32 @re_do_compile_fastmap(i8* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = icmp ult i32 %1, 513
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i64 @malloc(i32 %1)
%11 = inttoptr i64 %10 to i8*
%12 = icmp eq i64 %10, 0
br i1 %12, label %21, label %13
13: ; preds = %5, %9
%14 = phi i8* [ %11, %9 ], [ %7, %5 ]
store i8 0, i8* %3
%15 = tail call i32 @memset(i8* %4, i32 0, i32 256)
%16 = call i32 @memset(i8* %14, i32 0, i32 %1)
%17 = call i32 @re_compile_fastmap_aux(i8* %0, i32 %2, i8* %14, i8* %3, i8* %4)
%18 = icmp eq i8* %14, %7
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 @free(i8* %14)
br label %21
21: ; preds = %13, %19, %9
%22 = phi i32 [ 0, %9 ], [ 1, %19 ], [ 1, %13 ]
ret i32 %22
}