#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 EDOM;
int ERANGE;
int /*<<< orphan*/ abort();
int errno;
void check_large_neg(int flags) {
  if (flags & 0x01)
    return;
  int expected_errno = (flags & 0x02 ? ERANGE : flags & 0x08 ? EDOM : 0);
  if (expected_errno != errno)
    abort();
  errno = 0;
}


x86 assembly (clang, -O0):
<check_large_neg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     112f <check_large_neg+0x1f>
jmp    11ab <check_large_neg+0x9b>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     114f <check_large_neg+0x3f>
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    117f <check_large_neg+0x6f>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     116f <check_large_neg+0x5f>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <check_large_neg+0x69>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <check_large_neg+0x69>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e41(%rip),%rcx
cmp    (%rcx),%eax
je     119e <check_large_neg+0x8e>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2e2b(%rip),%rax
movl   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_large_neg>:
push   %rax
test   $0x1,%dil
jne    1148 <check_large_neg+0x38>
test   $0x2,%dil
jne    112e <check_large_neg+0x1e>
shl    $0x1c,%edi
sar    $0x1f,%edi
mov    0x2ebe(%rip),%rax
and    (%rax),%edi
jmp    1137 <check_large_neg+0x27>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    0x2e92(%rip),%rax
cmp    (%rax),%edi
jne    114a <check_large_neg+0x3a>
movl   $0x0,(%rax)
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@ERANGE = global i32 0
@EDOM = global i32 0
@errno = global i32 0
define void @check_large_neg(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %31
8: ; preds = %1
%9 = load i32, i32* %2
%10 = and i32 %9, 2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i32, i32* @ERANGE
br label %23
14: ; preds = %8
%15 = load i32, i32* %2
%16 = and i32 %15, 8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* @EDOM
br label %21
20: ; preds = %14
br label %21
21: ; preds = %20, %18
%22 = phi i32 [ %19, %18 ], [ 0, %20 ]
br label %23
23: ; preds = %21, %12
%24 = phi i32 [ %13, %12 ], [ %22, %21 ]
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = load i32, i32* @errno
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %23
store i32 0, i32* @errno
br label %31
31: ; preds = %30, %7
ret void
}

LLVM IR (-O2):
@ERANGE = global i32 0
@EDOM = global i32 0
@errno = global i32 0
define void @check_large_neg(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %1
%5 = and i32 %0, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = load i32, i32* @ERANGE
br label %14
9: ; preds = %4
%10 = and i32 %0, 8
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* @EDOM
%13 = select i1 %11, i32 0, i32 %12
br label %14
14: ; preds = %9, %7
%15 = phi i32 [ %8, %7 ], [ %13, %9 ]
%16 = load i32, i32* @errno
%17 = icmp eq i32 %15, %16
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 (...) @abort()
unreachable
20: ; preds = %14
store i32 0, i32* @errno
br label %21
21: ; preds = %1, %20
ret void
}