#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*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *extract(char *s1, char *s2) {
  static char r1[128];
  char t1[128];
  char *s1p, *s2p, *r1p, *s1end, *s2end;
  int found, s1len, s2len;
  r1p = r1;
  strcpy(t1, s1);
  s1p = t1;
  s1len = (int)strlen(s1p);
  s1end = s1p + s1len;
  s2p = s2;
  s2len = (int)strlen(s2);
  s2end = s2p + s2len;
  for (s2p = s2; s2p < s2end; s2p++) {
    found = 0;
    for (s1p = t1; s1p < s1end; s1p++) {
      if (*s2p == *s1p) {
        *s1p = '0';
        found = 1;
        break;
      }
    }
    if (found == 0) {
      *r1 = '0';
      *(r1 + 1) = '\0';
      return (r1);
    }
  }
  r1p = r1;
  for (s1p = t1; s1p < s1end; s1p++)
    if (*s1p != '0')
      *(r1p++) = *s1p;
  *r1p = '\0';
  return (r1);
}


x86 assembly (clang, -O0):
<extract>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0x2f06(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xd0(%rbp)
mov    -0xa8(%rbp),%rax
movslq -0xd0(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xd4(%rbp)
mov    -0xb0(%rbp),%rax
movslq -0xd4(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rax
cmp    -0xc8(%rbp),%rax
jae    129e <extract+0x17e>
movl   $0x0,-0xcc(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
cmp    -0xc0(%rbp),%rax
jae    1257 <extract+0x137>
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
mov    -0xa8(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    123b <extract+0x11b>
mov    -0xa8(%rbp),%rax
movb   $0x30,(%rax)
movl   $0x1,-0xcc(%rbp)
jmp    1257 <extract+0x137>
jmp    1240 <extract+0x120>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    11f2 <extract+0xd2>
cmpl   $0x0,-0xcc(%rbp)
jne    1282 <extract+0x162>
movb   $0x30,0x2dd5(%rip)
movb   $0x0,0x2dcf(%rip)
lea    0x2dc7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1332 <extract+0x212>
jmp    1287 <extract+0x167>
mov    -0xb0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xb0(%rbp)
jmp    11c6 <extract+0xa6>
lea    0x2d9b(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
cmp    -0xc0(%rbp),%rax
jae    131d <extract+0x1fd>
mov    -0xa8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     1301 <extract+0x1e1>
mov    -0xa8(%rbp),%rax
mov    (%rax),%cl
mov    -0xb8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xb8(%rbp)
mov    %cl,(%rax)
jmp    1306 <extract+0x1e6>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    12ba <extract+0x19a>
mov    -0xb8(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2d12(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    %rax,%r12
shl    $0x20,%r12
lea    (%rsp,%rcx,1),%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
shl    $0x20,%rcx
test   %rcx,%rcx
jle    119c <extract+0x7c>
test   %r12,%r12
jle    11c9 <extract+0xa9>
cltq
add    %r14,%rax
mov    %rsp,%rsi
mov    (%r14),%cl
mov    %rsi,%rdx
nopl   0x0(%rax)
cmp    (%rdx),%cl
je     1190 <extract+0x70>
add    $0x1,%rdx
cmp    %r15,%rdx
jb     1180 <extract+0x60>
jmp    11c9 <extract+0xa9>
nop
movb   $0x30,(%rdx)
add    $0x1,%r14
cmp    %rax,%r14
jb     1176 <extract+0x56>
lea    0x2e9d(%rip),%rax
test   %r12,%r12
jg     11b9 <extract+0x99>
jmp    11d7 <extract+0xb7>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r15,%rbx
jae    11d7 <extract+0xb7>
movzbl (%rbx),%ecx
cmp    $0x30,%cl
je     11b0 <extract+0x90>
mov    %cl,(%rax)
add    $0x1,%rax
jmp    11b0 <extract+0x90>
movb   $0x30,0x2e70(%rip)
lea    0x2e6a(%rip),%rax
movb   $0x0,(%rax)
lea    0x2e5f(%rip),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@extract.r1 = internal global [128 x i8] zeroinitializer
define i8* @extract(i8* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = call i64 @strlen(i8* %4)
%7 = shl i64 %6, 32
%8 = ashr exact i64 %7, 32
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %8
%10 = call i64 @strlen(i8* dereferenceable(1) %1)
%11 = shl i64 %10, 32
%12 = ashr exact i64 %11, 32
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = icmp sgt i64 %11, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = icmp sgt i64 %7, 0
br i1 %16, label %17, label %29
17: ; preds = %15, %30
%18 = phi i8* [ %31, %30 ], [ %1, %15 ]
%19 = load i8, i8* %18
br label %22
20: ; preds = %30, %2
%21 = icmp sgt i64 %7, 0
br i1 %21, label %33, label %44
22: ; preds = %17, %26
%23 = phi i8* [ %4, %17 ], [ %27, %26 ]
%24 = load i8, i8* %23
%25 = icmp eq i8 %19, %24
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %23, i64 1
%28 = icmp ult i8* %27, %9
br i1 %28, label %22, label %29
29: ; preds = %26, %15
store i8 48, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @extract.r1, i64 0, i64 0)
br label %44
30: ; preds = %22
store i8 48, i8* %23
%31 = getelementptr inbounds i8, i8* %18, i64 1
%32 = icmp ult i8* %31, %13
br i1 %32, label %17, label %20
33: ; preds = %20, %40
%34 = phi i8* [ %42, %40 ], [ %4, %20 ]
%35 = phi i8* [ %41, %40 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @extract.r1, i64 0, i64 0), %20 ]
%36 = load i8, i8* %34
%37 = icmp eq i8 %36, 48
br i1 %37, label %40, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %35, i64 1
store i8 %36, i8* %35
br label %40
40: ; preds = %33, %38
%41 = phi i8* [ %39, %38 ], [ %35, %33 ]
%42 = getelementptr inbounds i8, i8* %34, i64 1
%43 = icmp ult i8* %42, %9
br i1 %43, label %33, label %44
44: ; preds = %40, %20, %29
%45 = phi i8* [ getelementptr inbounds ([128 x i8], [128 x i8]* @extract.r1, i64 0, i64 1), %29 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @extract.r1, i64 0, i64 0), %20 ], [ %41, %40 ]
store i8 0, i8* %45
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @extract.r1, i64 0, i64 0)
}