#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*/ play(int *, int *, int *, int *);
int /*<<< orphan*/ screen();
int /*<<< orphan*/ shuffle(int *);
int /*<<< orphan*/ whathappens(int *, int, int);
void mastermind(void) {
  int turn;
  int position = 0;
  int win = 0;
  int guess[4] = {0};
  screen();
  shuffle(guess);
  for (turn = 1; turn <= 10; turn++) {
    play(guess, &position, &turn, &win);
    if (win == 1)
      break;
  }
  if (turn != 100)
    whathappens(guess, turn, win);
}


x86 assembly (clang, -O0):
<mastermind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    $0x0,%al
call   1030 <screen@plt>
lea    -0x20(%rbp),%rdi
call   1040 <shuffle@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jg     11ce <mastermind+0x7e>
lea    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x4(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1070 <play@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11bb <mastermind+0x6b>
jmp    11ce <mastermind+0x7e>
jmp    11c0 <mastermind+0x70>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118d <mastermind+0x3d>
cmpl   $0x64,-0x4(%rbp)
je     11e7 <mastermind+0x97>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <whathappens@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mastermind>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <screen@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <shuffle@plt>
movl   $0x1,0x4(%rsp)
lea    0xc(%rsp),%r15
lea    0x4(%rsp),%r12
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1060 <play@plt>
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%eax
cmp    $0x1,%edx
je     11d5 <mastermind+0x95>
lea    0x1(%rax),%esi
mov    %esi,0x4(%rsp)
cmp    $0xa,%eax
jl     1190 <mastermind+0x50>
cmp    $0x64,%esi
je     11c9 <mastermind+0x89>
lea    0x10(%rsp),%rdi
call   1050 <whathappens@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %eax,%esi
cmp    $0x64,%esi
jne    11bf <mastermind+0x7f>
jmp    11c9 <mastermind+0x89>

LLVM IR (-O0):
define void @mastermind() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
store i32 0, i32* %2
store i32 0, i32* %3
%5 = bitcast [4 x i32]* %4 to i8*
%6 = call i32 (...) @screen()
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%8 = call i32 @shuffle(i32* %7)
store i32 1, i32* %1
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %1
%11 = icmp sle i32 %10, 10
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%14 = call i32 @play(i32* %13, i32* %2, i32* %1, i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %12
br label %22
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %9
22: ; preds = %17, %9
%23 = load i32, i32* %1
%24 = icmp ne i32 %23, 100
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%27 = load i32, i32* %1
%28 = load i32, i32* %3
%29 = call i32 @whathappens(i32* %26, i32 %27, i32 %28)
br label %30
30: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
define void @mastermind() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast [4 x i32]* %4 to i8*
%9 = tail call i32 (...) @screen()
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%11 = call i32 @shuffle(i32* %10)
store i32 1, i32* %1
br label %12
12: ; preds = %0, %17
%13 = call i32 @play(i32* %10, i32* %2, i32* %1, i32* %3)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 1
%16 = load i32, i32* %1
br i1 %15, label %20, label %17
17: ; preds = %12
%18 = add nsw i32 %16, 1
store i32 %18, i32* %1
%19 = icmp slt i32 %16, 10
br i1 %19, label %12, label %20
20: ; preds = %17, %12
%21 = phi i32 [ %16, %12 ], [ %18, %17 ]
%22 = icmp eq i32 %21, 100
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @whathappens(i32* %10, i32 %21, i32 %14)
br label %25
25: ; preds = %23, %20
ret void
}