#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);
scalar_t__ foo();
int main() {
  int accum = 0;
  for (int i = 0; i < 10; ++i)
    accum += foo();
#pragma omp taskwait
  assert(accum == 10);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1169 <main+0x49>
mov    $0x0,%al
call   1040 <foo@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
cmpl   $0xa,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%rbx
add    %r14d,%ebx
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%r14
add    %ebx,%r14d
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%rbx
add    %r14d,%ebx
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%r14
add    %ebx,%r14d
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%rbx
add    %r14d,%ebx
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%r14
add    %ebx,%r14d
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%rbx
add    %r14d,%ebx
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rax,%r14
add    %ebx,%r14d
xor    %eax,%eax
call   1040 <foo@plt>
add    %r14d,%eax
xor    %edi,%edi
cmp    $0xa,%eax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = call i64 (...) @foo()
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %2
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 10
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @foo()
%2 = trunc i64 %1 to i32
%3 = tail call i64 (...) @foo()
%4 = trunc i64 %3 to i32
%5 = add i32 %2, %4
%6 = tail call i64 (...) @foo()
%7 = trunc i64 %6 to i32
%8 = add i32 %5, %7
%9 = tail call i64 (...) @foo()
%10 = trunc i64 %9 to i32
%11 = add i32 %8, %10
%12 = tail call i64 (...) @foo()
%13 = trunc i64 %12 to i32
%14 = add i32 %11, %13
%15 = tail call i64 (...) @foo()
%16 = trunc i64 %15 to i32
%17 = add i32 %14, %16
%18 = tail call i64 (...) @foo()
%19 = trunc i64 %18 to i32
%20 = add i32 %17, %19
%21 = tail call i64 (...) @foo()
%22 = trunc i64 %21 to i32
%23 = add i32 %20, %22
%24 = tail call i64 (...) @foo()
%25 = trunc i64 %24 to i32
%26 = add i32 %23, %25
%27 = tail call i64 (...) @foo()
%28 = trunc i64 %27 to i32
%29 = add i32 %26, %28
%30 = icmp eq i32 %29, 10
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
ret i32 0
}