#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*/ memset(char **, int /*<<< orphan*/, int);
unsigned char split_domain_name(char *, char **);
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
int hurl_verify_ssl_scope(char *expected_domain, char *actual_domain) {
  char *expected_labels[127], *actual_labels[127];
  unsigned char nrof_expected_labels = 0, nrof_actual_labels = 0;
  char *expected_label, *actual_label;
  int i = 0, verifications = 0;
  int wildcard = 0;
  memset(expected_labels, 0, sizeof(char *) * 127);
  memset(actual_labels, 0, sizeof(char *) * 127);
  nrof_expected_labels = split_domain_name(expected_domain, expected_labels);
  nrof_actual_labels = split_domain_name(actual_domain, actual_labels);
  i = 0;
  while (i < nrof_expected_labels) {
    expected_label = expected_labels[nrof_expected_labels - i - 1];
    if (wildcard) {
      verifications++;
    } else if (i < nrof_actual_labels) {
      actual_label = actual_labels[nrof_actual_labels - i - 1];
      if (strcmp(actual_label, "*") == 0 && i == nrof_actual_labels - 1) {
        wildcard = 1;
        verifications++;
      } else if (strcasecmp(expected_label, actual_label) == 0) {
        verifications++;
      }
    }
    i++;
  }
  return verifications == nrof_expected_labels ? 1 : 0;
}


