#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ write_bit(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ write_bits(int, int, int /*<<< orphan*/ *);
void a7_write_mask_index(FILE *out, int delta, int new_id) {
  if (delta < 0) {
    write_bit(1, out);
    write_bits(20, new_id, out);
  } else if (delta < 8) {
    write_bit(0, out);
    write_bits(3, delta, out);
  } else {
    write_bit(1, out);
    write_bits(20, new_id, out);
  }
}


x86 assembly (clang, -O0):
<a7_write_mask_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1160 <a7_write_mask_index+0x40>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1040 <write_bit@plt>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    $0x14,%edi
call   1030 <write_bits@plt>
jmp    11af <a7_write_mask_index+0x8f>
cmpl   $0x8,-0xc(%rbp)
jge    118b <a7_write_mask_index+0x6b>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1040 <write_bit@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    $0x3,%edi
call   1030 <write_bits@plt>
jmp    11aa <a7_write_mask_index+0x8a>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1040 <write_bit@plt>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    $0x14,%edi
call   1030 <write_bits@plt>
jmp    11af <a7_write_mask_index+0x8f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a7_write_mask_index>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rdi,%rbx
test   %esi,%esi
js     1148 <a7_write_mask_index+0x28>
mov    %esi,%ebp
cmp    $0x7,%esi
ja     1148 <a7_write_mask_index+0x28>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <write_bit@plt>
mov    $0x3,%edi
mov    %ebp,%esi
jmp    115d <a7_write_mask_index+0x3d>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <write_bit@plt>
mov    $0x14,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <write_bits@plt>

LLVM IR (-O0):
define void @a7_write_mask_index(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 %15
9: ; preds = %3
%10 = load i32*, i32** %4
%11 = call i32 @write_bit(i32 1, i32* %10)
%12 = load i32, i32* %6
%13 = load i32*, i32** %4
%14 = call i32 @write_bits(i32 20, i32 %12, i32* %13)
br label %31
15: ; preds = %3
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 8
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32*, i32** %4
%20 = call i32 @write_bit(i32 0, i32* %19)
%21 = load i32, i32* %5
%22 = load i32*, i32** %4
%23 = call i32 @write_bits(i32 3, i32 %21, i32* %22)
br label %30
24: ; preds = %15
%25 = load i32*, i32** %4
%26 = call i32 @write_bit(i32 1, i32* %25)
%27 = load i32, i32* %6
%28 = load i32*, i32** %4
%29 = call i32 @write_bits(i32 20, i32 %27, i32* %28)
br label %30
30: ; preds = %24, %18
br label %31
31: ; preds = %30, %9
ret void
}

LLVM IR (-O2):
define void @a7_write_mask_index(i32* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @write_bit(i32 1, i32* %0)
%7 = tail call i32 @write_bits(i32 20, i32 %2, i32* %0)
br label %16
8: ; preds = %3
%9 = icmp ult i32 %1, 8
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i32 @write_bit(i32 0, i32* %0)
%12 = tail call i32 @write_bits(i32 3, i32 %1, i32* %0)
br label %16
13: ; preds = %8
%14 = tail call i32 @write_bit(i32 1, i32* %0)
%15 = tail call i32 @write_bits(i32 20, i32 %2, i32* %0)
br label %16
16: ; preds = %10, %13, %5
ret void
}