#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 */
struct rooted_tree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroy_tree_cb_2(struct rooted_tree *,
                                     int /*<<< orphan*/ *);
struct rooted_tree *get_ordered_pattern_tree(char *);
int parse_labels(struct rooted_tree *, char **);
scalar_t__ strcmp(char *, char *);
int overlap_labels(char *seed1, char *seed2) {
  int i, j, overlap = 0;
  char label_set1[1000][200];
  char label_set2[1000][200];
  int lc1, lc2;
  struct rooted_tree *seed1_tree = get_ordered_pattern_tree(seed1);
  struct rooted_tree *seed2_tree = get_ordered_pattern_tree(seed2);
  lc1 = parse_labels(seed1_tree, label_set1);
  lc2 = parse_labels(seed2_tree, label_set2);
  for (i = 0; i < lc1; i++) {
    for (j = 0; j < lc2; j++) {
      if (strcmp(label_set1[i], label_set2[j]) == 0) {
        overlap++;
        break;
      }
    }
  }
  destroy_tree_cb_2(seed1_tree, NULL);
  destroy_tree_cb_2(seed2_tree, NULL);
  return overlap;
}


x86 assembly (clang, -O0):
<overlap_labels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ac0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_ordered_pattern_tree@plt>
mov    %rax,-0x61ab0(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_ordered_pattern_tree@plt>
mov    %rax,-0x61ab8(%rbp)
mov    -0x61ab0(%rbp),%rdi
lea    -0x30d60(%rbp),%rsi
call   1060 <parse_labels@plt>
mov    %eax,-0x61aa4(%rbp)
mov    -0x61ab8(%rbp),%rdi
lea    -0x61aa0(%rbp),%rsi
call   1060 <parse_labels@plt>
mov    %eax,-0x61aa8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x61aa4(%rbp),%eax
jge    1245 <overlap_labels+0x105>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x61aa8(%rbp),%eax
jge    1232 <overlap_labels+0xf2>
movslq -0x14(%rbp),%rax
lea    -0x30d60(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
movslq -0x18(%rbp),%rax
lea    -0x61aa0(%rbp),%rsi
imul   $0xc8,%rax,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <overlap_labels+0xdf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1232 <overlap_labels+0xf2>
jmp    1224 <overlap_labels+0xe4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c9 <overlap_labels+0x89>
jmp    1237 <overlap_labels+0xf7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <overlap_labels+0x73>
mov    -0x61ab0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <destroy_tree_cb_2@plt>
mov    -0x61ab8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <destroy_tree_cb_2@plt>
mov    -0x1c(%rbp),%eax
add    $0x61ac0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overlap_labels>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61aa8,%rsp
mov    %rsi,%rbx
call   1050 <get_ordered_pattern_tree@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <get_ordered_pattern_tree@plt>
mov    %rax,%rbx
lea    0x30d60(%rsp),%rsi
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
call   1060 <parse_labels@plt>
mov    %eax,%ebp
lea    0x20(%rsp),%rsi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   1060 <parse_labels@plt>
test   %ebp,%ebp
jle    11ff <overlap_labels+0xbf>
mov    %eax,%ebx
mov    %ebp,%r15d
mov    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %r13d,%r13d
movl   $0x0,0x4(%rsp)
jmp    11be <overlap_labels+0x7e>
nopl   (%rax)
addl   $0x1,0x4(%rsp)
add    $0x1,%r13
cmp    %r15,%r13
je     1207 <overlap_labels+0xc7>
test   %ebx,%ebx
jle    11b5 <overlap_labels+0x75>
imul   $0xc8,%r13,%rax
lea    (%rsp,%rax,1),%rbp
add    $0x30d60,%rbp
mov    0x18(%rsp),%r14
lea    0x20(%rsp),%r12
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b0 <overlap_labels+0x70>
add    $0xc8,%r12
add    $0xffffffffffffffff,%r14
jne    11e0 <overlap_labels+0xa0>
jmp    11b5 <overlap_labels+0x75>
movl   $0x0,0x4(%rsp)
mov    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <destroy_tree_cb_2@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <destroy_tree_cb_2@plt>
mov    0x4(%rsp),%eax
add    $0x61aa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rooted_tree = type { i32 }
define i32 @overlap_labels(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1000 x [200 x i8]]
%9 = alloca [1000 x [200 x i8]]
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.rooted_tree*
%13 = alloca %struct.rooted_tree*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%14 = load i8*, i8** %3
%15 = call %struct.rooted_tree* @get_ordered_pattern_tree(i8* %14)
store %struct.rooted_tree* %15, %struct.rooted_tree** %12
%16 = load i8*, i8** %4
%17 = call %struct.rooted_tree* @get_ordered_pattern_tree(i8* %16)
store %struct.rooted_tree* %17, %struct.rooted_tree** %13
%18 = load %struct.rooted_tree*, %struct.rooted_tree** %12
%19 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %8, i64 0, i64 0
%20 = bitcast [200 x i8]* %19 to i8**
%21 = call i32 @parse_labels(%struct.rooted_tree* %18, i8** %20)
store i32 %21, i32* %10
%22 = load %struct.rooted_tree*, %struct.rooted_tree** %13
%23 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %9, i64 0, i64 0
%24 = bitcast [200 x i8]* %23 to i8**
%25 = call i32 @parse_labels(%struct.rooted_tree* %22, i8** %24)
store i32 %25, i32* %11
store i32 0, i32* %5
br label %26
26: ; preds = %54, %2
%27 = load i32, i32* %5
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %57
30: ; preds = %26
store i32 0, i32* %6
br label %31
31: ; preds = %50, %30
%32 = load i32, i32* %6
%33 = load i32, i32* %11
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %53
35: ; preds = %31
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %8, i64 0, i64 %37
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %38, i64 0, i64 0
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %9, i64 0, i64 %41
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %42, i64 0, i64 0
%44 = call i64 @strcmp(i8* %39, i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %53
49: ; preds = %35
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %31
53: ; preds = %46, %31
br label %54
54: ; preds = %53
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %26
57: ; preds = %26
%58 = load %struct.rooted_tree*, %struct.rooted_tree** %12
%59 = call i32 @destroy_tree_cb_2(%struct.rooted_tree* %58, i32* null)
%60 = load %struct.rooted_tree*, %struct.rooted_tree** %13
%61 = call i32 @destroy_tree_cb_2(%struct.rooted_tree* %60, i32* null)
%62 = load i32, i32* %7
ret i32 %62
}

LLVM IR (-O2):
%struct.rooted_tree = type { i32 }
define i32 @overlap_labels(i8* %0, i8* %1) {
%3 = alloca [1000 x [200 x i8]]
%4 = alloca [1000 x [200 x i8]]
%5 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %3, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %4, i64 0, i64 0, i64 0
%7 = tail call %struct.rooted_tree* @get_ordered_pattern_tree(i8* %0)
%8 = tail call %struct.rooted_tree* @get_ordered_pattern_tree(i8* %1)
%9 = bitcast [1000 x [200 x i8]]* %3 to i8**
%10 = call i32 @parse_labels(%struct.rooted_tree* %7, i8** %9)
%11 = bitcast [1000 x [200 x i8]]* %4 to i8**
%12 = call i32 @parse_labels(%struct.rooted_tree* %8, i8** %11)
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %37
14: ; preds = %2
%15 = icmp sgt i32 %12, 0
%16 = zext i32 %10 to i64
%17 = zext i32 %12 to i64
br label %18
18: ; preds = %14, %33
%19 = phi i64 [ 0, %14 ], [ %35, %33 ]
%20 = phi i32 [ 0, %14 ], [ %34, %33 ]
br i1 %15, label %21, label %33
21: ; preds = %18
%22 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %3, i64 0, i64 %19, i64 0
br label %25
23: ; preds = %25
%24 = icmp eq i64 %30, %17
br i1 %24, label %33, label %25
25: ; preds = %21, %23
%26 = phi i64 [ 0, %21 ], [ %30, %23 ]
%27 = getelementptr inbounds [1000 x [200 x i8]], [1000 x [200 x i8]]* %4, i64 0, i64 %26, i64 0
%28 = call i64 @strcmp(i8* %22, i8* %27)
%29 = icmp eq i64 %28, 0
%30 = add nuw nsw i64 %26, 1
br i1 %29, label %31, label %23
31: ; preds = %25
%32 = add nsw i32 %20, 1
br label %33
33: ; preds = %23, %18, %31
%34 = phi i32 [ %32, %31 ], [ %20, %18 ], [ %20, %23 ]
%35 = add nuw nsw i64 %19, 1
%36 = icmp eq i64 %35, %16
br i1 %36, label %37, label %18
37: ; preds = %33, %2
%38 = phi i32 [ 0, %2 ], [ %34, %33 ]
%39 = call i32 @destroy_tree_cb_2(%struct.rooted_tree* %7, i32* null)
%40 = call i32 @destroy_tree_cb_2(%struct.rooted_tree* %8, i32* null)
ret i32 %38
}