#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 *);
int /*<<< orphan*/ rec(int, int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n;
  printf("Enter pattern length: ");
  scanf("%d", &n);
  char str[n + 1];
  char guess[n + 1];
  printf("Input the guess pattern: ");
  scanf("%s", guess);
  int wpeg, bpeg;
  printf("Enter the number of black pegs in the feedback: ");
  scanf("%d", &bpeg);
  printf("Enter the number of white pegs in the feedback: ");
  scanf("%d", &wpeg);
  printf("The possible key patterns are:");
  rec(n, 0, str, guess, wpeg, bpeg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe20(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
xor    %esi,%esi
call   1050 <rec@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%r14
lea    -0x24(%rbp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%r12
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
lea    -0x28(%rbp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%r8d
mov    -0x28(%rbp),%r9d
xor    %esi,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1050 <rec@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter pattern length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Input the guess pattern: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [49 x i8] c"Enter the number of black pegs in the feedback: \00"
@.str.5 = [49 x i8] c"Enter the number of white pegs in the feedback: \00"
@.str.6 = [31 x i8] c"The possible key patterns are:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %3
%14 = alloca i8, i64 %12
store i64 %12, i64* %4
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
store i64 %17, i64* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%21 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%23 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i32 @rec(i32 %26, i32 0, i8* %14, i8* %18, i32 %27, i32 %28)
store i32 0, i32* %1
%30 = load i8*, i8** %3
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter pattern length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Input the guess pattern: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [49 x i8] c"Enter the number of black pegs in the feedback: \00"
@.str.5 = [49 x i8] c"Enter the number of white pegs in the feedback: \00"
@.str.6 = [31 x i8] c"The possible key patterns are:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%18 = bitcast i32* %2 to i8*
%19 = bitcast i32* %3 to i8*
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @rec(i32 %25, i32 0, i8* %11, i8* %15, i32 %26, i32 %27)
ret i32 0
}