#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int omp_get_thread_num();
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  omp_set_num_threads(4);
  int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int N = sizeof(a) / sizeof(int);
#pragma omp parallel for
  for (int i = 0; i < N; i++) {
    printf("thread %d, i = %2d\n", omp_get_thread_num(), i);
    a[i] = a[i] + 10 * omp_get_thread_num();
  }
  for (int i = 0; i < N; i++)
    printf("%02d ", a[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
lea    -0x30(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0xa,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11d2 <main+0x92>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
mov    -0x38(%rbp),%edx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    -0x40(%rbp),%ecx
imul   $0xa,%eax,%eax
add    %eax,%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    117c <main+0x3c>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1209 <main+0xc9>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d9 <main+0x99>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xe9a(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
add    %eax,%eax
lea    (%rax,%rax,4),%ebp
or     $0x1,%ebp
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    $0x2,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    $0x3,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    $0x4,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    $0x5,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r15d
add    $0x6,%r15d
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r12d
add    $0x7,%r12d
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r13d
add    $0x8,%r13d
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%ebx
add    $0x9,%ebx
lea    0xd10(%rip),%r14
mov    %r14,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"thread %d, i = %2d\0A\00"
@.str.1 = [6 x i8] c"%02d \00"
define i32 @main() {
%1 = tail call i32 @omp_set_num_threads(i32 4)
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %2, i32 0)
%4 = tail call i32 (...) @omp_get_thread_num()
%5 = mul nsw i32 %4, 10
%6 = tail call i32 (...) @omp_get_thread_num()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %6, i32 1)
%8 = tail call i32 (...) @omp_get_thread_num()
%9 = mul nsw i32 %8, 10
%10 = or i32 %9, 1
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %11, i32 2)
%13 = tail call i32 (...) @omp_get_thread_num()
%14 = mul nsw i32 %13, 10
%15 = add nsw i32 %14, 2
%16 = tail call i32 (...) @omp_get_thread_num()
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %16, i32 3)
%18 = tail call i32 (...) @omp_get_thread_num()
%19 = mul nsw i32 %18, 10
%20 = add nsw i32 %19, 3
%21 = tail call i32 (...) @omp_get_thread_num()
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %21, i32 4)
%23 = tail call i32 (...) @omp_get_thread_num()
%24 = mul nsw i32 %23, 10
%25 = add nsw i32 %24, 4
%26 = tail call i32 (...) @omp_get_thread_num()
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %26, i32 5)
%28 = tail call i32 (...) @omp_get_thread_num()
%29 = mul nsw i32 %28, 10
%30 = add nsw i32 %29, 5
%31 = tail call i32 (...) @omp_get_thread_num()
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %31, i32 6)
%33 = tail call i32 (...) @omp_get_thread_num()
%34 = mul nsw i32 %33, 10
%35 = add nsw i32 %34, 6
%36 = tail call i32 (...) @omp_get_thread_num()
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %36, i32 7)
%38 = tail call i32 (...) @omp_get_thread_num()
%39 = mul nsw i32 %38, 10
%40 = add nsw i32 %39, 7
%41 = tail call i32 (...) @omp_get_thread_num()
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %41, i32 8)
%43 = tail call i32 (...) @omp_get_thread_num()
%44 = mul nsw i32 %43, 10
%45 = add nsw i32 %44, 8
%46 = tail call i32 (...) @omp_get_thread_num()
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %46, i32 9)
%48 = tail call i32 (...) @omp_get_thread_num()
%49 = mul nsw i32 %48, 10
%50 = add nsw i32 %49, 9
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%61 = tail call i32 @putchar(i32 10)
ret i32 0
}