#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*/ InicializaTabuleiro(char **);
int /*<<< orphan*/ MostraTabuleiro(char **);
scalar_t__ PosicaoValida(char **, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
main() {
  char matriz[8][8];
  int cont = 1;
  int i, j;
  InicializaTabuleiro(matriz);
  while (cont <= 8) {
    MostraTabuleiro(matriz);
    printf("Insira as coordendas de onde deseja colocar a rainha %d.\n", cont);
    printf("(Para reiniciar, insira "
           "0,0"
           "): ");
    scanf("%d,%d", &i, &j);
    if (i == 0 && j == 0) {
      InicializaTabuleiro(matriz);
      cont = 1;
      continue;
    }
    i--;
    j--;
    if (PosicaoValida(matriz, i, j))
      matriz[i][j] = (cont + 48);
    else {
      printf("Posicao invalida! tente novamente!\n");
      continue;
    }
    cont++;
  }
  MostraTabuleiro(matriz);
  printf("Parabens! Voce conseguiu!\n");
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <InicializaTabuleiro@plt>
cmpl   $0x8,-0x54(%rbp)
jg     125d <main+0xfd>
lea    -0x50(%rbp),%rdi
call   1080 <MostraTabuleiro@plt>
mov    -0x54(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x5c(%rbp),%rdx
call   1070 <scanf@plt>
cmpl   $0x0,-0x58(%rbp)
jne    11ee <main+0x8e>
cmpl   $0x0,-0x5c(%rbp)
jne    11ee <main+0x8e>
lea    -0x50(%rbp),%rdi
call   1060 <InicializaTabuleiro@plt>
movl   $0x1,-0x54(%rbp)
jmp    117f <main+0x1f>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
call   1030 <PosicaoValida@plt>
cmp    $0x0,%rax
je     123c <main+0xdc>
mov    -0x54(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
movslq -0x58(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x5c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    124f <main+0xef>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117f <main+0x1f>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    117f <main+0x1f>
lea    -0x50(%rbp),%rdi
call   1080 <MostraTabuleiro@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <InicializaTabuleiro@plt>
mov    $0x1,%ebp
lea    0xea3(%rip),%r15
lea    0xebb(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
jmp    11d7 <main+0x67>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%esi
mov    %esi,0xc(%rsp)
add    $0xffffffff,%edx
mov    %edx,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <PosicaoValida@plt>
test   %rax,%rax
jne    1229 <main+0xb9>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <MostraTabuleiro@plt>
lea    0xe1a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %esi,%eax
or     %edx,%eax
jne    11b0 <main+0x40>
mov    %rbx,%rdi
call   1070 <InicializaTabuleiro@plt>
mov    $0x1,%ebp
cmp    $0x9,%ebp
jl     11d7 <main+0x67>
jmp    1249 <main+0xd9>
lea    0x30(%rbp),%eax
movslq 0xc(%rsp),%rcx
movslq 0x8(%rsp),%rdx
lea    (%rsp,%rcx,8),%rcx
add    $0x10,%rcx
mov    %al,(%rdx,%rcx,1)
add    $0x1,%ebp
cmp    $0x9,%ebp
jl     11d7 <main+0x67>
lea    0x10(%rsp),%rdi
call   1090 <MostraTabuleiro@plt>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Insira as coordendas de onde deseja colocar a rainha %d.\0A\00"
@.str.1 = [31 x i8] c"(Para reiniciar, insira 0,0): \00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [36 x i8] c"Posicao invalida! tente novamente!\0A\00"
@.str.4 = [27 x i8] c"Parabens! Voce conseguiu!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x [8 x i8]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
%6 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 0
%7 = bitcast [8 x i8]* %6 to i8**
%8 = call i32 @InicializaTabuleiro(i8** %7)
br label %9
9: ; preds = %52, %50, %25, %0
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 8
br i1 %11, label %12, label %55
12: ; preds = %9
%13 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 0
%14 = bitcast [8 x i8]* %13 to i8**
%15 = call i32 @MostraTabuleiro(i8** %14)
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5)
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %12
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 0
%27 = bitcast [8 x i8]* %26 to i8**
%28 = call i32 @InicializaTabuleiro(i8** %27)
store i32 1, i32* %3
br label %9
29: ; preds = %22, %12
%30 = load i32, i32* %4
%31 = add nsw i32 %30, -1
store i32 %31, i32* %4
%32 = load i32, i32* %5
%33 = add nsw i32 %32, -1
store i32 %33, i32* %5
%34 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 0
%35 = bitcast [8 x i8]* %34 to i8**
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = call i64 @PosicaoValida(i8** %35, i32 %36, i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %29
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 48
%43 = trunc i32 %42 to i8
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 %45
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x i8], [8 x i8]* %46, i64 0, i64 %48
store i8 %43, i8* %49
br label %52
50: ; preds = %29
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %9
52: ; preds = %40
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %9
55: ; preds = %9
%56 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %2, i64 0, i64 0
%57 = bitcast [8 x i8]* %56 to i8**
%58 = call i32 @MostraTabuleiro(i8** %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 (...) @getchar()
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [58 x i8] c"Insira as coordendas de onde deseja colocar a rainha %d.\0A\00"
@.str.1 = [31 x i8] c"(Para reiniciar, insira 0,0): \00"
@.str.2 = [6 x i8] c"%d,%d\00"
@str = [26 x i8] c"Parabens! Voce conseguiu!\00"
@str.5 = [35 x i8] c"Posicao invalida! tente novamente!\00"
define i32 @main() {
%1 = alloca [8 x [8 x i8]]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %1, i64 0, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast [8 x [8 x i8]]* %1 to i8**
%8 = call i32 @InicializaTabuleiro(i8** %7)
br label %9
9: ; preds = %0, %22
%10 = phi i32 [ 1, %0 ], [ %23, %22 ]
%11 = call i32 @MostraTabuleiro(i8** %7)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %10)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %20, label %25
20: ; preds = %41, %9
%21 = call i32 @InicializaTabuleiro(i8** %7)
br label %22
22: ; preds = %20, %32
%23 = phi i32 [ %40, %32 ], [ 1, %20 ]
%24 = icmp slt i32 %23, 9
br i1 %24, label %9, label %52
25: ; preds = %9, %41
%26 = phi i32 [ %49, %41 ], [ %17, %9 ]
%27 = phi i32 [ %47, %41 ], [ %15, %9 ]
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
%29 = add nsw i32 %26, -1
store i32 %29, i32* %3
%30 = call i64 @PosicaoValida(i8** %7, i32 %28, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %41, label %32
32: ; preds = %25
%33 = trunc i32 %10 to i8
%34 = add i8 %33, 48
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [8 x [8 x i8]], [8 x [8 x i8]]* %1, i64 0, i64 %36, i64 %38
store i8 %34, i8* %39
%40 = add nsw i32 %10, 1
br label %22
41: ; preds = %25
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%43 = call i32 @MostraTabuleiro(i8** %7)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %10)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%47 = load i32, i32* %2
%48 = icmp eq i32 %47, 0
%49 = load i32, i32* %3
%50 = icmp eq i32 %49, 0
%51 = select i1 %48, i1 %50, i1 false
br i1 %51, label %20, label %25
52: ; preds = %22
%53 = call i32 @MostraTabuleiro(i8** %7)
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%55 = call i32 (...) @getchar()
ret i32 0
}