#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*/ _flushall();
int char_convert(char);
int check_victory(int *, int *);
int /*<<< orphan*/ pause_clear(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ random_word(char *, int *);
int /*<<< orphan*/ scanf(char *, char *);
int task3_main(void) {
  int max_guesses = 6, current_guesses = -1, i = 0, guessed[27],
      word_letters[10], victory = 0, letter = 0;
  char word[10], guess = '0';
  for (i = 0; i < 27; i++) {
    guessed[i] = 0;
    if (i < 10) {
      word[i] = '0';
      word_letters[i] = 0;
    }
  }
  random_word(word, word_letters);
  while ((max_guesses > current_guesses) && (!victory)) {
    victory = check_victory(word_letters, guessed);
    if (!victory) {
      current_guesses++;
    }
    printf("Guesses Left: %d\nGuess a Letter...",
           max_guesses - current_guesses);
    _flushall();
    scanf("%c", &guess);
    letter = char_convert(guess) - 1;
    guessed[letter]++;
  }
  pause_clear(0, 1);
  if (victory) {
    printf("You guessed the word!\n");
  } else {
    printf("You didn't guess the word!\n");
  }
  pause_clear(1, 1);
  return 0;
}


x86 assembly (clang, -O0):
<task3_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x6,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
movb   $0x30,-0xc3(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1b,-0xc(%rbp)
jge    1200 <task3_main+0x90>
movslq -0xc(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
cmpl   $0xa,-0xc(%rbp)
jge    11ed <task3_main+0x7d>
movslq -0xc(%rbp),%rax
movb   $0x30,-0xc2(%rbp,%rax,1)
30
movslq -0xc(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
jmp    11f2 <task3_main+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b2 <task3_main+0x42>
lea    -0xc2(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1080 <random_word@plt>
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0xc4(%rbp)
jle    1239 <task3_main+0xc9>
cmpl   $0x0,-0xb4(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0xc4(%rbp)
mov    -0xc4(%rbp),%al
test   $0x1,%al
jne    124c <task3_main+0xdc>
jmp    12d2 <task3_main+0x162>
lea    -0xb0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <check_victory@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jne    1278 <task3_main+0x108>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
sub    -0x8(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <_flushall@plt>
lea    0xd89(%rip),%rdi
lea    -0xc3(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0xc3(%rbp),%edi
call   1030 <char_convert@plt>
sub    $0x1,%eax
mov    %eax,-0xb8(%rbp)
movslq -0xb8(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    1213 <task3_main+0xa3>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <pause_clear@plt>
cmpl   $0x0,-0xb4(%rbp)
je     12fe <task3_main+0x18e>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130c <task3_main+0x19c>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1090 <pause_clear@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task3_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
movb   $0x30,0x5(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movups %xmm0,0x9c(%rsp)
xor    %eax,%eax
jmp    11da <task3_main+0x5a>
nopl   0x0(%rax)
add    $0x3,%rax
cmp    $0x1b,%rax
je     1225 <task3_main+0xa5>
cmp    $0x9,%rax
jbe    11f0 <task3_main+0x70>
cmp    $0x8,%rax
jbe    1203 <task3_main+0x83>
cmp    $0x7,%rax
ja     11d0 <task3_main+0x50>
jmp    1216 <task3_main+0x96>
xchg   %ax,%ax
movb   $0x30,0x6(%rsp,%rax,1)
movl   $0x0,0x10(%rsp,%rax,4)
cmp    $0x8,%rax
ja     11e6 <task3_main+0x66>
movb   $0x30,0x7(%rsp,%rax,1)
movl   $0x0,0x14(%rsp,%rax,4)
cmp    $0x7,%rax
ja     11d0 <task3_main+0x50>
movb   $0x30,0x8(%rsp,%rax,1)
movl   $0x0,0x18(%rsp,%rax,4)
jmp    11d0 <task3_main+0x50>
lea    0x6(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1090 <random_word@plt>
mov    $0xffffffff,%r14d
lea    0x40(%rsp),%r15
lea    0xdba(%rip),%r12
lea    0xdd6(%rip),%r13
lea    0x5(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1060 <check_victory@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
adc    $0x0,%r14d
mov    $0x6,%esi
sub    %r14d,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <_flushall@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movsbl 0x5(%rsp),%edi
call   1030 <char_convert@plt>
cltq
addl   $0x1,0x3c(%rsp,%rax,4)
cmp    $0x5,%r14d
jg     12b5 <task3_main+0x135>
test   %ebp,%ebp
je     1260 <task3_main+0xe0>
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <pause_clear@plt>
test   %ebp,%ebp
lea    0xd5c(%rip),%rax
lea    0xd70(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   10a0 <pause_clear@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Guesses Left: %d\0AGuess a Letter...\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [23 x i8] c"You guessed the word!\0A\00"
@.str.3 = [28 x i8] c"You didn't guess the word!\0A\00"
define i32 @task3_main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [27 x i32]
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca i8
store i32 6, i32* %1
store i32 -1, i32* %2
store i32 0, i32* %3
store i32 0, i32* %6
store i32 0, i32* %7
store i8 48, i8* %9
store i32 0, i32* %3
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 27
br i1 %12, label %13, label %30
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [27 x i32], [27 x i32]* %4, i64 0, i64 %15
store i32 0, i32* %16
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %21
store i8 48, i8* %22
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %24
store i32 0, i32* %25
br label %26
26: ; preds = %19, %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %10
30: ; preds = %10
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%33 = call i32 @random_word(i8* %31, i32* %32)
br label %34
34: ; preds = %53, %30
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
%41 = xor i1 %40, true
br label %42
42: ; preds = %38, %34
%43 = phi i1 [ false, %34 ], [ %41, %38 ]
br i1 %43, label %44, label %68
44: ; preds = %42
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%46 = getelementptr inbounds [27 x i32], [27 x i32]* %4, i64 0, i64 0
%47 = call i32 @check_victory(i32* %45, i32* %46)
store i32 %47, i32* %6
%48 = load i32, i32* %6
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %44
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %53
53: ; preds = %50, %44
%54 = load i32, i32* %1
%55 = load i32, i32* %2
%56 = sub nsw i32 %54, %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = call i32 (...) @_flushall()
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%60 = load i8, i8* %9
%61 = call i32 @char_convert(i8 signext %60)
%62 = sub nsw i32 %61, 1
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [27 x i32], [27 x i32]* %4, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 1
store i32 %67, i32* %65
br label %34
68: ; preds = %42
%69 = call i32 @pause_clear(i32 0, i32 1)
%70 = load i32, i32* %6
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %76
74: ; preds = %68
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %76
76: ; preds = %74, %72
%77 = call i32 @pause_clear(i32 1, i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Guesses Left: %d\0AGuess a Letter...\00"
@.str.1 = [3 x i8] c"%c\00"
@str = [27 x i8] c"You didn't guess the word!\00"
@str.4 = [22 x i8] c"You guessed the word!\00"
define i32 @task3_main() {
%1 = alloca [27 x i32]
%2 = bitcast [27 x i32]* %1 to i8*
%3 = alloca [10 x i32]
%4 = alloca [10 x i8]
%5 = alloca i8
%6 = bitcast [10 x i32]* %3 to i8*
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8 48, i8* %5
br label %8
8: ; preds = %26, %0
%9 = phi i64 [ 0, %0 ], [ %27, %26 ]
%10 = icmp ult i64 %9, 10
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %9
store i8 48, i8* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %9
store i32 0, i32* %13
br label %14
14: ; preds = %8, %11
%15 = add nuw nsw i64 %9, 1
%16 = icmp ult i64 %9, 9
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %15
store i8 48, i8* %18
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %15
store i32 0, i32* %19
br label %20
20: ; preds = %17, %14
%21 = add nuw nsw i64 %9, 2
%22 = icmp ult i64 %9, 8
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %21
store i8 48, i8* %24
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %21
store i32 0, i32* %25
br label %26
26: ; preds = %23, %20
%27 = add nuw nsw i64 %9, 3
%28 = icmp eq i64 %27, 27
br i1 %28, label %29, label %8
29: ; preds = %26
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%31 = call i32 @random_word(i8* %7, i32* %30)
%32 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 0
br label %33
33: ; preds = %29, %33
%34 = phi i32 [ -1, %29 ], [ %38, %33 ]
%35 = call i32 @check_victory(i32* %30, i32* %32)
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = add nsw i32 %34, %37
%39 = sub nsw i32 6, %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = call i32 (...) @_flushall()
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%43 = load i8, i8* %5
%44 = call i32 @char_convert(i8 signext %43)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
store i32 %49, i32* %47
%50 = icmp slt i32 %38, 6
%51 = select i1 %50, i1 %36, i1 false
br i1 %51, label %33, label %52
52: ; preds = %33
%53 = call i32 @pause_clear(i32 0, i32 1)
%54 = select i1 %36, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0)
%55 = call i32 @puts(i8* dereferenceable(1) %54)
%56 = call i32 @pause_clear(i32 1, i32 1)
ret i32 0
}