#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*/ cicloNomade(int, int, int, int);
int /*<<< orphan*/ imprimeMatriz(int **);
int /*<<< orphan*/ intervaloRecursos(int, int);
int /*<<< orphan*/ preencheMatriz(int **);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int iMapaGeografico[6][11];
  int iCiclos = 0;
  int iIntervalo;
  int iPontox = 0;
  int iPontoy = 0;
  int iPopulacao = 0;
  int iRecursos = 0;
  srand(time(NULL));
  preencheMatriz(iMapaGeografico);
  imprimeMatriz(iMapaGeografico);
  printf("\n");
  iPopulacao = rand() % 21;
  if (iPopulacao < 3) {
    iPopulacao = 20 - iPopulacao;
  }
  iPontox = rand() % 6;
  iPontoy = rand() % 11;
  printf("A populacao do grupo nomade e %d\n", iPopulacao);
  printf("O coordenada da localizacao do grupo nomade e %d\n", iPontox);
  printf("O Adirissa da localizacao do grupo nomade e %d\n", iPontoy);
  iRecursos = iMapaGeografico[iPontox][iPontoy];
  printf("\n Quantidade de recursos: %d", iRecursos);
  intervaloRecursos(iRecursos, iIntervalo);
  cicloNomade(iRecursos, iIntervalo, iPopulacao, iCiclos);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x11c(%rbp)
movl   $0x0,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x110(%rbp),%rdi
call   1040 <preencheMatriz@plt>
lea    -0x110(%rbp),%rdi
call   1080 <imprimeMatriz@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x15,%ecx
cltd
idiv   %ecx
mov    %edx,-0x124(%rbp)
cmpl   $0x3,-0x124(%rbp)
jge    122d <main+0xad>
mov    $0x14,%eax
sub    -0x124(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x11c(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,-0x120(%rbp)
mov    -0x124(%rbp),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x11c(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x120(%rbp),%esi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x11c(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x2c,%rcx,%rcx
add    %rcx,%rax
movslq -0x120(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x128(%rbp),%edi
mov    -0x118(%rbp),%esi
call   1090 <intervaloRecursos@plt>
mov    -0x128(%rbp),%edi
mov    -0x118(%rbp),%esi
mov    -0x124(%rbp),%edx
mov    -0x114(%rbp),%ecx
call   1030 <cicloNomade@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <preencheMatriz@plt>
mov    %rbx,%rdi
call   1090 <imprimeMatriz@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x30c30c31,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
mov    $0x14,%r14d
sub    %eax,%r14d
cmp    $0x3,%eax
cmovge %eax,%r14d
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rbx
imul   $0x2aaaaaab,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rbp
imul   $0x2e8ba2e9,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
sub    %eax,%ebp
lea    0xdb0(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdc1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xde3(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %ebx,%rax
movslq %ebp,%rcx
imul   $0x2c,%rax,%rax
add    %rsp,%rax
mov    (%rax,%rcx,4),%ebx
lea    0xdf3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   10a0 <intervaloRecursos@plt>
mov    %ebx,%edi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1040 <cicloNomade@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [34 x i8] c"A populacao do grupo nomade e %d\0A\00"
@.str.2 = [50 x i8] c"O coordenada da localizacao do grupo nomade e %d\0A\00"
@.str.3 = [48 x i8] c"O Adirissa da localizacao do grupo nomade e %d\0A\00"
@.str.4 = [29 x i8] c"\0A Quantidade de recursos: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x [11 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = getelementptr inbounds [6 x [11 x i32]], [6 x [11 x i32]]* %2, i64 0, i64 0
%12 = bitcast [11 x i32]* %11 to i32**
%13 = call i32 @preencheMatriz(i32** %12)
%14 = getelementptr inbounds [6 x [11 x i32]], [6 x [11 x i32]]* %2, i64 0, i64 0
%15 = bitcast [11 x i32]* %14 to i32**
%16 = call i32 @imprimeMatriz(i32** %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 21
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %25
22: ; preds = %0
%23 = load i32, i32* %7
%24 = sub nsw i32 20, %23
store i32 %24, i32* %7
br label %25
25: ; preds = %22, %0
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 6
store i32 %27, i32* %5
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 11
store i32 %29, i32* %6
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [6 x [11 x i32]], [6 x [11 x i32]]* %2, i64 0, i64 %37
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [11 x i32], [11 x i32]* %38, i64 0, i64 %40
%42 = load i32, i32* %41
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %8
%46 = load i32, i32* %4
%47 = call i32 @intervaloRecursos(i32 %45, i32 %46)
%48 = load i32, i32* %8
%49 = load i32, i32* %4
%50 = load i32, i32* %7
%51 = load i32, i32* %3
%52 = call i32 @cicloNomade(i32 %48, i32 %49, i32 %50, i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"A populacao do grupo nomade e %d\0A\00"
@.str.2 = [50 x i8] c"O coordenada da localizacao do grupo nomade e %d\0A\00"
@.str.3 = [48 x i8] c"O Adirissa da localizacao do grupo nomade e %d\0A\00"
@.str.4 = [29 x i8] c"\0A Quantidade de recursos: %d\00"
define i32 @main() {
%1 = alloca [6 x [11 x i32]]
%2 = bitcast [6 x [11 x i32]]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast [6 x [11 x i32]]* %1 to i32**
%6 = call i32 @preencheMatriz(i32** %5)
%7 = call i32 @imprimeMatriz(i32** %5)
%8 = call i32 @putchar(i32 10)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 21
%11 = icmp slt i32 %10, 3
%12 = sub nsw i32 20, %10
%13 = select i1 %11, i32 %12, i32 %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 6
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%21 = sext i32 %15 to i64
%22 = sext i32 %17 to i64
%23 = getelementptr inbounds [6 x [11 x i32]], [6 x [11 x i32]]* %1, i64 0, i64 %21, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = call i32 @intervaloRecursos(i32 %24, i32 undef)
%27 = call i32 @cicloNomade(i32 %24, i32 undef, i32 %13, i32 0)
ret i32 0
}