#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*/ CountNumbers(int *, int);
int atoi(char *);
int /*<<< orphan*/ avaliacao(char *, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ inicializacao();
scalar_t__ malloc(int);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ srand(int);
int main(int argc, char **argv) {
  int num_thds = 1, size = 100000, *a, i;
  char str[20];
  if (argc == 3) {
    size = atoi(argv[1]);
    num_thds = atoi(argv[2]);
  } else {
    printf("usage: <size> <num_thds>\n");
    return (0);
  }
  omp_set_num_threads(num_thds);
  a = (int *)malloc(size * sizeof(int));
  srand(424242);
  for (i = 0; i < size; ++i) {
    a[i] = rand() % 1000;
  }
  inicializacao();
  CountNumbers(a, size);
  sprintf(str, "%d; %d", size, num_thds);
  avaliacao(str, size);
  free(a);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x186a0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1203 <main+0x53>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    121b <main+0x6b>
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c0 <main+0x110>
mov    -0x14(%rbp),%edi
call   1080 <omp_set_num_threads@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x67932,%edi
call   1060 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    127b <main+0xcb>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1247 <main+0x97>
mov    $0x0,%al
call   10c0 <inicializacao@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1090 <CountNumbers@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd7b(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <avaliacao@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    1282 <main+0xd2>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
mov    0x10(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1080 <omp_set_num_threads@plt>
lea    0x0(,%r12,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    $0x67932,%edi
call   1060 <srand@plt>
test   %r12d,%r12d
jle    1243 <main+0x93>
mov    %r12d,%ebx
xor    %ebp,%ebp
nopl   (%rax)
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x0(%r13,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1210 <main+0x60>
xor    %eax,%eax
call   10c0 <inicializacao@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   1090 <CountNumbers@plt>
lea    0xda4(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12d,%edx
mov    %r14d,%ecx
call   10b0 <sprintf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <avaliacao@plt>
mov    %r13,%rdi
call   1040 <free@plt>
jmp    128e <main+0xde>
lea    0xd7e(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"usage: <size> <num_thds>\0A\00"
@.str.1 = [7 x i8] c"%d; %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 100000, i32* %7
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %7
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
br label %24
22: ; preds = %2
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %62
24: ; preds = %13
%25 = load i32, i32* %6
%26 = call i32 @omp_set_num_threads(i32 %25)
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 4
%30 = trunc i64 %29 to i32
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i32*
store i32* %32, i32** %8
%33 = call i32 @srand(i32 424242)
store i32 0, i32* %9
br label %34
34: ; preds = %45, %24
%35 = load i32, i32* %9
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 1000
%41 = load i32*, i32** %8
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %38
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %34
48: ; preds = %34
%49 = call i32 (...) @inicializacao()
%50 = load i32*, i32** %8
%51 = load i32, i32* %7
%52 = call i32 @CountNumbers(i32* %50, i32 %51)
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%54 = load i32, i32* %7
%55 = load i32, i32* %6
%56 = call i32 @sprintf(i8* %53, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %55)
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%58 = load i32, i32* %7
%59 = call i32 @avaliacao(i8* %57, i32 %58)
%60 = load i32*, i32** %8
%61 = call i32 @free(i32* %60)
store i32 0, i32* %3
br label %62
62: ; preds = %48, %22
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d; %d\00"
@str = [25 x i8] c"usage: <size> <num_thds>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @omp_set_num_threads(i32 %12)
%14 = shl i32 %9, 2
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
%17 = tail call i32 @srand(i32 424242)
%18 = icmp sgt i32 %9, 0
br i1 %18, label %19, label %30
19: ; preds = %6
%20 = zext i32 %9 to i64
br label %23
21: ; preds = %2
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %36
23: ; preds = %19, %23
%24 = phi i64 [ 0, %19 ], [ %28, %23 ]
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 1000
%27 = getelementptr inbounds i32, i32* %16, i64 %24
store i32 %26, i32* %27
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, %20
br i1 %29, label %30, label %23
30: ; preds = %23, %6
%31 = tail call i32 (...) @inicializacao()
%32 = tail call i32 @CountNumbers(i32* %16, i32 %9)
%33 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %12)
%34 = call i32 @avaliacao(i8* %4, i32 %9)
%35 = call i32 @free(i32* %16)
br label %36
36: ; preds = %30, %21
ret i32 0
}