#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*/ fill_with_numbers(int *, int, int);
int guess_numbers(int *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int main() {
  puts("C O D E - C R A C K E R");
  puts("");
  puts("There is a Code of 4 numbers. You should find it out.");
  puts("-- have fun and follow (@addisaden)");
  puts("");
  int numbers[4] = {-1, -1, -1, -1};
  fill_with_numbers(numbers, 10, 4);
  int solved = 0;
  int counter = 0;
  while (!(solved = guess_numbers(numbers, 10, 4))) {
    if (counter >= 10)
      break;
    counter++;
  }
  if (solved)
    printf("You cracked the code in %i steps. Congratulation.\n", counter + 1);
  else
    puts("You lost. Maybe you crack it the next time.");
  printf("CODE :: %i %i %i %i\n", numbers[0], numbers[1], numbers[2],
         numbers[3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
mov    0xf5e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf5b(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1050 <fill_with_numbers@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1060 <guess_numbers@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ed <main+0xad>
jmp    120a <main+0xca>
cmpl   $0xa,-0x28(%rbp)
jl     11fc <main+0xbc>
jmp    120a <main+0xca>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c2 <main+0x82>
cmpl   $0x0,-0x24(%rbp)
je     122d <main+0xed>
mov    -0x28(%rbp),%esi
add    $0x1,%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1239 <main+0xf9>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1060 <fill_with_numbers@plt>
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1070 <guess_numbers@plt>
lea    0x1(%rbx),%esi
test   %eax,%eax
jne    11d0 <main+0x80>
cmp    $0xa,%ebx
mov    %esi,%ebx
jb     11b0 <main+0x60>
test   %eax,%eax
je     11e4 <main+0x94>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f0 <main+0xa0>
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"C O D E - C R A C K E R\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [54 x i8] c"There is a Code of 4 numbers. You should find it out.\00"
@.str.3 = [36 x i8] c"-- have fun and follow (@addisaden)\00"
@__const.main.numbers = [4 x i32] [i32 -1, i32 -1, i32 -1, i32 -1]
@.str.4 = [51 x i8] c"You cracked the code in %i steps. Congratulation.\0A\00"
@.str.5 = [44 x i8] c"You lost. Maybe you crack it the next time.\00"
@.str.6 = [21 x i8] c"CODE :: %i %i %i %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = bitcast [4 x i32]* %2 to i8*
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%12 = call i32 @fill_with_numbers(i32* %11, i32 10, i32 4)
store i32 0, i32* %3
store i32 0, i32* %4
br label %13
13: ; preds = %22, %0
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%15 = call i32 @guess_numbers(i32* %14, i32 10, i32 4)
store i32 %15, i32* %3
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %18
br label %25
22: ; preds = %18
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %13
25: ; preds = %21, %13
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %30)
br label %34
32: ; preds = %25
%33 = call i32 @puts(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%36 = load i32, i32* %35
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%40 = load i32, i32* %39
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%42 = load i32, i32* %41
%43 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %36, i32 %38, i32 %40, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"C O D E - C R A C K E R\00"
@.str.2 = [54 x i8] c"There is a Code of 4 numbers. You should find it out.\00"
@.str.3 = [36 x i8] c"-- have fun and follow (@addisaden)\00"
@.str.4 = [51 x i8] c"You cracked the code in %i steps. Congratulation.\0A\00"
@.str.5 = [44 x i8] c"You lost. Maybe you crack it the next time.\00"
@.str.6 = [21 x i8] c"CODE :: %i %i %i %i\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @putchar(i32 10)
%7 = bitcast [4 x i32]* %1 to i8*
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%9 = call i32 @fill_with_numbers(i32* %8, i32 10, i32 4)
br label %10
10: ; preds = %10, %0
%11 = phi i32 [ 0, %0 ], [ %16, %10 ]
%12 = call i32 @guess_numbers(i32* %8, i32 10, i32 4)
%13 = icmp ne i32 %12, 0
%14 = icmp ugt i32 %11, 9
%15 = select i1 %13, i1 true, i1 %14
%16 = add nuw nsw i32 %11, 1
br i1 %15, label %17, label %10
17: ; preds = %10
br i1 %13, label %18, label %20
18: ; preds = %17
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %22
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* %8
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%27 = load i32, i32* %26
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%29 = load i32, i32* %28
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %23, i32 %25, i32 %27, i32 %29)
ret i32 0
}