#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 */
scalar_t__ crAlloc(int);
int /*<<< orphan*/ crFreeStrings(char **);
char **crStrSplit(char const *, char *);
int /*<<< orphan*/ crStrcat(char *, char *);
scalar_t__ crStrcmp(char *, char *);
int crStrlen(char const *);
char *crStrIntersect(const char *s1, const char *s2) {
  int len1, len2;
  int resultLen;
  char *result;
  char **exten1, **exten2;
  int i, j;
  if (!s1 || !s2) {
    return NULL;
  }
  len1 = crStrlen(s1);
  len2 = crStrlen(s2);
  resultLen = ((len1 > len2) ? len1 : len2) + 2;
  result = (char *)crAlloc(resultLen);
  if (!result) {
    return NULL;
  }
  result[0] = 0;
  exten1 = crStrSplit(s1, " ");
  exten2 = crStrSplit(s2, " ");
  for (i = 0; exten1[i]; i++) {
    for (j = 0; exten2[j]; j++) {
      if (crStrcmp(exten1[i], exten2[j]) == 0) {
        crStrcat(result, exten1[i]);
        crStrcat(result, " ");
        break;
      }
    }
  }
  crFreeStrings(exten1);
  crFreeStrings(exten2);
  return result;
}


x86 assembly (clang, -O0):
<crStrIntersect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1186 <crStrIntersect+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1193 <crStrIntersect+0x33>
movq   $0x0,-0x8(%rbp)
jmp    12e9 <crStrIntersect+0x189>
mov    -0x10(%rbp),%rdi
call   1070 <crStrlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <crStrlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11c2 <crStrIntersect+0x62>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    11c8 <crStrIntersect+0x68>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <crAlloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f5 <crStrIntersect+0x95>
movq   $0x0,-0x8(%rbp)
jmp    12e9 <crStrIntersect+0x189>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1080 <crStrSplit@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1080 <crStrSplit@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12cf <crStrIntersect+0x16f>
movl   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x48(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12bc <crStrIntersect+0x15c>
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x40(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <crStrcmp@plt>
cmp    $0x0,%rax
jne    12a9 <crStrIntersect+0x149>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <crStrcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1050 <crStrcat@plt>
jmp    12bc <crStrIntersect+0x15c>
jmp    12ae <crStrIntersect+0x14e>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1245 <crStrIntersect+0xe5>
jmp    12c1 <crStrIntersect+0x161>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    122b <crStrIntersect+0xcb>
mov    -0x38(%rbp),%rdi
call   1040 <crFreeStrings@plt>
mov    -0x40(%rbp),%rdi
call   1040 <crFreeStrings@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crStrIntersect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     1281 <crStrIntersect+0x121>
mov    %rsi,%r15
test   %rsi,%rsi
je     1281 <crStrIntersect+0x121>
mov    %rdi,%rbx
call   1070 <crStrlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <crStrlen@plt>
cmp    %eax,%ebp
cmovle %eax,%ebp
add    $0x2,%ebp
mov    %ebp,%edi
call   1060 <crAlloc@plt>
test   %rax,%rax
je     127e <crStrIntersect+0x11e>
mov    %rax,%r14
movb   $0x0,(%rax)
lea    0xe46(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <crStrSplit@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rbp,%rsi
call   1080 <crStrSplit@plt>
mov    %rax,%r15
mov    (%r12),%rdi
test   %rdi,%rdi
je     126c <crStrIntersect+0x10c>
mov    %r15,%rax
add    $0x8,%rax
mov    %rax,(%rsp)
xor    %ebp,%ebp
mov    %r12,%rbx
jmp    1230 <crStrIntersect+0xd0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%rsi
mov    %r14,%rdi
call   1050 <crStrcat@plt>
mov    %r14,%rdi
lea    0xdeb(%rip),%rsi
call   1050 <crStrcat@plt>
lea    (%r12,%rbp,8),%rbx
add    $0x8,%rbx
mov    0x8(%r12,%rbp,8),%rdi
add    $0x1,%rbp
test   %rdi,%rdi
je     126c <crStrIntersect+0x10c>
mov    (%r15),%rsi
test   %rsi,%rsi
je     121a <crStrIntersect+0xba>
call   1030 <crStrcmp@plt>
test   %rax,%rax
je     1200 <crStrIntersect+0xa0>
mov    (%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%rsi
test   %rsi,%rsi
je     121a <crStrIntersect+0xba>
mov    (%rbx),%rdi
call   1030 <crStrcmp@plt>
add    $0x8,%r13
test   %rax,%rax
jne    1250 <crStrIntersect+0xf0>
jmp    1200 <crStrIntersect+0xa0>
mov    %r12,%rdi
call   1040 <crFreeStrings@plt>
mov    %r15,%rdi
call   1040 <crFreeStrings@plt>
jmp    1281 <crStrIntersect+0x121>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i8* @crStrIntersect(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %16, %2
store i8* null, i8** %3
br label %100
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = call i32 @crStrlen(i8* %21)
store i32 %22, i32* %6
%23 = load i8*, i8** %5
%24 = call i32 @crStrlen(i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32, i32* %6
br label %32
30: ; preds = %20
%31 = load i32, i32* %7
br label %32
32: ; preds = %30, %28
%33 = phi i32 [ %29, %28 ], [ %31, %30 ]
%34 = add nsw i32 %33, 2
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = call i64 @crAlloc(i32 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %9
%38 = load i8*, i8** %9
%39 = icmp ne i8* %38, null
br i1 %39, label %41, label %40
40: ; preds = %32
store i8* null, i8** %3
br label %100
41: ; preds = %32
%42 = load i8*, i8** %9
%43 = getelementptr inbounds i8, i8* %42, i64 0
store i8 0, i8* %43
%44 = load i8*, i8** %4
%45 = call i8** @crStrSplit(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8** %45, i8*** %10
%46 = load i8*, i8** %5
%47 = call i8** @crStrSplit(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8** %47, i8*** %11
store i32 0, i32* %12
br label %48
48: ; preds = %91, %41
%49 = load i8**, i8*** %10
%50 = load i32, i32* %12
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %94
55: ; preds = %48
store i32 0, i32* %13
br label %56
56: ; preds = %87, %55
%57 = load i8**, i8*** %11
%58 = load i32, i32* %13
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %90
63: ; preds = %56
%64 = load i8**, i8*** %10
%65 = load i32, i32* %12
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = load i8**, i8*** %11
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = call i64 @crStrcmp(i8* %68, i8* %73)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %86
76: ; preds = %63
%77 = load i8*, i8** %9
%78 = load i8**, i8*** %10
%79 = load i32, i32* %12
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @crStrcat(i8* %77, i8* %82)
%84 = load i8*, i8** %9
%85 = call i32 @crStrcat(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %90
86: ; preds = %63
br label %87
87: ; preds = %86
%88 = load i32, i32* %13
%89 = add nsw i32 %88, 1
store i32 %89, i32* %13
br label %56
90: ; preds = %76, %56
br label %91
91: ; preds = %90
%92 = load i32, i32* %12
%93 = add nsw i32 %92, 1
store i32 %93, i32* %12
br label %48
94: ; preds = %48
%95 = load i8**, i8*** %10
%96 = call i32 @crFreeStrings(i8** %95)
%97 = load i8**, i8*** %11
%98 = call i32 @crFreeStrings(i8** %97)
%99 = load i8*, i8** %9
store i8* %99, i8** %3
br label %100
100: ; preds = %94, %40, %19
%101 = load i8*, i8** %3
ret i8* %101
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i8* @crStrIntersect(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %51
6: ; preds = %2
%7 = tail call i32 @crStrlen(i8* %0)
%8 = tail call i32 @crStrlen(i8* %1)
%9 = icmp sgt i32 %7, %8
%10 = select i1 %9, i32 %7, i32 %8
%11 = add nsw i32 %10, 2
%12 = tail call i64 @crAlloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i64 %12, 0
br i1 %14, label %51, label %15
15: ; preds = %6
store i8 0, i8* %13
%16 = tail call i8** @crStrSplit(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = tail call i8** @crStrSplit(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = load i8*, i8** %16
%19 = icmp eq i8* %18, null
br i1 %19, label %48, label %20
20: ; preds = %15, %43
%21 = phi i8* [ %46, %43 ], [ %18, %15 ]
%22 = phi i64 [ %44, %43 ], [ 0, %15 ]
%23 = phi i8** [ %45, %43 ], [ %16, %15 ]
%24 = load i8*, i8** %17
%25 = icmp eq i8* %24, null
br i1 %25, label %43, label %26
26: ; preds = %20
%27 = tail call i64 @crStrcmp(i8* %21, i8* %24)
%28 = icmp eq i64 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %26, %34
%30 = phi i64 [ %38, %34 ], [ 1, %26 ]
%31 = getelementptr inbounds i8*, i8** %17, i64 %30
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
br i1 %33, label %43, label %34
34: ; preds = %29
%35 = load i8*, i8** %23
%36 = tail call i64 @crStrcmp(i8* %35, i8* %32)
%37 = icmp eq i64 %36, 0
%38 = add nuw i64 %30, 1
br i1 %37, label %39, label %29
39: ; preds = %34, %26
%40 = load i8*, i8** %23
%41 = tail call i32 @crStrcat(i8* %13, i8* %40)
%42 = tail call i32 @crStrcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %29, %20, %39
%44 = add nuw i64 %22, 1
%45 = getelementptr inbounds i8*, i8** %16, i64 %44
%46 = load i8*, i8** %45
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %20
48: ; preds = %43, %15
%49 = tail call i32 @crFreeStrings(i8** %16)
%50 = tail call i32 @crFreeStrings(i8** %17)
br label %51
51: ; preds = %6, %2, %48
%52 = phi i8* [ %13, %48 ], [ null, %2 ], [ null, %6 ]
ret i8* %52
}