#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*/ bubble_sort(char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ *strchr(char const *, char const);
size_t strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *left_exclude(const char srcA[], const char srcB[]) {
  size_t lenA = strlen(srcA);
  size_t lenB = strlen(srcB);
  size_t tempSize = lenA + lenB + 1;
  int i, j, index = 0;
  char temp[tempSize];
  for (i = 0; i < lenB; i++) {
    if (strchr(srcA, srcB[i]) == NULL) {
      temp[index++] = srcB[i];
      temp[index] = '\0';
    }
  }
  bubble_sort(temp, index);
  char *result = (char *)malloc(index + 1);
  strncpy(result, temp, index);
  result[index] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<left_exclude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
lea    0x1(%rax,%rcx,1),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1228 <left_exclude+0xd8>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1215 <left_exclude+0xc5>
mov    -0x58(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,1),%dl
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    121a <left_exclude+0xca>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c0 <left_exclude+0x70>
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <bubble_sort@plt>
mov    -0x34(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    -0x58(%rbp),%rsi
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x34(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x50(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x50(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<left_exclude>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
add    %r14,%rax
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
test   %r13,%r13
je     11d5 <left_exclude+0x85>
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    11a9 <left_exclude+0x59>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    %r14,%r13
je     11d8 <left_exclude+0x88>
movsbl (%rbx,%r14,1),%esi
mov    %r15,%rdi
call   1050 <strchr@plt>
test   %rax,%rax
jne    11a0 <left_exclude+0x50>
movzbl (%rbx,%r14,1),%eax
movslq %r12d,%rcx
lea    0x1(%rcx),%r12
mov    -0x30(%rbp),%rdx
mov    %al,(%rdx,%rcx,1)
movb   $0x0,0x1(%rdx,%rcx,1)
jmp    11a0 <left_exclude+0x50>
xor    %r12d,%r12d
mov    -0x30(%rbp),%r14
mov    %r14,%rdi
mov    %r12d,%esi
call   1070 <bubble_sort@plt>
lea    0x1(%r12),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movslq %r12d,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @left_exclude(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%14 = load i8*, i8** %3
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %5
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
store i64 %17, i64* %6
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = add i64 %18, %19
%21 = add i64 %20, 1
store i64 %21, i64* %7
store i32 0, i32* %10
%22 = load i64, i64* %7
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %11
%24 = alloca i8, i64 %22
store i64 %22, i64* %12
store i32 0, i32* %8
br label %25
25: ; preds = %53, %2
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = load i64, i64* %6
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i8*, i8** %4
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = call i32* @strchr(i8* %31, i8 signext %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %52
39: ; preds = %30
%40 = load i8*, i8** %4
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
store i32 %46, i32* %10
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %24, i64 %47
store i8 %44, i8* %48
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %24, i64 %50
store i8 0, i8* %51
br label %52
52: ; preds = %39, %30
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %25
56: ; preds = %25
%57 = load i32, i32* %10
%58 = call i32 @bubble_sort(i8* %24, i32 %57)
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to i8*
store i8* %62, i8** %13
%63 = load i8*, i8** %13
%64 = load i32, i32* %10
%65 = call i32 @strncpy(i8* %63, i8* %24, i32 %64)
%66 = load i8*, i8** %13
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
store i8 0, i8* %69
%70 = load i8*, i8** %13
%71 = load i8*, i8** %11
ret i8* %70
}

LLVM IR (-O2):
define i8* @left_exclude(i8* %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 1
%6 = add i64 %5, %4
%7 = alloca i8, i64 %6
%8 = icmp eq i64 %4, 0
br i1 %8, label %27, label %9
9: ; preds = %2, %23
%10 = phi i64 [ %25, %23 ], [ 0, %2 ]
%11 = phi i32 [ %24, %23 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %10
%13 = load i8, i8* %12
%14 = tail call i32* @strchr(i8* %0, i8 signext %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = load i8, i8* %12
%18 = add nsw i32 %11, 1
%19 = sext i32 %11 to i64
%20 = getelementptr inbounds i8, i8* %7, i64 %19
store i8 %17, i8* %20
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds i8, i8* %7, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %9, %16
%24 = phi i32 [ %18, %16 ], [ %11, %9 ]
%25 = add nuw i64 %10, 1
%26 = icmp eq i64 %25, %4
br i1 %26, label %27, label %9
27: ; preds = %23, %2
%28 = phi i32 [ 0, %2 ], [ %24, %23 ]
%29 = call i32 @bubble_sort(i8* %7, i32 %28)
%30 = add nsw i32 %28, 1
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
%33 = call i32 @strncpy(i8* %32, i8* %7, i32 %28)
%34 = sext i32 %28 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
ret i8* %32
}