#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 SET_BITS(uintptr_t addr, uint32_t val) {
  if (!(((uintptr_t)addr) & 0xffffffff00000000)) {
    if (val & ~0xff) {
      addbyte(0x81);
      addbyte(0x0c);
      addbyte(0x25);
      addlong(addr);
      addlong(val);
    } else {
      addbyte(0x80);
      addbyte(0x0c);
      addbyte(0x25);
      addlong(addr);
      addbyte(val);
    }
  } else {
    addbyte(0x48);
    addbyte(0xb8 | 0);
    addquad(addr);
    if (val & ~0xff) {
      addbyte(0x81);
      addbyte(0x08);
      addlong(val);
    } else {
      addbyte(0x80);
      addbyte(0x08);
      addbyte(val);
    }
  }
}


x86 assembly (clang, -O0):
<SET_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    11d4 <SET_BITS+0xa4>
mov    -0xc(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x0,%eax
je     119e <SET_BITS+0x6e>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0xc,%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
call   1030 <addlong@plt>
jmp    11cf <SET_BITS+0x9f>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0xc,%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
call   1040 <addbyte@plt>
jmp    1244 <SET_BITS+0x114>
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     1223 <SET_BITS+0xf3>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x8,%edi
call   1040 <addbyte@plt>
mov    -0xc(%rbp),%edi
call   1030 <addlong@plt>
jmp    123f <SET_BITS+0x10f>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x8,%edi
call   1040 <addbyte@plt>
mov    -0xc(%rbp),%edi
call   1040 <addbyte@plt>
jmp    1244 <SET_BITS+0x114>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SET_BITS>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rdi,%rax
shr    $0x20,%rax
jne    1170 <SET_BITS+0x40>
cmp    $0x100,%ebp
jae    11b5 <SET_BITS+0x85>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0xc,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    %ebx,%edi
call   1030 <addlong@plt>
jmp    11a8 <SET_BITS+0x78>
mov    $0x48,%edi
call   1040 <addbyte@plt>
mov    $0xb8,%edi
call   1040 <addbyte@plt>
mov    %rbx,%rdi
call   1050 <addquad@plt>
cmp    $0x100,%ebp
jae    11dc <SET_BITS+0xac>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    $0x8,%edi
call   1040 <addbyte@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <addbyte@plt>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0xc,%edi
call   1040 <addbyte@plt>
mov    $0x25,%edi
call   1040 <addbyte@plt>
mov    %ebx,%edi
call   1030 <addlong@plt>
jmp    11f0 <SET_BITS+0xc0>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    $0x8,%edi
call   1040 <addbyte@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <addlong@plt>

LLVM IR (-O0):
define void @SET_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 %31, 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 %21
12: ; preds = %8
%13 = call i32 @addbyte(i32 129)
%14 = call i32 @addbyte(i32 12)
%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 = call i32 @addlong(i32 %19)
br label %30
21: ; preds = %8
%22 = call i32 @addbyte(i32 128)
%23 = call i32 @addbyte(i32 12)
%24 = call i32 @addbyte(i32 37)
%25 = load i64, i64* %3
%26 = trunc i64 %25 to i32
%27 = call i32 @addlong(i32 %26)
%28 = load i32, i32* %4
%29 = call i32 @addbyte(i32 %28)
br label %30
30: ; preds = %21, %12
br label %50
31: ; preds = %2
%32 = call i32 @addbyte(i32 72)
%33 = call i32 @addbyte(i32 184)
%34 = load i64, i64* %3
%35 = call i32 @addquad(i64 %34)
%36 = load i32, i32* %4
%37 = and i32 %36, -256
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %31
%40 = call i32 @addbyte(i32 129)
%41 = call i32 @addbyte(i32 8)
%42 = load i32, i32* %4
%43 = call i32 @addlong(i32 %42)
br label %49
44: ; preds = %31
%45 = call i32 @addbyte(i32 128)
%46 = call i32 @addbyte(i32 8)
%47 = load i32, i32* %4
%48 = call i32 @addbyte(i32 %47)
br label %49
49: ; preds = %44, %39
br label %50
50: ; preds = %49, %30
ret void
}

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