#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*/ naive_printf(char *, char);
char *strchr(char *, char);
void solve(char *s1, char *s2, int len) {
  if (len == 0)
    return;
  int nlen = strchr(s2, *s1) - s2;
  solve(s1 + 1, s2, nlen);
  solve(s1 + nlen + 1, s2 + nlen + 1, len - nlen - 1);
  naive_printf("%c", (*s1));
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1152 <solve+0x22>
jmp    11bf <solve+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
call   1040 <strchr@plt>
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <solve@plt>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1030 <solve@plt>
mov    -0x8(%rbp),%rax
lea    0xe49(%rip),%rdi
movsbl (%rax),%esi
call   1050 <naive_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
test   %edx,%edx
je     119a <solve+0x6a>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
movsbl (%rdi),%esi
mov    %rbp,%rdi
call   1040 <strchr@plt>
mov    %rax,%rbx
sub    %rbp,%rbx
lea    0x1(%r15),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <solve@plt>
movslq %ebx,%rdx
lea    (%r15,%rdx,1),%rdi
add    $0x1,%rdi
lea    (%rdx,%rbp,1),%rsi
add    $0x1,%rsi
not    %edx
add    %r14d,%edx
call   1030 <solve@plt>
movsbl (%r15),%esi
lea    0xe75(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <naive_printf@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @solve(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
br label %42
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = call i8* @strchr(i8* %12, i8 signext %14)
%16 = load i8*, i8** %5
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8*, i8** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = sub nsw i32 %35, %36
%38 = sub nsw i32 %37, 1
%39 = load i8*, i8** %4
%40 = load i8, i8* %39
%41 = call i32 @naive_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %40)
br label %42
42: ; preds = %11, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @solve(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %6
5: ; preds = %3, %6
ret void
6: ; preds = %3
%7 = load i8, i8* %0
%8 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext %7)
%9 = ptrtoint i8* %8 to i64
%10 = ptrtoint i8* %1 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds i8, i8* %0, i64 1
tail call void @solve(i8* %13, i8* %1, i32 %12)
%14 = shl i64 %11, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = getelementptr inbounds i8, i8* %1, i64 %15
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = xor i32 %12, -1
%21 = add i32 %20, %2
tail call void @solve(i8* %17, i8* %19, i32 %21)
%22 = load i8, i8* %0
%23 = tail call i32 @naive_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %22)
br label %5
}