#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 = 11, 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:
      fi = jugar(mida, taulell, freq);
      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   $0xb,-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    12b1 <main+0x171>
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     128c <main+0x14c>
jmp    12a7 <main+0x167>
mov    -0x84(%rbp),%edi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1040 <jugar@plt>
mov    %eax,-0x8c(%rbp)
jmp    12ac <main+0x16c>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <configurar@plt>
mov    %eax,-0x84(%rbp)
jmp    12ac <main+0x16c>
jmp    12ac <main+0x16c>
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
mov    $0xb,%ebp
xor    %r12d,%r12d
lea    0xec3(%rip),%r13
lea    0xed1(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0xec8(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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    %r14,%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    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%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    121d <main+0xcd>
mov    %ebp,%edi
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1050 <jugar@plt>
mov    %eax,%r12d
cmpl   $0x3,0xc(%rsp)
jne    1248 <main+0xf8>
jmp    1252 <main+0x102>
cs nopw 0x0(%rax,%rax,1)
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <configurar@plt>
mov    %eax,%ebp
cmpl   $0x3,0xc(%rsp)
je     1252 <main+0x102>
cmp    $0x1,%r12d
jne    1190 <main+0x40>
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"
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 11, i32* %3
store i32 0, i32* %5
br label %7
7: ; preds = %46, %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 %47
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 %45 [
i32 1, label %34
i32 2, label %40
]
34: ; preds = %32
%35 = load i32, i32* %3
%36 = getelementptr inbounds [11 x [11 x i8]], [11 x [11 x i8]]* %2, i64 0, i64 0
%37 = bitcast [11 x i8]* %36 to i8**
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%39 = call i32 @jugar(i32 %35, i8** %37, i32* %38)
store i32 %39, i32* %5
br label %46
40: ; preds = %32
%41 = getelementptr inbounds [11 x [11 x i8]], [11 x [11 x i8]]* %2, i64 0, i64 0
%42 = bitcast [11 x i8]* %41 to i8**
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%44 = call i32 @configurar(i8** %42, i32* %43)
store i32 %44, i32* %3
br label %46
45: ; preds = %32
br label %46
46: ; preds = %45, %40, %34
br label %7
47: ; 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"
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, %32
%10 = phi i32 [ 0, %0 ], [ %34, %32 ]
%11 = phi i32 [ 11, %0 ], [ %33, %32 ]
%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 %32 [
i32 1, label %28
i32 2, label %30
]
28: ; preds = %26
%29 = call i32 @jugar(i32 %11, i8** %7, i32* %8)
br label %32
30: ; preds = %26
%31 = call i32 @configurar(i8** %7, i32* %8)
br label %32
32: ; preds = %26, %30, %28
%33 = phi i32 [ %11, %26 ], [ %31, %30 ], [ %11, %28 ]
%34 = phi i32 [ %10, %26 ], [ %10, %30 ], [ %29, %28 ]
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 3
%37 = icmp ne i32 %34, 1
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %9, label %39
39: ; preds = %32
ret i32 0
}