#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 /*<<< orphan*/ printf(char *, int, int, int, int, ...);
void multi_scope(void) {
  int i01 = 1, i02 = 2;
  {
    int i11 = 11, i12 = 12;
    {
      int i21 = -21, i22 = 22;
#pragma omp parallel num_threads(2) firstprivate(i01) shared(i11) private(i21)
      {
        int thread_num = omp_get_thread_num();
        i21 = 100 * (thread_num + 1) + 21;
#pragma omp critical
        printf("multi_scope: thread_num=%d, i01=%d, i11=%d, i21=%d\n",
               thread_num, i01, i11, i21);
      }
      printf("multi_scope: i01=%d, i02=%d, i11=%d, "
             "i12=%d, i21=%d, i22=%d\n",
             i01, i02, i11, i12, i21, i22);
    }
  }
}


x86 assembly (clang, -O0):
<multi_scope>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0xb,-0xc(%rbp)
movl   $0xc,-0x10(%rbp)
movl   $0xffffffeb,-0x14(%rbp)
movl   $0x16,-0x18(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
imul   $0x64,%eax,%eax
add    $0x15,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xe93(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_scope>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
imul   $0x64,%eax,%ebx
add    $0x79,%ebx
lea    0xec7(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    $0xb,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x16,(%rsp)
lea    0xed7(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0xb,%ecx
mov    $0xc,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"multi_scope: thread_num=%d, i01=%d, i11=%d, i21=%d\0A\00"
@.str.1 = [61 x i8] c"multi_scope: i01=%d, i02=%d, i11=%d, i12=%d, i21=%d, i22=%d\0A\00"
define void @multi_scope() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 1, i32* %1
store i32 2, i32* %2
store i32 11, i32* %3
store i32 12, i32* %4
store i32 -21, i32* %5
store i32 22, i32* %6
%8 = call i32 (...) @omp_get_thread_num()
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = add nsw i32 %9, 1
%11 = mul nsw i32 100, %10
%12 = add nsw i32 %11, 21
store i32 %12, i32* %5
%13 = load i32, i32* %7
%14 = load i32, i32* %1
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21, i32 %22, i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [52 x i8] c"multi_scope: thread_num=%d, i01=%d, i11=%d, i21=%d\0A\00"
@.str.1 = [61 x i8] c"multi_scope: i01=%d, i02=%d, i11=%d, i12=%d, i21=%d, i22=%d\0A\00"
define void @multi_scope() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = mul i32 %1, 100
%3 = add i32 %2, 121
%4 = tail call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %1, i32 1, i32 11, i32 %3)
%5 = tail call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32 11, i32 12, i32 %3, i32 22)
ret void
}