#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_andimm(int, int, int);
int /*<<< orphan*/ emit_movzbl_dualindexedx4(int, int, int);
int /*<<< orphan*/ emit_writebyte_dualindexedx4(int, int, int);
void emit_rmw_andimm(int addr, int map, int imm) {
  if (map < 0) {
    assert(map >= 0);
  } else {
    emit_movzbl_dualindexedx4(addr, map, 14);
    emit_andimm(14, imm, 14);
    emit_writebyte_dualindexedx4(14, addr, map);
  }
}


x86 assembly (clang, -O0):
<emit_rmw_andimm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1171 <emit_rmw_andimm+0x31>
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
jmp    11a0 <emit_rmw_andimm+0x60>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0xe,%edx
call   1030 <emit_movzbl_dualindexedx4@plt>
mov    -0xc(%rbp),%esi
mov    $0xe,%edx
mov    %edx,%edi
call   1060 <emit_andimm@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0xe,%edi
call   1050 <emit_writebyte_dualindexedx4@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_rmw_andimm>:
test   %esi,%esi
js     117d <emit_rmw_andimm+0x3d>
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0xe,%edx
call   1030 <emit_movzbl_dualindexedx4@plt>
mov    $0xe,%edi
mov    %r14d,%esi
mov    $0xe,%edx
call   1060 <emit_andimm@plt>
mov    $0xe,%edi
mov    %ebp,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <emit_writebyte_dualindexedx4@plt>
xor    %edi,%edi
jmp    1040 <assert@plt>

LLVM IR (-O0):
define void @emit_rmw_andimm(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* %5
%11 = icmp sge i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
br label %23
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 @emit_movzbl_dualindexedx4(i32 %15, i32 %16, i32 14)
%18 = load i32, i32* %6
%19 = call i32 @emit_andimm(i32 14, i32 %18, i32 14)
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @emit_writebyte_dualindexedx4(i32 14, i32 %20, i32 %21)
br label %23
23: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
define void @emit_rmw_andimm(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @assert(i32 0)
br label %11
7: ; preds = %3
%8 = tail call i32 @emit_movzbl_dualindexedx4(i32 %0, i32 %1, i32 14)
%9 = tail call i32 @emit_andimm(i32 14, i32 %2, i32 14)
%10 = tail call i32 @emit_writebyte_dualindexedx4(i32 14, i32 %0, i32 %1)
br label %11
11: ; preds = %7, %5
ret void
}