#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 */
char *computeDifference(char *, char *);
char *computeUnion(char *, char *);
char *parseIntersection(char *);
int /*<<< orphan*/ string_remove_char(char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
char *parseUnionOrDifference(char *expression) {
  char *value1 = parseIntersection(expression);
  while (strlen(expression) > 0) {
    char symbol = expression[0];
    if (symbol != '+' && symbol != '-') {
      return value1;
    }
    string_remove_char(expression, 0);
    char *value2 = parseIntersection(expression);
    if (symbol == '+') {
      value1 = computeUnion(value1, value2);
    } else {
      value1 = computeDifference(value1, value2);
    }
  }
  return value1;
}


x86 assembly (clang, -O0):
<parseUnionOrDifference>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <parseIntersection@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11fd <parseUnionOrDifference+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
je     11ac <parseUnionOrDifference+0x5c>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
je     11ac <parseUnionOrDifference+0x5c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <parseUnionOrDifference+0xb5>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <string_remove_char@plt>
mov    -0x10(%rbp),%rdi
call   1050 <parseIntersection@plt>
mov    %rax,-0x28(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    11e7 <parseUnionOrDifference+0x97>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <computeUnion@plt>
mov    %rax,-0x18(%rbp)
jmp    11f8 <parseUnionOrDifference+0xa8>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <computeDifference@plt>
mov    %rax,-0x18(%rbp)
jmp    1169 <parseUnionOrDifference+0x19>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseUnionOrDifference>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
call   1050 <parseIntersection@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    11ed <parseUnionOrDifference+0x9d>
jmp    119b <parseUnionOrDifference+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1060 <computeUnion@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    %r14,%rax
test   %rcx,%rcx
jle    11f0 <parseUnionOrDifference+0xa0>
movzbl (%r12),%ebx
cmp    $0x2d,%bl
je     11aa <parseUnionOrDifference+0x5a>
cmp    $0x2b,%bl
jne    11e0 <parseUnionOrDifference+0x90>
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <string_remove_char@plt>
mov    %r12,%rdi
call   1050 <parseIntersection@plt>
mov    %r14,%rdi
mov    %rax,%rsi
cmp    $0x2b,%bl
je     1180 <parseUnionOrDifference+0x30>
call   1070 <computeDifference@plt>
mov    %rax,%r14
jmp    11e3 <parseUnionOrDifference+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%r15
mov    %r15,%rax
cmp    $0x2d,%bl
je     1188 <parseUnionOrDifference+0x38>
jmp    11f0 <parseUnionOrDifference+0xa0>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @parseUnionOrDifference(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @parseIntersection(i8* %7)
store i8* %8, i8** %4
br label %9
9: ; preds = %42, %1
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %43
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
store i8 %16, i8* %5
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 43
br i1 %19, label %20, label %26
20: ; preds = %13
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 45
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %45
26: ; preds = %20, %13
%27 = load i8*, i8** %3
%28 = call i32 @string_remove_char(i8* %27, i32 0)
%29 = load i8*, i8** %3
%30 = call i8* @parseIntersection(i8* %29)
store i8* %30, i8** %6
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 43
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i8*, i8** %4
%36 = load i8*, i8** %6
%37 = call i8* @computeUnion(i8* %35, i8* %36)
store i8* %37, i8** %4
br label %42
38: ; preds = %26
%39 = load i8*, i8** %4
%40 = load i8*, i8** %6
%41 = call i8* @computeDifference(i8* %39, i8* %40)
store i8* %41, i8** %4
br label %42
42: ; preds = %38, %34
br label %9
43: ; preds = %9
%44 = load i8*, i8** %4
store i8* %44, i8** %2
br label %45
45: ; preds = %43, %24
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
define i8* @parseUnionOrDifference(i8* %0) {
%2 = tail call i8* @parseIntersection(i8* %0)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %26
5: ; preds = %1, %21
%6 = phi i8* [ %22, %21 ], [ undef, %1 ]
%7 = phi i8* [ %23, %21 ], [ %2, %1 ]
%8 = load i8, i8* %0
switch i8 %8, label %17 [
i8 45, label %9
i8 43, label %9
]
9: ; preds = %5, %5
%10 = tail call i32 @string_remove_char(i8* %0, i32 0)
%11 = tail call i8* @parseIntersection(i8* %0)
%12 = icmp eq i8 %8, 43
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i8* @computeUnion(i8* %7, i8* %11)
br label %21
15: ; preds = %9
%16 = tail call i8* @computeDifference(i8* %7, i8* %11)
br label %17
17: ; preds = %15, %5
%18 = phi i8* [ %7, %5 ], [ %16, %15 ]
%19 = phi i8* [ %7, %5 ], [ %6, %15 ]
%20 = icmp eq i8 %8, 45
br i1 %20, label %21, label %26
21: ; preds = %17, %13
%22 = phi i8* [ %6, %13 ], [ %19, %17 ]
%23 = phi i8* [ %14, %13 ], [ %18, %17 ]
%24 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %5, label %26
26: ; preds = %17, %21, %1
%27 = phi i8* [ %2, %1 ], [ %23, %21 ], [ %19, %17 ]
ret i8* %27
}