x86 assembly (clang, -O0):
<hurl_verify_ssl_scope>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x811(%rbp)
movb   $0x0,-0x812(%rbp)
movl   $0x0,-0x82c(%rbp)
movl   $0x0,-0x830(%rbp)
movl   $0x0,-0x834(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <split_domain_name@plt>
mov    %al,-0x811(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1050 <split_domain_name@plt>
mov    %al,-0x812(%rbp)
movl   $0x0,-0x82c(%rbp)
mov    -0x82c(%rbp),%eax
movzbl -0x811(%rbp),%ecx
cmp    %ecx,%eax
jge    130a <hurl_verify_ssl_scope+0x1ca>
movzbl -0x811(%rbp),%eax
sub    -0x82c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x410(%rbp,%rax,8),%rax
ff
mov    %rax,-0x820(%rbp)
cmpl   $0x0,-0x834(%rbp)
je     1232 <hurl_verify_ssl_scope+0xf2>
mov    -0x830(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x830(%rbp)
jmp    12f6 <hurl_verify_ssl_scope+0x1b6>
mov    -0x82c(%rbp),%eax
movzbl -0x812(%rbp),%ecx
cmp    %ecx,%eax
jge    12f1 <hurl_verify_ssl_scope+0x1b1>
movzbl -0x812(%rbp),%eax
sub    -0x82c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x810(%rbp,%rax,8),%rax
ff
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12bb <hurl_verify_ssl_scope+0x17b>
mov    -0x82c(%rbp),%eax
movzbl -0x812(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12bb <hurl_verify_ssl_scope+0x17b>
movl   $0x1,-0x834(%rbp)
mov    -0x830(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x830(%rbp)
jmp    12ec <hurl_verify_ssl_scope+0x1ac>
mov    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12e7 <hurl_verify_ssl_scope+0x1a7>
mov    -0x830(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x830(%rbp)
jmp    12ec <hurl_verify_ssl_scope+0x1ac>
jmp    12f1 <hurl_verify_ssl_scope+0x1b1>
jmp    12f6 <hurl_verify_ssl_scope+0x1b6>
mov    -0x82c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x82c(%rbp)
jmp    11db <hurl_verify_ssl_scope+0x9b>
mov    -0x830(%rbp),%edx
movzbl -0x811(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hurl_verify_ssl_scope>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x420(%rsp),%r15
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <split_domain_name@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <split_domain_name@plt>
movzbl %bl,%ecx
test   %bl,%bl
je     1258 <hurl_verify_ssl_scope+0x118>
movzbl %al,%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %rdx,0x10(%rsp)
lea    (%rsp,%rax,8),%r14
add    $0x18,%r14
lea    (%rsp,%rcx,8),%r13
add    $0x418,%r13
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %ebp,%ebp
mov    %rcx,0x8(%rsp)
mov    %rax,(%rsp)
jmp    11fa <hurl_verify_ssl_scope+0xba>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    $0x1,%r12d
add    $0x1,%r15
add    $0xfffffffffffffff8,%r14
add    $0xfffffffffffffff8,%r13
cmp    %r15,%rcx
je     1258 <hurl_verify_ssl_scope+0x118>
test   %r12d,%r12d
jne    11e0 <hurl_verify_ssl_scope+0xa0>
xor    %r12d,%r12d
cmp    %rax,%r15
jae    11e9 <hurl_verify_ssl_scope+0xa9>
mov    0x0(%r13),%rax
mov    %rax,0x18(%rsp)
mov    (%r14),%rbx
mov    %rbx,%rdi
lea    0xde3(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1239 <hurl_verify_ssl_scope+0xf9>
cmp    %r15,0x10(%rsp)
jne    1239 <hurl_verify_ssl_scope+0xf9>
add    $0x1,%ebp
mov    $0x1,%r12d
jmp    124d <hurl_verify_ssl_scope+0x10d>
mov    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
cmp    $0x1,%rax
adc    $0x0,%ebp
mov    0x8(%rsp),%rcx
mov    (%rsp),%rax
jmp    11e9 <hurl_verify_ssl_scope+0xa9>
xor    %eax,%eax
cmp    %ecx,%ebp
sete   %al
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
define i32 @hurl_verify_ssl_scope(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [127 x i8*]
%6 = alloca [127 x i8*]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %7
store i8 0, i8* %8
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%14 = getelementptr inbounds [127 x i8*], [127 x i8*]* %5, i64 0, i64 0
%15 = call i32 @memset(i8** %14, i32 0, i32 1016)
%16 = getelementptr inbounds [127 x i8*], [127 x i8*]* %6, i64 0, i64 0
%17 = call i32 @memset(i8** %16, i32 0, i32 1016)
%18 = load i8*, i8** %3
%19 = getelementptr inbounds [127 x i8*], [127 x i8*]* %5, i64 0, i64 0
%20 = call zeroext i8 @split_domain_name(i8* %18, i8** %19)
store i8 %20, i8* %7
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [127 x i8*], [127 x i8*]* %6, i64 0, i64 0
%23 = call zeroext i8 @split_domain_name(i8* %21, i8** %22)
store i8 %23, i8* %8
store i32 0, i32* %11
br label %24
24: ; preds = %80, %2
%25 = load i32, i32* %11
%26 = load i8, i8* %7
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %83
29: ; preds = %24
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
%32 = load i32, i32* %11
%33 = sub nsw i32 %31, %32
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [127 x i8*], [127 x i8*]* %5, i64 0, i64 %35
%37 = load i8*, i8** %36
store i8* %37, i8** %9
%38 = load i32, i32* %13
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %29
%41 = load i32, i32* %12
%42 = add nsw i32 %41, 1
store i32 %42, i32* %12
br label %80
43: ; preds = %29
%44 = load i32, i32* %11
%45 = load i8, i8* %8
%46 = zext i8 %45 to i32
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %79
48: ; preds = %43
%49 = load i8, i8* %8
%50 = zext i8 %49 to i32
%51 = load i32, i32* %11
%52 = sub nsw i32 %50, %51
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [127 x i8*], [127 x i8*]* %6, i64 0, i64 %54
%56 = load i8*, i8** %55
store i8* %56, i8** %10
%57 = load i8*, i8** %10
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %69
60: ; preds = %48
%61 = load i32, i32* %11
%62 = load i8, i8* %8
%63 = zext i8 %62 to i32
%64 = sub nsw i32 %63, 1
%65 = icmp eq i32 %61, %64
br i1 %65, label %66, label %69
66: ; preds = %60
store i32 1, i32* %13
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %78
69: ; preds = %60, %48
%70 = load i8*, i8** %9
%71 = load i8*, i8** %10
%72 = call i64 @strcasecmp(i8* %70, i8* %71)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i32, i32* %12
%76 = add nsw i32 %75, 1
store i32 %76, i32* %12
br label %77
77: ; preds = %74, %69
br label %78
78: ; preds = %77, %66
br label %79
79: ; preds = %78, %43
br label %80
80: ; preds = %79, %40
%81 = load i32, i32* %11
%82 = add nsw i32 %81, 1
store i32 %82, i32* %11
br label %24
83: ; preds = %24
%84 = load i32, i32* %12
%85 = load i8, i8* %7
%86 = zext i8 %85 to i32
%87 = icmp eq i32 %84, %86
%88 = zext i1 %87 to i64
%89 = select i1 %87, i32 1, i32 0
ret i32 %89
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
define i32 @hurl_verify_ssl_scope(i8* %0, i8* %1) {
%3 = alloca [127 x i8*]
%4 = alloca [127 x i8*]
%5 = bitcast [127 x i8*]* %3 to i8*
%6 = bitcast [127 x i8*]* %4 to i8*
%7 = getelementptr inbounds [127 x i8*], [127 x i8*]* %3, i64 0, i64 0
%8 = call i32 @memset(i8** %7, i32 0, i32 1016)
%9 = getelementptr inbounds [127 x i8*], [127 x i8*]* %4, i64 0, i64 0
%10 = call i32 @memset(i8** %9, i32 0, i32 1016)
%11 = call zeroext i8 @split_domain_name(i8* %0, i8** %7)
%12 = call zeroext i8 @split_domain_name(i8* %1, i8** %9)
%13 = icmp eq i8 %11, 0
br i1 %13, label %55, label %14
14: ; preds = %2
%15 = zext i8 %12 to i64
%16 = add nuw nsw i64 %15, 4294967295
%17 = and i64 %16, 4294967295
%18 = zext i8 %12 to i64
%19 = zext i8 %11 to i64
%20 = zext i8 %12 to i64
%21 = zext i8 %11 to i64
br label %22
22: ; preds = %14, %50
%23 = phi i64 [ 0, %14 ], [ %53, %50 ]
%24 = phi i32 [ 0, %14 ], [ %52, %50 ]
%25 = phi i32 [ 0, %14 ], [ %51, %50 ]
%26 = xor i64 %23, -1
%27 = add nsw i64 %26, %19
%28 = getelementptr inbounds [127 x i8*], [127 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i32 %24, 0
br i1 %30, label %33, label %31
31: ; preds = %22
%32 = add nsw i32 %25, 1
br label %50
33: ; preds = %22
%34 = icmp ult i64 %23, %18
br i1 %34, label %35, label %50
35: ; preds = %33
%36 = add nsw i64 %26, %20
%37 = getelementptr inbounds [127 x i8*], [127 x i8*]* %4, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
%41 = icmp eq i64 %23, %17
%42 = select i1 %40, i1 %41, i1 false
br i1 %42, label %43, label %45
43: ; preds = %35
%44 = add nsw i32 %25, 1
br label %50
45: ; preds = %35
%46 = call i64 @strcasecmp(i8* %29, i8* %38)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = add nsw i32 %25, %48
br label %50
50: ; preds = %45, %33, %43, %31
%51 = phi i32 [ %32, %31 ], [ %44, %43 ], [ %25, %33 ], [ %49, %45 ]
%52 = phi i32 [ 1, %31 ], [ 1, %43 ], [ 0, %33 ], [ 0, %45 ]
%53 = add nuw nsw i64 %23, 1
%54 = icmp eq i64 %53, %21
br i1 %54, label %55, label %22
55: ; preds = %50, %2
%56 = phi i32 [ 0, %2 ], [ %51, %50 ]
%57 = zext i8 %11 to i32
%58 = icmp eq i32 %56, %57
%59 = zext i1 %58 to i32
ret i32 %59
}