#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*/ ASN1_STRING_set_default_mask(unsigned long);
unsigned long B_ASN1_BMPSTRING;
scalar_t__ B_ASN1_T61STRING;
unsigned long B_ASN1_UTF8STRING;
scalar_t__ strcmp(char const *, char *);
scalar_t__ strncmp(char const *, char *, int);
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
int ASN1_STRING_set_default_mask_asc(const char *p) {
  unsigned long mask;
  char *end;
  if (strncmp(p, "MASK:", 5) == 0) {
    if (!p[5])
      return 0;
    mask = strtoul(p + 5, &end, 0);
    if (*end)
      return 0;
  } else if (strcmp(p, "nombstr") == 0)
    mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
  else if (strcmp(p, "pkix") == 0)
    mask = ~((unsigned long)B_ASN1_T61STRING);
  else if (strcmp(p, "utf8only") == 0)
    mask = B_ASN1_UTF8STRING;
  else if (strcmp(p, "default") == 0)
    mask = 0xFFFFFFFFL;
  else
    return 0;
  ASN1_STRING_set_default_mask(mask);
  return 1;
}


x86 assembly (clang, -O0):
<ASN1_STRING_set_default_mask_asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ba <ASN1_STRING_set_default_mask_asc+0x7a>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x5(%rax)
jne    1185 <ASN1_STRING_set_default_mask_asc+0x45>
movl   $0x0,-0x4(%rbp)
jmp    12ab <ASN1_STRING_set_default_mask_asc+0x16b>
mov    -0x10(%rbp),%rdi
add    $0x5,%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b5 <ASN1_STRING_set_default_mask_asc+0x75>
movl   $0x0,-0x4(%rbp)
jmp    12ab <ASN1_STRING_set_default_mask_asc+0x16b>
jmp    129b <ASN1_STRING_set_default_mask_asc+0x15b>
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f5 <ASN1_STRING_set_default_mask_asc+0xb5>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    0x2df3(%rip),%rcx
or     (%rcx),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1296 <ASN1_STRING_set_default_mask_asc+0x156>
mov    -0x10(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1226 <ASN1_STRING_set_default_mask_asc+0xe6>
mov    0x2dca(%rip),%rax
mov    (%rax),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1291 <ASN1_STRING_set_default_mask_asc+0x151>
mov    -0x10(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1253 <ASN1_STRING_set_default_mask_asc+0x113>
mov    0x2d91(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    128c <ASN1_STRING_set_default_mask_asc+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <ASN1_STRING_set_default_mask_asc+0x13b>
mov    $0xffffffff,%eax
mov    %rax,-0x18(%rbp)
jmp    1287 <ASN1_STRING_set_default_mask_asc+0x147>
movl   $0x0,-0x4(%rbp)
jmp    12ab <ASN1_STRING_set_default_mask_asc+0x16b>
jmp    128c <ASN1_STRING_set_default_mask_asc+0x14c>
jmp    1291 <ASN1_STRING_set_default_mask_asc+0x151>
jmp    1296 <ASN1_STRING_set_default_mask_asc+0x156>
jmp    129b <ASN1_STRING_set_default_mask_asc+0x15b>
mov    -0x18(%rbp),%rdi
call   1050 <ASN1_STRING_set_default_mask@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_STRING_set_default_mask_asc>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b5 <ASN1_STRING_set_default_mask_asc+0x75>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11dc <ASN1_STRING_set_default_mask_asc+0x9c>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f5 <ASN1_STRING_set_default_mask_asc+0xb5>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1208 <ASN1_STRING_set_default_mask_asc+0xc8>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    121c <ASN1_STRING_set_default_mask_asc+0xdc>
mov    $0xffffffff,%edi
jmp    1212 <ASN1_STRING_set_default_mask_asc+0xd2>
cmpb   $0x0,0x5(%rbx)
je     1204 <ASN1_STRING_set_default_mask_asc+0xc4>
add    $0x5,%rbx
mov    %rsp,%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %rax,%rdi
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    121c <ASN1_STRING_set_default_mask_asc+0xdc>
jmp    1212 <ASN1_STRING_set_default_mask_asc+0xd2>
mov    0x2e0d(%rip),%rax
mov    0x2dee(%rip),%rcx
mov    (%rcx),%rdi
or     (%rax),%rdi
not    %rdi
jmp    1212 <ASN1_STRING_set_default_mask_asc+0xd2>
mov    0x2de4(%rip),%rax
mov    (%rax),%rdi
not    %rdi
jmp    1212 <ASN1_STRING_set_default_mask_asc+0xd2>
xor    %ebp,%ebp
jmp    121c <ASN1_STRING_set_default_mask_asc+0xdc>
mov    0x2dc9(%rip),%rax
mov    (%rax),%rdi
call   1050 <ASN1_STRING_set_default_mask@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"MASK:\00"
@.str.1 = [8 x i8] c"nombstr\00"
@B_ASN1_BMPSTRING = global i64 0
@B_ASN1_UTF8STRING = global i64 0
@.str.2 = [5 x i8] c"pkix\00"
@B_ASN1_T61STRING = global i64 0
@.str.3 = [9 x i8] c"utf8only\00"
@.str.4 = [8 x i8] c"default\00"
define i32 @ASN1_STRING_set_default_mask_asc(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 5
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
store i32 0, i32* %2
br label %59
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 5
%18 = call i64 @strtoul(i8* %17, i8** %5, i32 0)
store i64 %18, i64* %4
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 0, i32* %2
br label %59
23: ; preds = %15
br label %56
24: ; preds = %1
%25 = load i8*, i8** %3
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i64, i64* @B_ASN1_BMPSTRING
%30 = load i64, i64* @B_ASN1_UTF8STRING
%31 = or i64 %29, %30
%32 = xor i64 %31, -1
store i64 %32, i64* %4
br label %55
33: ; preds = %24
%34 = load i8*, i8** %3
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i64, i64* @B_ASN1_T61STRING
%39 = xor i64 %38, -1
store i64 %39, i64* %4
br label %54
40: ; preds = %33
%41 = load i8*, i8** %3
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i64, i64* @B_ASN1_UTF8STRING
store i64 %45, i64* %4
br label %53
46: ; preds = %40
%47 = load i8*, i8** %3
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
store i64 4294967295, i64* %4
br label %52
51: ; preds = %46
store i32 0, i32* %2
br label %59
52: ; preds = %50
br label %53
53: ; preds = %52, %44
br label %54
54: ; preds = %53, %37
br label %55
55: ; preds = %54, %28
br label %56
56: ; preds = %55, %23
%57 = load i64, i64* %4
%58 = call i32 @ASN1_STRING_set_default_mask(i64 %57)
store i32 1, i32* %2
br label %59
59: ; preds = %56, %51, %22, %14
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str = [6 x i8] c"MASK:\00"
@.str.1 = [8 x i8] c"nombstr\00"
@B_ASN1_BMPSTRING = global i64 0
@B_ASN1_UTF8STRING = global i64 0
@.str.2 = [5 x i8] c"pkix\00"
@B_ASN1_T61STRING = global i64 0
@.str.3 = [9 x i8] c"utf8only\00"
@.str.4 = [8 x i8] c"default\00"
define i32 @ASN1_STRING_set_default_mask_asc(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 5
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %40, label %10
10: ; preds = %6
%11 = call i64 @strtoul(i8* %7, i8** %2, i32 0)
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %37, label %40
15: ; preds = %1
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i64, i64* @B_ASN1_BMPSTRING
%20 = load i64, i64* @B_ASN1_UTF8STRING
%21 = or i64 %20, %19
%22 = xor i64 %21, -1
br label %37
23: ; preds = %15
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i64, i64* @B_ASN1_T61STRING
%28 = xor i64 %27, -1
br label %37
29: ; preds = %23
%30 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i64, i64* @B_ASN1_UTF8STRING
br label %37
34: ; preds = %29
%35 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34, %18, %32, %26, %10
%38 = phi i64 [ %11, %10 ], [ %22, %18 ], [ %28, %26 ], [ %33, %32 ], [ 4294967295, %34 ]
%39 = tail call i32 @ASN1_STRING_set_default_mask(i64 %38)
br label %40
40: ; preds = %34, %10, %6, %37
%41 = phi i32 [ 1, %37 ], [ 0, %6 ], [ 0, %10 ], [ 0, %34 ]
ret i32 %41
}