#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ addbyte(int);
int /*<<< orphan*/ addlong(int);
int /*<<< orphan*/ addquad(uintptr_t);
void CLEAR_BITS(uintptr_t addr, uint32_t val) {
  if (!(((uintptr_t)addr) & 0xffffffff00000000)) {
    if (val & ~0xff) {
      addbyte(0x81);
      addbyte(0x24);
      addbyte(0x25);
      addlong(addr);
      addlong(~val);
    } else {
      addbyte(0x80);
      addbyte(0x24);
      addbyte(0x25);
      addlong(addr);
      addbyte(~val);
    }
  } else {
    addbyte(0x48);
    addbyte(0xb8 | 0);
    addquad(addr);
    if (val & ~0xff) {
      addbyte(0x81);
      addbyte(0x20);
      addlong(~val);
    } else {
      addbyte(0x80);
      addbyte(0x20);
      addbyte(~val);
    }
  }
}


x86 assembly (clang, -O0):
<CLEAR_BITS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movabs $0xffffffff00000000,%rax
ff ff ff
and    -0x8(%rbp),%rax
cmp    $0x0,%rax
jne    11da <CLEAR_BITS+0xaa>
mov    -0xc(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x0,%eax
je     11a1 <CLEAR_BITS+0x71>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x24,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1030 <addlong@plt>
mov    -0xc(%rbp),%edi
xor    $0xffffffff,%edi
call   1030 <addlong@plt>
jmp    11d5 <CLEAR_BITS+0xa5>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x24,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1030 <addlong@plt>
mov    -0xc(%rbp),%edi
xor    $0xffffffff,%edi
call   1040 <addbyte@plt>
jmp    1250 <CLEAR_BITS+0x120>
mov    $0x48,%edi
call   1040 <addbyte@plt>
mov    $0xb8,%edi
call   1040 <addbyte@plt>
mov    -0x8(%rbp),%rdi
call   1050 <addquad@plt>
mov    -0xc(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x0,%eax
je     122c <CLEAR_BITS+0xfc>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x20,%edi
call   1040 <addbyte@plt>
mov    -0xc(%rbp),%edi
xor    $0xffffffff,%edi
call   1030 <addlong@plt>
jmp    124b <CLEAR_BITS+0x11b>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x20,%edi
call   1040 <addbyte@plt>
mov    -0xc(%rbp),%edi
xor    $0xffffffff,%edi
call   1040 <addbyte@plt>
jmp    1250 <CLEAR_BITS+0x120>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CLEAR_BITS>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rdi,%rax
shr    $0x20,%rax
jne    1172 <CLEAR_BITS+0x42>
cmp    $0x100,%ebx
jae    11ba <CLEAR_BITS+0x8a>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x24,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    %r14d,%edi
call   1030 <addlong@plt>
jmp    11aa <CLEAR_BITS+0x7a>
mov    $0x48,%edi
call   1040 <addbyte@plt>
mov    $0xb8,%edi
call   1040 <addbyte@plt>
mov    %r14,%rdi
call   1050 <addquad@plt>
cmp    $0x100,%ebx
jae    11e2 <CLEAR_BITS+0xb2>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x20,%edi
call   1040 <addbyte@plt>
not    %ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <addbyte@plt>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x24,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    %r14d,%edi
call   1030 <addlong@plt>
jmp    11f6 <CLEAR_BITS+0xc6>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x20,%edi
call   1040 <addbyte@plt>
not    %ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <addlong@plt>

LLVM IR (-O0):
define void @CLEAR_BITS(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
%5 = load i64, i64* %3
%6 = and i64 %5, -4294967296
%7 = icmp ne i64 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = and i32 %9, -256
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = call i32 @addbyte(i32 129)
%14 = call i32 @addbyte(i32 36)
%15 = call i32 @addbyte(i32 37)
%16 = load i64, i64* %3
%17 = trunc i64 %16 to i32
%18 = call i32 @addlong(i32 %17)
%19 = load i32, i32* %4
%20 = xor i32 %19, -1
%21 = call i32 @addlong(i32 %20)
br label %32
22: ; preds = %8
%23 = call i32 @addbyte(i32 128)
%24 = call i32 @addbyte(i32 36)
%25 = call i32 @addbyte(i32 37)
%26 = load i64, i64* %3
%27 = trunc i64 %26 to i32
%28 = call i32 @addlong(i32 %27)
%29 = load i32, i32* %4
%30 = xor i32 %29, -1
%31 = call i32 @addbyte(i32 %30)
br label %32
32: ; preds = %22, %12
br label %54
33: ; preds = %2
%34 = call i32 @addbyte(i32 72)
%35 = call i32 @addbyte(i32 184)
%36 = load i64, i64* %3
%37 = call i32 @addquad(i64 %36)
%38 = load i32, i32* %4
%39 = and i32 %38, -256
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %33
%42 = call i32 @addbyte(i32 129)
%43 = call i32 @addbyte(i32 32)
%44 = load i32, i32* %4
%45 = xor i32 %44, -1
%46 = call i32 @addlong(i32 %45)
br label %53
47: ; preds = %33
%48 = call i32 @addbyte(i32 128)
%49 = call i32 @addbyte(i32 32)
%50 = load i32, i32* %4
%51 = xor i32 %50, -1
%52 = call i32 @addbyte(i32 %51)
br label %53
53: ; preds = %47, %41
br label %54
54: ; preds = %53, %32
ret void
}

LLVM IR (-O2):
define void @CLEAR_BITS(i64 %0, i32 %1) {
%3 = icmp ult i64 %0, 4294967296
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = icmp ult i32 %1, 256
br i1 %5, label %14, label %6
6: ; preds = %4
%7 = tail call i32 @addbyte(i32 129)
%8 = tail call i32 @addbyte(i32 36)
%9 = tail call i32 @addbyte(i32 37)
%10 = trunc i64 %0 to i32
%11 = tail call i32 @addlong(i32 %10)
%12 = xor i32 %1, -1
%13 = tail call i32 @addlong(i32 %12)
br label %37
14: ; preds = %4
%15 = tail call i32 @addbyte(i32 128)
%16 = tail call i32 @addbyte(i32 36)
%17 = tail call i32 @addbyte(i32 37)
%18 = trunc i64 %0 to i32
%19 = tail call i32 @addlong(i32 %18)
%20 = xor i32 %1, -1
%21 = tail call i32 @addbyte(i32 %20)
br label %37
22: ; preds = %2
%23 = tail call i32 @addbyte(i32 72)
%24 = tail call i32 @addbyte(i32 184)
%25 = tail call i32 @addquad(i64 %0)
%26 = icmp ult i32 %1, 256
br i1 %26, label %32, label %27
27: ; preds = %22
%28 = tail call i32 @addbyte(i32 129)
%29 = tail call i32 @addbyte(i32 32)
%30 = xor i32 %1, -1
%31 = tail call i32 @addlong(i32 %30)
br label %37
32: ; preds = %22
%33 = tail call i32 @addbyte(i32 128)
%34 = tail call i32 @addbyte(i32 32)
%35 = xor i32 %1, -1
%36 = tail call i32 @addbyte(i32 %35)
br label %37
37: ; preds = %27, %32, %6, %14
ret void
}