#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 configurar(char **, int *);
int jugar(int, char **, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  char taulell[11][11];
  int mida = 0, op, fi = 0;
  int freq[5];
  while (op != 3 && fi != 1) {
    printf("\nIntrodueix un d'aquests nombres per a realitzar l'accio "
           "corresponent:\n");
    printf("\n\t1.Jugar una partida");
    printf("\n\t2.Configuracio del Taulell");
    printf("\n\t3.Sortir del joc\n\t");
    scanf("%d", &op);
    while (op < 1 || op > 3) {
      printf("Introdueix un nombre valid: ");
      scanf("%d", &op);
    }
    switch (op) {
    case 1:
      if (mida != 0) {
        fi = jugar(mida, taulell, freq);
      } else {
        printf("\n Per a jugar primer has de configurar el taulell!!\n");
      }
      break;
    case 2:
      mida = configurar(taulell, freq);
      break;
    default:
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x8c(%rbp)
xor    %eax,%eax
cmpl   $0x3,-0x88(%rbp)
mov    %al,-0xa1(%rbp)
je     118b <main+0x4b>
cmpl   $0x1,-0x8c(%rbp)
setne  %al
mov    %al,-0xa1(%rbp)
mov    -0xa1(%rbp),%al
test   $0x1,%al
jne    119e <main+0x5e>
jmp    12cf <main+0x18f>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x88(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x88(%rbp)
mov    %al,-0xa2(%rbp)
jl     1206 <main+0xc6>
cmpl   $0x3,-0x88(%rbp)
setg   %al
mov    %al,-0xa2(%rbp)
mov    -0xa2(%rbp),%al
test   $0x1,%al
jne    1219 <main+0xd9>
jmp    123d <main+0xfd>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x88(%rbp),%rsi
call   1050 <scanf@plt>
jmp    11e1 <main+0xa1>
mov    -0x88(%rbp),%eax
mov    %eax,-0xa8(%rbp)
sub    $0x1,%eax
je     126b <main+0x12b>
jmp    1257 <main+0x117>
mov    -0xa8(%rbp),%eax
sub    $0x2,%eax
je     12aa <main+0x16a>
jmp    12c5 <main+0x185>
cmpl   $0x0,-0x84(%rbp)
je     1299 <main+0x159>
mov    -0x84(%rbp),%edi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1040 <jugar@plt>
mov    %eax,-0x8c(%rbp)
jmp    12a5 <main+0x165>
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
jmp    12ca <main+0x18a>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <configurar@plt>
mov    %eax,-0x84(%rbp)
jmp    12ca <main+0x18a>
jmp    12ca <main+0x18a>
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
xor    %r15d,%r15d
lea    0xec8(%rip),%r13
lea    0xed6(%rip),%rbx
lea    0xc(%rsp),%rbp
lea    0xecd(%rip),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffc,%ecx
ja     11ff <main+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     11e0 <main+0x90>
cmp    $0x2,%eax
je     1230 <main+0xe0>
cmp    $0x1,%eax
jne    1242 <main+0xf2>
test   %r12d,%r12d
je     1255 <main+0x105>
mov    %r12d,%edi
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1050 <jugar@plt>
mov    %eax,%r15d
cmpl   $0x3,0xc(%rsp)
jne    1249 <main+0xf9>
jmp    126b <main+0x11b>
nopl   0x0(%rax)
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <configurar@plt>
mov    %eax,%r12d
cmpl   $0x3,0xc(%rsp)
je     126b <main+0x11b>
cmp    $0x1,%r15d
jne    1190 <main+0x40>
jmp    126b <main+0x11b>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
cmpl   $0x3,0xc(%rsp)
jne    1249 <main+0xf9>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [72 x i8] c"\0AIntrodueix un d'aquests nombres per a realitzar l'accio corresponent:\0A\00"
@.str.1 = [22 x i8] c"\0A\091.Jugar una partida\00"
@.str.2 = [29 x i8] c"\0A\092.Configuracio del Taulell\00"
@.str.3 = [21 x i8] c"\0A\093.Sortir del joc\0A\09\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [29 x i8] c"Introdueix un nombre valid: \00"
@.str.6 = [53 x i8] c"\0A Per a jugar primer has de configurar el taulell!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x [11 x i8]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [5 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
br label %7
7: ; preds = %52, %0
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 1
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ false, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %53
15: ; preds = %13
%16 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %21
21: ; preds = %29, %15
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 1
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 3
br label %27
27: ; preds = %24, %21
%28 = phi i1 [ true, %21 ], [ %26, %24 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %21
32: ; preds = %27
%33 = load i32, i32* %4
switch i32 %33, label %51 [
i32 1, label %34
i32 2, label %46
]
34: ; preds = %32
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i32, i32* %3
%39 = getelementptr inbounds [11 x [11 x i8]], [11 x [11 x i8]]* %2, i64 0, i64 0
%40 = bitcast [11 x i8]* %39 to i8**
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%42 = call i32 @jugar(i32 %38, i8** %40, i32* %41)
store i32 %42, i32* %5
br label %45
43: ; preds = %34
%44 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
br label %45
45: ; preds = %43, %37
br label %52
46: ; preds = %32
%47 = getelementptr inbounds [11 x [11 x i8]], [11 x [11 x i8]]* %2, i64 0, i64 0
%48 = bitcast [11 x i8]* %47 to i8**
%49 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%50 = call i32 @configurar(i8** %48, i32* %49)
store i32 %50, i32* %3
br label %52
51: ; preds = %32
br label %52
52: ; preds = %51, %46, %45
br label %7
53: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"\0A\091.Jugar una partida\00"
@.str.2 = [29 x i8] c"\0A\092.Configuracio del Taulell\00"
@.str.3 = [21 x i8] c"\0A\093.Sortir del joc\0A\09\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [29 x i8] c"Introdueix un nombre valid: \00"
@str = [71 x i8] c"\0AIntrodueix un d'aquests nombres per a realitzar l'accio corresponent:\00"
@str.7 = [52 x i8] c"\0A Per a jugar primer has de configurar el taulell!!\00"
define i32 @main() {
%1 = alloca [11 x [11 x i8]]
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = getelementptr inbounds [11 x [11 x i8]], [11 x [11 x i8]]* %1, i64 0, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast [5 x i32]* %3 to i8*
%7 = bitcast [11 x [11 x i8]]* %1 to i8**
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
br label %9
9: ; preds = %0, %36
%10 = phi i32 [ 0, %0 ], [ %38, %36 ]
%11 = phi i32 [ 0, %0 ], [ %37, %36 ]
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = add i32 %17, -4
%19 = icmp ult i32 %18, -3
br i1 %19, label %20, label %26
20: ; preds = %9, %20
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = add i32 %23, -4
%25 = icmp ult i32 %24, -3
br i1 %25, label %20, label %26
26: ; preds = %20, %9
%27 = phi i32 [ %17, %9 ], [ %23, %20 ]
switch i32 %27, label %36 [
i32 1, label %28
i32 2, label %34
]
28: ; preds = %26
%29 = icmp eq i32 %11, 0
br i1 %29, label %32, label %30
30: ; preds = %28
%31 = call i32 @jugar(i32 %11, i8** %7, i32* %8)
br label %36
32: ; preds = %28
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.7, i64 0, i64 0))
br label %36
34: ; preds = %26
%35 = call i32 @configurar(i8** %7, i32* %8)
br label %36
36: ; preds = %26, %30, %32, %34
%37 = phi i32 [ %11, %26 ], [ %35, %34 ], [ %11, %30 ], [ 0, %32 ]
%38 = phi i32 [ %10, %26 ], [ %10, %34 ], [ %31, %30 ], [ %10, %32 ]
%39 = load i32, i32* %2
%40 = icmp ne i32 %39, 3
%41 = icmp ne i32 %38, 1
%42 = select i1 %40, i1 %41, i1 false
br i1 %42, label %9, label %43
43: ; preds = %36
ret i32 0
}