#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*/ assert(int);
int /*<<< orphan*/ emit_u(unsigned int);
void emit_arith_imm(unsigned opcode, unsigned flg, unsigned c10, unsigned rb,
                    unsigned rd, unsigned cond) {
  assert((opcode & ~0x7U) == 0);
  assert((flg & ~0x1U) == 0);
  assert((c10 & ~0x3FF) == 0);
  emit_u((opcode << 28) | (flg << 27) | (c10 << 16) | (rb << 8) | (rd << 4) |
         cond);
}


x86 assembly (clang, -O0):
<emit_arith_imm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffff8,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
and    $0xfffffc00,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%edi
shl    $0x1c,%edi
mov    -0x8(%rbp),%eax
shl    $0x1b,%eax
or     %eax,%edi
mov    -0xc(%rbp),%eax
shl    $0x10,%eax
or     %eax,%edi
mov    -0x10(%rbp),%eax
shl    $0x8,%eax
or     %eax,%edi
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
or     %eax,%edi
or     -0x18(%rbp),%edi
call   1040 <emit_u@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_arith_imm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %esi,%ebx
mov    %edi,%r13d
xor    %edi,%edi
cmp    $0x8,%r13d
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x2,%ebx
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x400,%r12d
setb   %dil
call   1030 <assert@plt>
shl    $0x1c,%r13d
shl    $0x1b,%ebx
or     %r13d,%ebx
shl    $0x10,%r12d
shl    $0x8,%ebp
or     %r12d,%ebp
or     %ebx,%ebp
shl    $0x4,%r15d
or     %r14d,%r15d
or     %ebp,%r15d
mov    %r15d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <emit_u@plt>

LLVM IR (-O0):
define void @emit_arith_imm(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %7
%14 = and i32 %13, -8
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %8
%19 = and i32 %18, -2
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %9
%24 = and i32 %23, -1024
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %7
%29 = shl i32 %28, 28
%30 = load i32, i32* %8
%31 = shl i32 %30, 27
%32 = or i32 %29, %31
%33 = load i32, i32* %9
%34 = shl i32 %33, 16
%35 = or i32 %32, %34
%36 = load i32, i32* %10
%37 = shl i32 %36, 8
%38 = or i32 %35, %37
%39 = load i32, i32* %11
%40 = shl i32 %39, 4
%41 = or i32 %38, %40
%42 = load i32, i32* %12
%43 = or i32 %41, %42
%44 = call i32 @emit_u(i32 %43)
ret void
}

LLVM IR (-O2):
define void @emit_arith_imm(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp ult i32 %0, 8
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ult i32 %1, 2
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp ult i32 %2, 1024
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = shl i32 %0, 28
%17 = shl i32 %1, 27
%18 = or i32 %17, %16
%19 = shl i32 %2, 16
%20 = or i32 %18, %19
%21 = shl i32 %3, 8
%22 = or i32 %20, %21
%23 = shl i32 %4, 4
%24 = or i32 %22, %23
%25 = or i32 %24, %5
%26 = tail call i32 @emit_u(i32 %25)
ret void
}