#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 omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main() {
  int N = 12;
  int array[] = {12, 432, 23, 435, 65, 2, 657, 456, 4, 45, 89, 20};
  int np = 0, iam = 0, inicio, fin, TAM;
#pragma omp parallel private(np, iam, TAM, inicio, fin)
  {
    np = omp_get_num_threads();
    iam = omp_get_thread_num();
    TAM = N / np;
    inicio = iam * TAM;
    fin = inicio + TAM;
    for (inicio; inicio < fin; inicio++) {
      printf("Thread %d of %d - array[%d] %d\n", iam + 1, np, inicio,
             array[inicio]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x44(%rbp)
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%eax
imul   -0x54(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    11e5 <main+0xa5>
mov    -0x48(%rbp),%esi
add    $0x1,%esi
mov    -0x44(%rbp),%edx
mov    -0x4c(%rbp),%ecx
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%r8d
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11aa <main+0x6a>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%r12d
mov    $0xc,%eax
xor    %edx,%edx
idiv   %r14d
test   %eax,%eax
jle    11b1 <main+0x81>
mov    %eax,%ecx
imul   %r12d,%ecx
add    %ecx,%eax
add    $0x1,%r12d
movslq %ecx,%rbx
movslq %eax,%r13
lea    0xe8a(%rip),%rax
lea    (%rax,%rbx,4),%rbp
lea    0xeaf(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%r8d
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1040 <printf@plt>
add    $0x1,%rbx
add    $0x4,%rbp
cmp    %r13,%rbx
jl     1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.array = [12 x i32] [i32 12, i32 432, i32 23, i32 435, i32 65, i32 2, i32 657, i32 456, i32 4, i32 45, i32 89, i32 20]
@.str = [32 x i8] c"Thread %d of %d - array[%d] %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [12 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 12, i32* %2
%9 = bitcast [12 x i32]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
%10 = call i32 (...) @omp_get_num_threads()
store i32 %10, i32* %4
%11 = call i32 (...) @omp_get_thread_num()
store i32 %11, i32* %5
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = sdiv i32 %12, %13
store i32 %14, i32* %8
%15 = load i32, i32* %5
%16 = load i32, i32* %8
%17 = mul nsw i32 %15, %16
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = add nsw i32 %18, %19
store i32 %20, i32* %7
%21 = load i32, i32* %6
br label %22
22: ; preds = %36, %0
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %4
%30 = load i32, i32* %6
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29, i32 %30, i32 %34)
br label %36
36: ; preds = %26
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %22
39: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [12 x i32] [i32 12, i32 432, i32 23, i32 435, i32 65, i32 2, i32 657, i32 456, i32 4, i32 45, i32 89, i32 20]
@.str = [32 x i8] c"Thread %d of %d - array[%d] %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_num_threads()
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = sdiv i32 12, %1
%4 = mul i32 %3, %2
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %19
6: ; preds = %0
%7 = add nsw i32 %4, %3
%8 = add nsw i32 %2, 1
%9 = sext i32 %4 to i64
%10 = sext i32 %7 to i64
br label %11
11: ; preds = %6, %11
%12 = phi i64 [ %9, %6 ], [ %17, %11 ]
%13 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.main.array, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = trunc i64 %12 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %1, i32 %15, i32 %14)
%17 = add nsw i64 %12, 1
%18 = icmp slt i64 %17, %10
br i1 %18, label %11, label %19
19: ; preds = %11, %0
ret i32 0
}