#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_procs();
int omp_get_num_threads();
int /*<<< orphan*/ printf(char *, int);
int sin(int);
int main(int argc, char *argv[]) {
  int k;
  int x;
#pragma omp parallel for private(k, x)
  for (k = 0; k < 80; k++) {
    x = sin(k * 2.0) * 100 + 1;
    if (x > 60)
      x = x % 60 + 1;
    printf("x = %d\n", x);
    int numth = omp_get_num_threads();
    printf("th = %d\n", numth);
  }
  int num = omp_get_num_procs();
  printf("cores = %d\n", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    11db <main+0x9b>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
imul   $0x64,%eax,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3c,-0x18(%rbp)
jle    11a5 <main+0x65>
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <omp_get_num_threads@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
mov    $0x0,%al
call   1060 <omp_get_num_procs@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x88888889,%r15d
lea    0xeac(%rip),%r14
lea    0xead(%rip),%rbx
xor    %ebp,%ebp
jmp    1184 <main+0x44>
nop
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_num_threads@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x2,%ebp
cmp    $0xa0,%ebp
je     11ac <main+0x6c>
mov    %ebp,%edi
call   1050 <sin@plt>
imul   $0x64,%eax,%esi
or     $0x1,%esi
cmp    $0x3d,%esi
jl     1160 <main+0x20>
mov    %esi,%eax
imul   %r15,%rax
shr    $0x25,%rax
imul   $0x3c,%eax,%eax
neg    %eax
add    %eax,%esi
add    $0x1,%esi
jmp    1160 <main+0x20>
xor    %eax,%eax
call   1060 <omp_get_num_procs@plt>
lea    0xe57(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"x = %d\0A\00"
@.str.1 = [9 x i8] c"th = %d\0A\00"
@.str.2 = [12 x i8] c"cores = %d\0A\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %10
10: ; preds = %33, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 80
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 2.000000e+00
%17 = fptosi double %16 to i32
%18 = call i32 @sin(i32 %17)
%19 = mul nsw i32 %18, 100
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 60
br i1 %22, label %23, label %27
23: ; preds = %13
%24 = load i32, i32* %7
%25 = srem i32 %24, 60
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %27
27: ; preds = %23, %13
%28 = load i32, i32* %7
%29 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = call i32 (...) @omp_get_num_threads()
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %10
36: ; preds = %10
%37 = call i32 (...) @omp_get_num_procs()
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"x = %d\0A\00"
@.str.1 = [9 x i8] c"th = %d\0A\00"
@.str.2 = [12 x i8] c"cores = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %13
%4 = phi i32 [ 0, %2 ], [ %18, %13 ]
%5 = shl nuw i32 %4, 1
%6 = tail call i32 @sin(i32 %5)
%7 = mul nsw i32 %6, 100
%8 = or i32 %7, 1
%9 = icmp sgt i32 %8, 60
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = urem i32 %8, 60
%12 = add nuw nsw i32 %11, 1
br label %13
13: ; preds = %10, %3
%14 = phi i32 [ %12, %10 ], [ %8, %3 ]
%15 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = tail call i32 (...) @omp_get_num_threads()
%17 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %4, 1
%19 = icmp eq i32 %18, 80
br i1 %19, label %20, label %3
20: ; preds = %13
%21 = tail call i32 (...) @omp_get_num_procs()
%22 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}