#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 substituteWildcard(char str[], int length, int index) {
  if (index == length) {
    printf("%s\n", str);
  } else {
    if (str[index] == '?') {
      str[index] = '0';
      substituteWildcard(str, length, index + 1);
      str[index] = '?';
      str[index] = '1';
      substituteWildcard(str, length, index + 1);
      str[index] = '?';
    } else {
      substituteWildcard(str, length, index + 1);
    }
  }
}


x86 assembly (clang, -O0):
<substituteWildcard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1153 <substituteWildcard+0x33>
mov    -0x8(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    11d8 <substituteWildcard+0xb8>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    11c1 <substituteWildcard+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1040 <substituteWildcard@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x3f,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1040 <substituteWildcard@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x3f,(%rax,%rcx,1)
jmp    11d3 <substituteWildcard+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1040 <substituteWildcard@plt>
jmp    11d8 <substituteWildcard+0xb8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substituteWildcard>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    %esi,%edx
je     115c <substituteWildcard+0x3c>
mov    %edx,%ebx
mov    %esi,%r15d
movslq %edx,%rbp
add    %r14,%rbp
add    $0x1,%ebx
mov    %esi,%eax
neg    %eax
cmpb   $0x3f,0x0(%rbp)
je     1175 <substituteWildcard+0x55>
add    $0x1,%rbp
lea    (%rax,%rbx,1),%ecx
add    $0x1,%ecx
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x1,%ecx
jne    1140 <substituteWildcard+0x20>
lea    0xe9d(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
movb   $0x30,0x0(%rbp)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <substituteWildcard@plt>
movb   $0x31,0x0(%rbp)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <substituteWildcard@plt>
movb   $0x3f,0x0(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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