#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*/ DoStuff(int);
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int main() {
  DoStuff(0);
  if (errno) {
    perror("ERROR");
  } else {
    DoStuff(1);
    if (errno) {
      perror("ERROR");
    } else {
      DoStuff(1);
      if (errno) {
        perror("ERROR");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <DoStuff@plt>
mov    0x2ea3(%rip),%rax
cmpq   $0x0,(%rax)
je     1158 <main+0x38>
lea    0xeb2(%rip),%rdi
call   1030 <perror@plt>
jmp    11b5 <main+0x95>
mov    $0x1,%edi
call   1040 <DoStuff@plt>
mov    0x2e77(%rip),%rax
cmpq   $0x0,(%rax)
je     1184 <main+0x64>
lea    0xe86(%rip),%rdi
call   1030 <perror@plt>
jmp    11b0 <main+0x90>
mov    $0x1,%edi
call   1040 <DoStuff@plt>
mov    0x2e4b(%rip),%rax
cmpq   $0x0,(%rax)
je     11ab <main+0x8b>
lea    0xe5a(%rip),%rdi
call   1030 <perror@plt>
jmp    11b0 <main+0x90>
jmp    11b5 <main+0x95>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1040 <DoStuff@plt>
mov    0x2eb1(%rip),%rbx
cmpq   $0x0,(%rbx)
jne    1159 <main+0x39>
mov    $0x1,%edi
call   1040 <DoStuff@plt>
cmpq   $0x0,(%rbx)
jne    1159 <main+0x39>
mov    $0x1,%edi
call   1040 <DoStuff@plt>
cmpq   $0x0,(%rbx)
jne    1159 <main+0x39>
xor    %eax,%eax
pop    %rbx
ret
lea    0xea0(%rip),%rdi
call   1030 <perror@plt>
jmp    1155 <main+0x35>

LLVM IR (-O0):
@errno = global i64 0
@.str = [6 x i8] c"ERROR\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @DoStuff(i32 0)
%3 = load i64, i64* @errno
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %21
7: ; preds = %0
%8 = call i32 @DoStuff(i32 1)
%9 = load i64, i64* @errno
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
13: ; preds = %7
%14 = call i32 @DoStuff(i32 1)
%15 = load i64, i64* @errno
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
br label %20
20: ; preds = %19, %11
br label %21
21: ; preds = %20, %5
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [6 x i8] c"ERROR\00"
define i32 @main() {
%1 = tail call i32 @DoStuff(i32 0)
%2 = load i64, i64* @errno
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = tail call i32 @DoStuff(i32 1)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = tail call i32 @DoStuff(i32 1)
%10 = load i64, i64* @errno
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8, %4, %0
%13 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
ret i32 0
}