#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_thread_num();
int main(int argc, char const *argv[]) {
  int a[100000];
  int i;
  for (i = 0; i < 100000; i++)
    a[i] = i;
#pragma omp parallel
  {
    int sum, i;
    int tid = omp_get_thread_num();
    for (i = tid * 100000 / 8; i < (tid + 1) * 100000 / 8; i++)
      sum += a[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x61a94(%rbp)
cmpl   $0x186a0,-0x61a94(%rbp)
jge    116b <main+0x5b>
mov    -0x61a94(%rbp),%ecx
movslq -0x61a94(%rbp),%rax
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x61a94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61a94(%rbp)
jmp    1133 <main+0x23>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x61aa0(%rbp)
imul   $0x186a0,-0x61aa0(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x61a9c(%rbp)
mov    -0x61a9c(%rbp),%eax
mov    %eax,-0x61aa4(%rbp)
mov    -0x61aa0(%rbp),%eax
add    $0x1,%eax
imul   $0x186a0,%eax,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x61aa4(%rbp),%eax
cmp    %ecx,%eax
jge    11f1 <main+0xe1>
movslq -0x61a9c(%rbp),%rax
mov    -0x61a90(%rbp,%rax,4),%eax
add    -0x61a98(%rbp),%eax
mov    %eax,-0x61a98(%rbp)
mov    -0x61a9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61a9c(%rbp)
jmp    1190 <main+0x80>
xor    %eax,%eax
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @omp_get_thread_num()
ret i32 0
}