#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void decode_bo_case(int bo_case, int context_length, FILE *annotation_fp) {
  int i;
  int current_bo_case;
  for (i = context_length - 1; i >= 0; i--) {
    fprintf(annotation_fp, "%d", i + 2);
    current_bo_case = bo_case / (1 << (2 * i));
    if (current_bo_case == 1) {
      fprintf(annotation_fp, "-");
    } else {
      if (current_bo_case == 2) {
        fprintf(annotation_fp, "x");
      } else {
        i = -2;
      }
    }
    bo_case -= (current_bo_case * (1 << (2 * i)));
  }
  if (i > -2) {
    fprintf(annotation_fp, "1");
  }
  fprintf(annotation_fp, "\n");
}


x86 assembly (clang, -O0):
<decode_bo_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11e2 <decode_bo_case+0xd2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
add    $0x2,%edx
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1186 <decode_bo_case+0x76>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b3 <decode_bo_case+0xa3>
cmpl   $0x2,-0x18(%rbp)
jne    11a7 <decode_bo_case+0x97>
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ae <decode_bo_case+0x9e>
movl   $0xfffffffe,-0x14(%rbp)
jmp    11b3 <decode_bo_case+0xa3>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x1c(%rbp),%ecx
imul   %eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <decode_bo_case+0x1b>
cmpl   $0xfffffffe,-0x14(%rbp)
jle    11fe <decode_bo_case+0xee>
mov    -0x10(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_bo_case>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
test   %esi,%esi
jle    11a3 <decode_bo_case+0x83>
mov    %edi,%r15d
mov    %esi,%r13d
add    $0x1,%r13d
lea    (%rsi,%rsi,1),%ebp
add    $0xfffffffe,%ebp
lea    0xeb7(%rip),%r12
jmp    116c <decode_bo_case+0x4c>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    %ebp,%ecx
shl    %cl,%ebx
sub    %ebx,%r15d
add    $0xffffffff,%r13d
add    $0xfffffffe,%ebp
cmp    $0x1,%r13d
je     11a5 <decode_bo_case+0x85>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%esi
mov    %ebp,%ecx
shl    %cl,%esi
mov    %r15d,%eax
cltd
idiv   %esi
mov    %eax,%ebx
mov    $0x2d,%edi
cmp    $0x1,%eax
je     1150 <decode_bo_case+0x30>
cmp    $0x2,%ebx
jne    11b2 <decode_bo_case+0x92>
mov    $0x78,%edi
jmp    1150 <decode_bo_case+0x30>
js     11b2 <decode_bo_case+0x92>
mov    $0x31,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @decode_bo_case(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %7
br label %11
11: ; preds = %45, %3
%12 = load i32, i32* %7
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %48
14: ; preds = %11
%15 = load i32*, i32** %6
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 2
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = mul nsw i32 2, %20
%22 = shl i32 1, %21
%23 = sdiv i32 %19, %22
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %14
%27 = load i32*, i32** %6
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %37
29: ; preds = %14
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32*, i32** %6
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
35: ; preds = %29
store i32 -2, i32* %7
br label %36
36: ; preds = %35, %32
br label %37
37: ; preds = %36, %26
%38 = load i32, i32* %8
%39 = load i32, i32* %7
%40 = mul nsw i32 2, %39
%41 = shl i32 1, %40
%42 = mul nsw i32 %38, %41
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, %42
store i32 %44, i32* %4
br label %45
45: ; preds = %37
%46 = load i32, i32* %7
%47 = add nsw i32 %46, -1
store i32 %47, i32* %7
br label %11
48: ; preds = %11
%49 = load i32, i32* %7
%50 = icmp sgt i32 %49, -2
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32*, i32** %6
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %51, %48
%55 = load i32*, i32** %6
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @decode_bo_case(i32 %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %22
5: ; preds = %3, %15
%6 = phi i32 [ %20, %15 ], [ %0, %3 ]
%7 = phi i32 [ %8, %15 ], [ %1, %3 ]
%8 = add nsw i32 %7, -1
%9 = add nuw nsw i32 %7, 1
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = shl nuw nsw i32 %8, 1
%12 = shl nuw i32 1, %11
%13 = sdiv i32 %6, %12
switch i32 %13, label %26 [
i32 1, label %15
i32 2, label %14
]
14: ; preds = %5
br label %15
15: ; preds = %5, %14
%16 = phi i32 [ 120, %14 ], [ 45, %5 ]
%17 = tail call i32 @fputc(i32 %16, i32* %2)
%18 = shl nuw nsw i32 %8, 1
%19 = shl i32 %13, %18
%20 = sub nsw i32 %6, %19
%21 = icmp eq i32 %8, 0
br i1 %21, label %24, label %5
22: ; preds = %3
%23 = icmp sgt i32 %1, -1
br i1 %23, label %24, label %26
24: ; preds = %15, %22
%25 = tail call i32 @fputc(i32 49, i32* %2)
br label %26
26: ; preds = %5, %24, %22
%27 = tail call i32 @fputc(i32 10, i32* %2)
ret void
}