#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*/ assert(int);
int /*<<< orphan*/ consumer(int);
int /*<<< orphan*/ producer(int *);
int main() {
  int x = -1;
  int v[5] = {0, 1, 2, 3, 4};
  producer(&x);
  for (int i = 0; i < 1000; ++i) {
    for (int j = 0; j < 1000; ++j) {
    }
  }
  consumer(v[x] + x);
#pragma omp taskwait
  assert(x == 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <producer@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
jge    11bc <main+0x8c>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3e8,-0x28(%rbp)
jge    11a9 <main+0x79>
jmp    119b <main+0x6b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1189 <main+0x59>
jmp    11ae <main+0x7e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <main+0x45>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
add    -0x8(%rbp),%edi
call   1050 <consumer@plt>
cmpl   $0x1,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x4(%rsp),%rdi
call   1030 <producer@plt>
movslq 0x4(%rsp),%rax
lea    0xeb1(%rip),%rcx
mov    (%rcx,%rax,4),%edi
add    %eax,%edi
call   1050 <consumer@plt>
xor    %edi,%edi
cmpl   $0x1,0x4(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.v = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%6 = bitcast [5 x i32]* %3 to i8*
%7 = call i32 @producer(i32* %2)
store i32 0, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %23
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %16, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 1000
br i1 %14, label %15, label %19
15: ; preds = %12
br label %16
16: ; preds = %15
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %12
19: ; preds = %12
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %2
%29 = add nsw i32 %27, %28
%30 = call i32 @consumer(i32 %29)
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 1
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@__const.main.v = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = call i32 @producer(i32* %1)
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.v, i64 0, i64 %5
%7 = load i32, i32* %6
%8 = add nsw i32 %7, %4
%9 = call i32 @consumer(i32 %8)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
ret i32 0
}