#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*/ abort();
int bar();
int foo();
int main() {
  int r;
#pragma omp target map(from : r)
  {
    r = (foo() == 1) + (bar() == 1);
    r += (foo() == 2) + (bar() == 2);
  }
  if (r != 4)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <bar@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    $0x1,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <bar@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    $0x2,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11b7 <main+0x87>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <foo@plt>
xor    %r14d,%r14d
cmp    $0x1,%eax
sete   %r14b
xor    %eax,%eax
call   1040 <bar@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
xor    %eax,%eax
call   1050 <foo@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
sete   %bl
xor    %eax,%eax
call   1040 <bar@plt>
xor    %ecx,%ecx
cmp    $0x2,%eax
sete   %cl
add    %r14d,%ebp
add    %ebx,%ebp
add    %ecx,%ebp
cmp    $0x4,%ebp
jne    1186 <main+0x56>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @foo()
%2 = icmp eq i32 %1, 1
%3 = zext i1 %2 to i32
%4 = tail call i32 (...) @bar()
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 (...) @foo()
%8 = icmp eq i32 %7, 2
%9 = zext i1 %8 to i32
%10 = tail call i32 (...) @bar()
%11 = icmp eq i32 %10, 2
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %6, %3
%14 = add nuw nsw i32 %13, %9
%15 = add nuw nsw i32 %14, %12
%16 = icmp eq i32 %15, 4
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = tail call i32 (...) @abort()
unreachable
19: ; preds = %0
ret i32 0
}