#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*/ printf(char *, char *);
void interleave(char str1[], char str2[], int m, int n, char ils[], int index) {
  if (m == 0 && n == 0) {
    ils[index] = '\0';
    printf("%s\n", ils);
  }
  if (m != 0) {
    ils[index] = str1[0];
    interleave(str1 + 1, str2, m - 1, n, ils, index + 1);
  }
  if (n != 0) {
    ils[index] = str2[0];
    interleave(str1, str2 + 1, m, n - 1, ils, index + 1);
  }
}


x86 assembly (clang, -O0):
<interleave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    116e <interleave+0x4e>
cmpl   $0x0,-0x18(%rbp)
jne    116e <interleave+0x4e>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11af <interleave+0x8f>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
add    $0x1,%r9d
call   1040 <interleave@plt>
cmpl   $0x0,-0x18(%rbp)
je     11f0 <interleave+0xd0>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
add    $0x1,%r9d
call   1040 <interleave@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interleave>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,0x10(%rsp)
lea    0x1(%rdi),%rax
mov    %rax,0x8(%rsp)
lea    -0x1(%r15),%eax
mov    %eax,0x4(%rsp)
movslq %r9d,%r12
lea    0x1(%r12),%r13d
add    %r8,%r12
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
or     %r15d,%eax
je     11b0 <interleave+0x90>
test   %r15d,%r15d
je     1191 <interleave+0x71>
mov    0x10(%rsp),%rax
movzbl (%rax),%eax
mov    %al,(%r12)
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    0x4(%rsp),%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %r13d,%r9d
call   1040 <interleave@plt>
sub    $0x1,%ebp
jb     11cb <interleave+0xab>
movzbl (%rbx),%eax
mov    %al,(%r12)
add    $0x1,%rbx
add    $0x1,%r13d
add    $0x1,%r12
jmp    1160 <interleave+0x40>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%r12)
lea    0xe44(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
test   %r15d,%r15d
jne    116c <interleave+0x4c>
jmp    1191 <interleave+0x71>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @interleave(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %6
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i8*, i8** %11
%20 = load i32, i32* %12
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %11
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %18, %15, %6
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %45
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = load i8*, i8** %11
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8*, i8** %8
%39 = load i32, i32* %9
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %10
%42 = load i8*, i8** %11
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
br label %45
45: ; preds = %28, %25
%46 = load i32, i32* %10
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %65
48: ; preds = %45
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = load i8*, i8** %11
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
%56 = load i8*, i8** %7
%57 = load i8*, i8** %8
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = load i32, i32* %9
%60 = load i32, i32* %10
%61 = sub nsw i32 %60, 1
%62 = load i8*, i8** %11
%63 = load i32, i32* %12
%64 = add nsw i32 %63, 1
br label %65
65: ; preds = %48, %45
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @interleave(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = icmp eq i32 %2, 0
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = add nsw i32 %2, -1
%10 = sext i32 %5 to i64
br label %11
11: ; preds = %28, %6
%12 = phi i64 [ %33, %28 ], [ %10, %6 ]
%13 = phi i8* [ %31, %28 ], [ %1, %6 ]
%14 = phi i32 [ %32, %28 ], [ %3, %6 ]
%15 = or i32 %14, %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %4, i64 %12
store i8 0, i8* %18
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %20
20: ; preds = %17, %11
br i1 %7, label %26, label %21
21: ; preds = %20
%22 = load i8, i8* %0
%23 = getelementptr inbounds i8, i8* %4, i64 %12
store i8 %22, i8* %23
%24 = trunc i64 %12 to i32
%25 = add i32 %24, 1
tail call void @interleave(i8* %8, i8* %13, i32 %9, i32 %14, i8* %4, i32 %25)
br label %26
26: ; preds = %21, %20
%27 = icmp eq i32 %14, 0
br i1 %27, label %34, label %28
28: ; preds = %26
%29 = load i8, i8* %13
%30 = getelementptr inbounds i8, i8* %4, i64 %12
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %13, i64 1
%32 = add nsw i32 %14, -1
%33 = add nsw i64 %12, 1
br label %11
34: ; preds = %26
ret void
}