#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 /*<<< orphan*/ pd002s(int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int i, n, errors;
  int a, b;
  n = 1024;
  a = 0;
  b = n;
  pd002s(n, &a, &b);
  errors = 0;
  if (a != n) {
    errors += 1;
    printf("parallel for 002 - EXPECTED A = %d OBSERVED %d\n", n, a);
  }
  if (b != 0) {
    errors += 1;
    printf("parallel for 002 - EXPECTED B = %d OBSERVED %d\n", 0, b);
  }
  if (errors == 0)
    printf("parallel for 002 PASSED\n");
  else
    printf("parallel for 002 FAILED\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x400,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <pd002s@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1183 <main+0x63>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     11a9 <main+0x89>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%edx
lea    0xe90(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11c6 <main+0xa6>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x400,(%rsp)
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
mov    $0x400,%edi
call   1050 <pd002s@plt>
mov    0x4(%rsp),%edx
cmp    $0x400,%edx
jne    116e <main+0x3e>
mov    (%rsp),%edx
test   %edx,%edx
jne    1188 <main+0x58>
lea    0xf0c(%rip),%rdi
jmp    119f <main+0x6f>
lea    0xe8b(%rip),%rdi
mov    $0x400,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%edx
test   %edx,%edx
je     1198 <main+0x68>
lea    0xea1(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [48 x i8] c"parallel for 002 - EXPECTED A = %d OBSERVED %d\0A\00"
@.str.1 = [48 x i8] c"parallel for 002 - EXPECTED B = %d OBSERVED %d\0A\00"
@.str.2 = [25 x i8] c"parallel for 002 PASSED\0A\00"
@.str.3 = [25 x i8] c"parallel for 002 FAILED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1024, i32* %3
store i32 0, i32* %5
%7 = load i32, i32* %3
store i32 %7, i32* %6
%8 = load i32, i32* %3
%9 = call i32 @pd002s(i32 %8, i32* %5, i32* %6)
store i32 0, i32* %4
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %13, %0
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %25)
br label %27
27: ; preds = %22, %19
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [48 x i8] c"parallel for 002 - EXPECTED A = %d OBSERVED %d\0A\00"
@.str.1 = [48 x i8] c"parallel for 002 - EXPECTED B = %d OBSERVED %d\0A\00"
@str = [24 x i8] c"parallel for 002 FAILED\00"
@str.4 = [24 x i8] c"parallel for 002 PASSED\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %1
store i32 1024, i32* %2
%5 = call i32 @pd002s(i32 1024, i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 1024
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %18, label %15
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 1024, i32 %6)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11, %8
%16 = phi i32 [ %13, %11 ], [ %9, %8 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %16)
br label %18
18: ; preds = %15, %11, %8
%19 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0), %15 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}