#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;
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ 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)) {
    if (!p[5])
      return 0;
    mask = strtoul(p + 5, &end, 0);
    if (*end)
      return 0;
  } else if (!strcmp(p, "nombstr"))
    mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
  else if (!strcmp(p, "pkix"))
    mask = ~((unsigned long)B_ASN1_T61STRING);
  else if (!strcmp(p, "utf8only"))
    mask = B_ASN1_UTF8STRING;
  else if (!strcmp(p, "default"))
    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,%eax
jne    11b9 <ASN1_STRING_set_default_mask_asc+0x79>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x5(%rax)
jne    1184 <ASN1_STRING_set_default_mask_asc+0x44>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <ASN1_STRING_set_default_mask_asc+0x166>
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     11b4 <ASN1_STRING_set_default_mask_asc+0x74>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <ASN1_STRING_set_default_mask_asc+0x166>
jmp    1296 <ASN1_STRING_set_default_mask_asc+0x156>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f3 <ASN1_STRING_set_default_mask_asc+0xb3>
mov    0x2e17(%rip),%rax
mov    (%rax),%rax
mov    0x2df5(%rip),%rcx
or     (%rcx),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1291 <ASN1_STRING_set_default_mask_asc+0x151>
mov    -0x10(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1223 <ASN1_STRING_set_default_mask_asc+0xe3>
mov    0x2dcd(%rip),%rax
mov    (%rax),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    128c <ASN1_STRING_set_default_mask_asc+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    124f <ASN1_STRING_set_default_mask_asc+0x10f>
mov    0x2d95(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1287 <ASN1_STRING_set_default_mask_asc+0x147>
mov    -0x10(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1276 <ASN1_STRING_set_default_mask_asc+0x136>
mov    $0xffffffff,%eax
mov    %rax,-0x18(%rbp)
jmp    1282 <ASN1_STRING_set_default_mask_asc+0x142>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <ASN1_STRING_set_default_mask_asc+0x166>
jmp    1287 <ASN1_STRING_set_default_mask_asc+0x147>
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>
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   %eax,%eax
je     11b0 <ASN1_STRING_set_default_mask_asc+0x70>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d7 <ASN1_STRING_set_default_mask_asc+0x97>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f0 <ASN1_STRING_set_default_mask_asc+0xb0>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1203 <ASN1_STRING_set_default_mask_asc+0xc3>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    1217 <ASN1_STRING_set_default_mask_asc+0xd7>
mov    $0xffffffff,%edi
jmp    120d <ASN1_STRING_set_default_mask_asc+0xcd>
cmpb   $0x0,0x5(%rbx)
je     11ff <ASN1_STRING_set_default_mask_asc+0xbf>
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    1217 <ASN1_STRING_set_default_mask_asc+0xd7>
jmp    120d <ASN1_STRING_set_default_mask_asc+0xcd>
mov    0x2e12(%rip),%rax
mov    0x2df3(%rip),%rcx
mov    (%rcx),%rdi
or     (%rax),%rdi
not    %rdi
jmp    120d <ASN1_STRING_set_default_mask_asc+0xcd>
mov    0x2de9(%rip),%rax
mov    (%rax),%rdi
not    %rdi
jmp    120d <ASN1_STRING_set_default_mask_asc+0xcd>
xor    %ebp,%ebp
jmp    1217 <ASN1_STRING_set_default_mask_asc+0xd7>
mov    0x2dce(%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 i32 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = icmp ne i32 %7, 0
br i1 %8, label %24, label %9
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 i32 @strcmp(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
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 i32 @strcmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %40, label %37
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 i32 @strcmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %46, label %44
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 i32 @strcmp(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
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 i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = icmp eq i32 %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 i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %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 i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32 %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 i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32 %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 i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34, %18, %32, %26, %10
%38 = phi i64 [ %33, %32 ], [ %28, %26 ], [ %22, %18 ], [ %11, %10 ], [ 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
}