#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*/ valid_bo(long, int, int /*<<< orphan*/);
unsigned long insert_boe(unsigned long insn, long value, int dialect,
                         const char **errmsg) {
  if (!valid_bo(value, dialect, 0))
    *errmsg = "invalid conditional option";
  else if ((value & 1) != 0)
    *errmsg = "attempt to set y bit when using + or - modifier";
  return insn | ((value & 0x1f) << 21);
}


x86 assembly (clang, -O0):
<insert_boe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <valid_bo@plt>
cmp    $0x0,%eax
jne    1151 <insert_boe+0x41>
mov    -0x20(%rbp),%rax
lea    0xeb7(%rip),%rcx
mov    %rcx,(%rax)
jmp    1176 <insert_boe+0x66>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1171 <insert_boe+0x61>
mov    -0x20(%rbp),%rax
lea    0xead(%rip),%rcx
mov    %rcx,(%rax)
jmp    1176 <insert_boe+0x66>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
and    $0x1f,%rcx
shl    $0x15,%rcx
or     %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_boe>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %edx,%esi
xor    %edx,%edx
call   1030 <valid_bo@plt>
test   %eax,%eax
je     113c <insert_boe+0x2c>
test   $0x1,%bl
je     1146 <insert_boe+0x36>
lea    0xee1(%rip),%rax
jmp    1143 <insert_boe+0x33>
lea    0xebd(%rip),%rax
mov    %rax,(%r15)
and    $0x1f,%ebx
shl    $0x15,%rbx
or     %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"invalid conditional option\00"
@.str.1 = [48 x i8] c"attempt to set y bit when using + or - modifier\00"
define i64 @insert_boe(i64 %0, i64 %1, i32 %2, i8** %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8**
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%9 = load i64, i64* %6
%10 = load i32, i32* %7
%11 = call i32 @valid_bo(i64 %9, i32 %10, i32 0)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %4
%14 = load i8**, i8*** %8
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %14
br label %22
15: ; preds = %4
%16 = load i64, i64* %6
%17 = and i64 %16, 1
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i8**, i8*** %8
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8** %20
br label %21
21: ; preds = %19, %15
br label %22
22: ; preds = %21, %13
%23 = load i64, i64* %5
%24 = load i64, i64* %6
%25 = and i64 %24, 31
%26 = shl i64 %25, 21
%27 = or i64 %23, %26
ret i64 %27
}

LLVM IR (-O2):
@.str = [27 x i8] c"invalid conditional option\00"
@.str.1 = [48 x i8] c"attempt to set y bit when using + or - modifier\00"
define i64 @insert_boe(i64 %0, i64 %1, i32 %2, i8** nocapture writeonly %3) {
%5 = tail call i32 @valid_bo(i64 %1, i32 %2, i32 0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = and i64 %1, 1
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7, %4
%11 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), %7 ]
store i8* %11, i8** %3
br label %12
12: ; preds = %10, %7
%13 = shl i64 %1, 21
%14 = and i64 %13, 65011712
%15 = or i64 %14, %0
ret i64 %15
}