#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_pos(int flags) {
  int expected_errno = (flags & 0x04 ? ERANGE : flags & 0x10 ? EDOM : 0);
  if (expected_errno != errno)
    abort();
  errno = 0;
}


x86 assembly (clang, -O0):
<check_large_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     113b <check_large_pos+0x2b>
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    116b <check_large_pos+0x5b>
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     115b <check_large_pos+0x4b>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1165 <check_large_pos+0x55>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    1165 <check_large_pos+0x55>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
je     118a <check_large_pos+0x7a>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2e3f(%rip),%rax
movl   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_large_pos>:
push   %rax
test   $0x4,%dil
jne    1128 <check_large_pos+0x18>
shl    $0x1b,%edi
sar    $0x1f,%edi
mov    0x2ec4(%rip),%rax
and    (%rax),%edi
jmp    1131 <check_large_pos+0x21>
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    0x2e98(%rip),%rax
cmp    (%rax),%edi
jne    1144 <check_large_pos+0x34>
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_pos(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @ERANGE
br label %18
9: ; preds = %1
%10 = load i32, i32* %2
%11 = and i32 %10, 16
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @EDOM
br label %16
15: ; preds = %9
br label %16
16: ; preds = %15, %13
%17 = phi i32 [ %14, %13 ], [ 0, %15 ]
br label %18
18: ; preds = %16, %7
%19 = phi i32 [ %8, %7 ], [ %17, %16 ]
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = load i32, i32* @errno
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (...) @abort()
unreachable
25: ; preds = %18
store i32 0, i32* @errno
ret void
}

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