#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 test_logical_foo1();
int test_logical_foo2();
int test_logical_foo3();
int test_logical_bar() {
  int x = 0;
  (x = test_logical_foo1()) || (x = test_logical_foo2()) ||
      (x = test_logical_foo3());
  x || test_logical_foo1();
  return x;
}


x86 assembly (clang, -O0):
<test_logical_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <test_logical_foo1@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x5(%rbp)
jne    1186 <test_logical_bar+0x56>
mov    $0x0,%al
call   1050 <test_logical_foo2@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x5(%rbp)
jne    1186 <test_logical_bar+0x56>
mov    $0x0,%al
call   1040 <test_logical_foo3@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x6(%rbp)
jne    11a8 <test_logical_bar+0x78>
mov    $0x0,%al
call   1030 <test_logical_foo1@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_logical_bar>:
push   %rax
xor    %eax,%eax
call   1030 <test_logical_foo1@plt>
test   %eax,%eax
je     113e <test_logical_bar+0xe>
pop    %rcx
ret
xor    %eax,%eax
call   1050 <test_logical_foo2@plt>
test   %eax,%eax
jne    113c <test_logical_bar+0xc>
xor    %eax,%eax
call   1040 <test_logical_foo3@plt>
test   %eax,%eax
jne    113c <test_logical_bar+0xc>
xor    %eax,%eax
call   1030 <test_logical_foo1@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @test_logical_bar() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @test_logical_foo1()
store i32 %2, i32* %1
%3 = icmp ne i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = call i32 (...) @test_logical_foo2()
store i32 %5, i32* %1
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = call i32 (...) @test_logical_foo3()
store i32 %8, i32* %1
%9 = icmp ne i32 %8, 0
br label %10
10: ; preds = %7, %4, %0
%11 = phi i1 [ true, %4 ], [ true, %0 ], [ %9, %7 ]
%12 = zext i1 %11 to i32
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = call i32 (...) @test_logical_foo1()
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %15, %10
%19 = phi i1 [ true, %10 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
define i32 @test_logical_bar() {
%1 = tail call i32 (...) @test_logical_foo1()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %11
3: ; preds = %0
%4 = tail call i32 (...) @test_logical_foo2()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 (...) @test_logical_foo3()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @test_logical_foo1()
br label %11
11: ; preds = %3, %0, %9, %6
%12 = phi i32 [ 0, %9 ], [ %7, %6 ], [ %4, %3 ], [ %1, %0 ]
ret i32 %12
}