#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 checkInput(char *, char *, char *, int);
int /*<<< orphan*/ printOutput(int, int, char **, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int l;
  int k;
  int score;
  int lenGuess;
  printf("Enter the pattern length: ");
  scanf("%d", &l);
  printf("Enter the number of guesses: ");
  scanf("%d", &lenGuess);
  char key[l];
  char g[lenGuess][l];
  char r[lenGuess][l];
  printf("Input the key pattern with no spaces: ");
  scanf("%s", key);
  score = 0;
  for (k = 0; k < lenGuess && score == 0; k++) {
    printf("Input a guess pattern with no spaces: ");
    scanf(" %s", g[k]);
    score = checkInput(key, g[k], r[k], l);
    printOutput(l, k, r, g);
  }
  if (score == 1) {
    printf("You guessed the pattern!");
  } else {
    printf("You did not guess the pattern!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    %rdi,-0x80(%rbp)
xor    %eax,%eax
mov    %al,-0x71(%rbp)
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rdi
mov    -0x71(%rbp),%al
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
mov    %rax,-0x70(%rbp)
mov    %rcx,%rsi
imul   %rax,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x68(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
mov    %rax,-0x60(%rbp)
mov    %rcx,%rsi
imul   %rax,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x58(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x40(%rbp)
mov    %rax,-0x48(%rbp)
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x81(%rbp)
jge    1266 <main+0x126>
cmpl   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    1279 <main+0x139>
jmp    12fc <main+0x1bc>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x70(%rbp),%rcx
mov    -0x68(%rbp),%rsi
movslq -0xc(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x70(%rbp),%r8
mov    -0x60(%rbp),%rcx
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    -0x68(%rbp),%rsi
movslq -0xc(%rbp),%rax
imul   %r8,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdx
mov    -0x8(%rbp),%ecx
call   1050 <checkInput@plt>
mov    -0x58(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <printOutput@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1245 <main+0x105>
cmpl   $0x1,-0x10(%rbp)
jne    1317 <main+0x1d7>
lea    0xd81(%rip),%rdi
call   1030 <printf@plt>
jmp    1323 <main+0x1e3>
lea    0xd89(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%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   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb7(%rip),%rbx
lea    -0x2c(%rbp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rsp,%r14
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%r13d
imul   %r13,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    %r12,-0x50(%rbp)
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1280 <main+0x140>
mov    %r14,-0x38(%rbp)
mov    %r15,-0x48(%rbp)
mov    %rbx,-0x40(%rbp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x50(%rbp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <checkInput@plt>
mov    %eax,%r12d
mov    -0x2c(%rbp),%edi
mov    %r14d,%esi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
call   1040 <printOutput@plt>
add    $0x1,%r14
movslq -0x30(%rbp),%rax
cmp    %rax,%r14
jge    126d <main+0x12d>
add    %r13,%rbx
add    %r13,%r15
test   %r12d,%r12d
je     1210 <main+0xd0>
cmp    $0x1,%r12d
mov    -0x38(%rbp),%r14
jne    1280 <main+0x140>
lea    0xe10(%rip),%rdi
jmp    1287 <main+0x147>
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the pattern length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Enter the number of guesses: \00"
@.str.3 = [39 x i8] c"Input the key pattern with no spaces: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [39 x i8] c"Input a guess pattern with no spaces: \00"
@.str.6 = [4 x i8] c" %s\00"
@.str.7 = [25 x i8] c"You guessed the pattern!\00"
@.str.8 = [31 x i8] c"You did not guess the pattern!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %2
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = load i32, i32* %2
%23 = zext i32 %22 to i64
%24 = mul nuw i64 %21, %23
%25 = alloca i8, i64 %24
store i64 %21, i64* %8
store i64 %23, i64* %9
%26 = load i32, i32* %5
%27 = zext i32 %26 to i64
%28 = load i32, i32* %2
%29 = zext i32 %28 to i64
%30 = mul nuw i64 %27, %29
%31 = alloca i8, i64 %30
store i64 %27, i64* %10
store i64 %29, i64* %11
%32 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %19)
store i32 0, i32* %4
store i32 0, i32* %3
br label %34
34: ; preds = %65, %0
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 0
br label %41
41: ; preds = %38, %34
%42 = phi i1 [ false, %34 ], [ %40, %38 ]
br i1 %42, label %43, label %68
43: ; preds = %41
%44 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = mul nsw i64 %46, %23
%48 = getelementptr inbounds i8, i8* %25, i64 %47
%49 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %48)
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = mul nsw i64 %51, %23
%53 = getelementptr inbounds i8, i8* %25, i64 %52
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = mul nsw i64 %55, %29
%57 = getelementptr inbounds i8, i8* %31, i64 %56
%58 = load i32, i32* %2
%59 = call i32 @checkInput(i8* %19, i8* %53, i8* %57, i32 %58)
store i32 %59, i32* %4
%60 = load i32, i32* %2
%61 = load i32, i32* %3
%62 = bitcast i8* %31 to i8**
%63 = bitcast i8* %25 to i8**
%64 = call i32 @printOutput(i32 %60, i32 %61, i8** %62, i8** %63)
br label %65
65: ; preds = %43
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
store i32 %67, i32* %3
br label %34
68: ; preds = %41
%69 = load i32, i32* %4
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %75
73: ; preds = %68
%74 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %75
75: ; preds = %73, %71
store i32 0, i32* %1
%76 = load i8*, i8** %6
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter the pattern length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Enter the number of guesses: \00"
@.str.3 = [39 x i8] c"Input the key pattern with no spaces: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [39 x i8] c"Input a guess pattern with no spaces: \00"
@.str.6 = [4 x i8] c" %s\00"
@.str.7 = [25 x i8] c"You guessed the pattern!\00"
@.str.8 = [31 x i8] c"You did not guess the pattern!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = load i32, i32* %1
%16 = zext i32 %15 to i64
%17 = mul nuw i64 %16, %14
%18 = alloca i8, i64 %17
%19 = alloca i8, i64 %17
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %47
24: ; preds = %0
%25 = bitcast i8* %19 to i8**
%26 = bitcast i8* %18 to i8**
br label %27
27: ; preds = %24, %27
%28 = phi i64 [ 0, %24 ], [ %39, %27 ]
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%30 = mul nuw nsw i64 %28, %16
%31 = getelementptr inbounds i8, i8* %18, i64 %30
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds i8, i8* %19, i64 %30
%34 = load i32, i32* %1
%35 = call i32 @checkInput(i8* %12, i8* %31, i8* %33, i32 %34)
%36 = load i32, i32* %1
%37 = trunc i64 %28 to i32
%38 = call i32 @printOutput(i32 %36, i32 %37, i8** %25, i8** %26)
%39 = add nuw nsw i64 %28, 1
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
%43 = icmp eq i32 %35, 0
%44 = select i1 %42, i1 %43, i1 false
br i1 %44, label %27, label %45
45: ; preds = %27
%46 = icmp eq i32 %35, 1
br i1 %46, label %48, label %47
47: ; preds = %0, %45
br label %48
48: ; preds = %45, %47
%49 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), %47 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), %45 ]
%50 = call i32 @printf(i8* dereferenceable(1) %49)
ret i32 0
}