#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 bullCowCalculator(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ inputChecker(int);
int numberLength(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int inputTaker(int numberToBeGuessed) {
  int i = 1, inputNumber;
  printf("\n\t\t\t\tCow\tBull\n");
  while (1) {
    printf("\n%d. Enter your Guess: ", i);
    scanf("%d", &inputNumber);
    if (numberLength(inputNumber) == 4 && inputChecker(inputNumber) == 0) {
      i++;
      printf("\t\t\t\t%d",
             bullCowCalculator(numberToBeGuessed, inputNumber) / 10);
      printf("\t%d", bullCowCalculator(numberToBeGuessed, inputNumber) % 10);
    }
    if (i > 8) {
      printf("\n\nBad luck! Better Luck Next time\nThe number was %d",
             numberToBeGuessed);
      break;
    }
    if (numberToBeGuessed == inputNumber) {
      printf("\n\nCongrats you found the number in %d turns", i - 1);
      exit(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<inputTaker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <numberLength@plt>
cmp    $0x4,%eax
jne    1213 <inputTaker+0xb3>
mov    -0xc(%rbp),%edi
call   1050 <inputChecker@plt>
cmp    $0x0,%rax
jne    1213 <inputTaker+0xb3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <bullCowCalculator@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <bullCowCalculator@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jle    1233 <inputTaker+0xd3>
mov    -0x4(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125f <inputTaker+0xff>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    125a <inputTaker+0xfa>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1180 <inputTaker+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputTaker>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xefb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
lea    0xe6b(%rip),%r14
lea    0xe80(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe73(%rip),%r13
jmp    11ba <inputTaker+0x4a>
add    $0x1,%ebp
nopl   (%rax)
cmp    %ebx,0x4(%rsp)
je     1279 <inputTaker+0x109>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
call   1030 <numberLength@plt>
cmp    $0x4,%eax
jne    11b0 <inputTaker+0x40>
mov    0x4(%rsp),%edi
call   1060 <inputChecker@plt>
test   %rax,%rax
jne    11b0 <inputTaker+0x40>
mov    0x4(%rsp),%esi
mov    %ebx,%edi
call   1090 <bullCowCalculator@plt>
cltq
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x22,%rsi
add    %eax,%esi
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %ebx,%edi
call   1090 <bullCowCalculator@plt>
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x8,%ebp
jl     11aa <inputTaker+0x3a>
lea    0xdc0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffff,%ebp
lea    0xdd0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"\0A\09\09\09\09Cow\09Bull\0A\00"
@.str.1 = [24 x i8] c"\0A%d. Enter your Guess: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"\09\09\09\09%d\00"
@.str.4 = [4 x i8] c"\09%d\00"
@.str.5 = [52 x i8] c"\0A\0ABad luck! Better Luck Next time\0AThe number was %d\00"
@.str.6 = [44 x i8] c"\0A\0ACongrats you found the number in %d turns\00"
define i32 @inputTaker(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %1, %45
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = call i32 @numberLength(i32 %10)
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %30
13: ; preds = %6
%14 = load i32, i32* %4
%15 = call i64 @inputChecker(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = call i32 @bullCowCalculator(i32 %20, i32 %21)
%23 = sdiv i32 %22, 10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = call i32 @bullCowCalculator(i32 %25, i32 %26)
%28 = srem i32 %27, 10
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %17, %13, %6
%31 = load i32, i32* %3
%32 = icmp sgt i32 %31, 8
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %46
36: ; preds = %30
%37 = load i32, i32* %2
%38 = load i32, i32* %4
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %3
%42 = sub nsw i32 %41, 1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %36
br label %6
46: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"\0A%d. Enter your Guess: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"\09\09\09\09%d\00"
@.str.4 = [4 x i8] c"\09%d\00"
@.str.5 = [52 x i8] c"\0A\0ABad luck! Better Luck Next time\0AThe number was %d\00"
@.str.6 = [44 x i8] c"\0A\0ACongrats you found the number in %d turns\00"
@str = [14 x i8] c"\0A\09\09\09\09Cow\09Bull\00"
define i32 @inputTaker(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %29, %1
%6 = phi i32 [ 1, %1 ], [ %30, %29 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 @numberLength(i32 %9)
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %29
12: ; preds = %5
%13 = load i32, i32* %2
%14 = call i64 @inputChecker(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = add nsw i32 %6, 1
%18 = load i32, i32* %2
%19 = call i32 @bullCowCalculator(i32 %0, i32 %18)
%20 = sdiv i32 %19, 10
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = call i32 @bullCowCalculator(i32 %0, i32 %22)
%24 = srem i32 %23, 10
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = icmp sgt i32 %6, 7
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %0)
ret i32 0
29: ; preds = %5, %12, %16
%30 = phi i32 [ %17, %16 ], [ %6, %12 ], [ %6, %5 ]
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, %0
br i1 %32, label %33, label %5
33: ; preds = %29
%34 = add nsw i32 %30, -1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 0)
unreachable
}