#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*/ OddEven(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 = 1024, *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() % size;
    printf("%d ", a[i]);
  }
  printf("\n");
  inicializacao();
  OddEven(a, size);
  sprintf(str, "%d; %d", size, num_thds);
  avaliacao(str, size);
  for (i = 0; i < size; ++i) {
    printf("%d ", a[i]);
  }
  printf("\n");
  ;
  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   $0x400,-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    121d <main+0x6d>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132d <main+0x17d>
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    1292 <main+0xe2>
mov    $0x0,%al
call   10d0 <rand@plt>
cltd
idivl  -0x18(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1249 <main+0x99>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10c0 <inicializacao@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1090 <OddEven@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd5a(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <avaliacao@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    130f <main+0x15f>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12dc <main+0x12c>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@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    12da <main+0x10a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   10a0 <omp_set_num_threads@plt>
lea    0x0(,%r14,4),%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    $0x67932,%edi
call   1080 <srand@plt>
test   %r14d,%r14d
jle    12e8 <main+0x118>
mov    %r14d,%ebp
lea    0xdca(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10f0 <rand@plt>
cltd
idiv   %r14d
mov    %edx,0x0(%r13,%rbx,4)
mov    %r12,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1240 <main+0x70>
mov    $0xa,%edi
call   1050 <putchar@plt>
xor    %eax,%eax
call   10e0 <inicializacao@plt>
mov    %r13,%rdi
mov    %r14d,%esi
call   10b0 <OddEven@plt>
lea    0xd7c(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
call   10d0 <sprintf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1030 <avaliacao@plt>
test   %r14d,%r14d
jle    1327 <main+0x157>
lea    0xd50(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12c0 <main+0xf0>
jmp    1327 <main+0x157>
lea    0xd2a(%rip),%rdi
call   1060 <puts@plt>
jmp    1339 <main+0x169>
mov    $0xa,%edi
call   1050 <putchar@plt>
xor    %eax,%eax
call   10e0 <inicializacao@plt>
mov    %r13,%rdi
mov    %r14d,%esi
call   10b0 <OddEven@plt>
lea    0xcf9(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <avaliacao@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r13,%rdi
call   1040 <free@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 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [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 1024, 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 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %86
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 = %52, %24
%35 = load i32, i32* %9
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %55
38: ; preds = %34
%39 = call i32 (...) @rand()
%40 = load i32, i32* %7
%41 = srem i32 %39, %40
%42 = load i32*, i32** %8
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 %41, i32* %45
%46 = load i32*, i32** %8
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %38
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %34
55: ; preds = %34
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 (...) @inicializacao()
%58 = load i32*, i32** %8
%59 = load i32, i32* %7
%60 = call i32 @OddEven(i32* %58, i32 %59)
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%62 = load i32, i32* %7
%63 = load i32, i32* %6
%64 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %62, i32 %63)
%65 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%66 = load i32, i32* %7
%67 = call i32 @avaliacao(i8* %65, i32 %66)
store i32 0, i32* %9
br label %68
68: ; preds = %79, %55
%69 = load i32, i32* %9
%70 = load i32, i32* %7
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %82
72: ; preds = %68
%73 = load i32*, i32** %8
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %73, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %72
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %68
82: ; preds = %68
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32*, i32** %8
%85 = call i32 @free(i32* %84)
store i32 0, i32* %3
br label %86
86: ; preds = %82, %22
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [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 %46
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 %55
23: ; preds = %19, %23
%24 = phi i64 [ 0, %19 ], [ %29, %23 ]
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, %9
%27 = getelementptr inbounds i32, i32* %16, i64 %24
store i32 %26, i32* %27
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %20
br i1 %30, label %31, label %23
31: ; preds = %23
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 (...) @inicializacao()
%34 = tail call i32 @OddEven(i32* %16, i32 %9)
%35 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %12)
%36 = call i32 @avaliacao(i8* %4, i32 %9)
br i1 %18, label %37, label %52
37: ; preds = %31
%38 = zext i32 %9 to i64
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ 0, %37 ], [ %44, %39 ]
%41 = getelementptr inbounds i32, i32* %16, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %40, 1
%45 = icmp eq i64 %44, %38
br i1 %45, label %52, label %39
46: ; preds = %6
%47 = tail call i32 @putchar(i32 10)
%48 = tail call i32 (...) @inicializacao()
%49 = tail call i32 @OddEven(i32* %16, i32 %9)
%50 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %12)
%51 = call i32 @avaliacao(i8* %4, i32 %9)
br label %52
52: ; preds = %39, %46, %31
%53 = call i32 @putchar(i32 10)
%54 = call i32 @free(i32* %16)
br label %55
55: ; preds = %52, %21
ret i32 0
}