#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 mqc_decode();
int /*<<< orphan*/ mqc_setcurctx(int /*<<< orphan*/);
int /*<<< orphan*/ t1_getctxno_mag(int);
void t1_dec_refpass_step(int *fp, int *dp, int poshalf, int neghalf) {
  int v, t;
  if ((*fp & (0x1000 | 0x4000)) == 0x1000) {
    mqc_setcurctx(t1_getctxno_mag(*fp));
    v = mqc_decode();
    t = v ? poshalf : neghalf;
    *dp += *dp < 0 ? -t : t;
    *fp |= 0x2000;
  }
}


x86 assembly (clang, -O0):
<t1_dec_refpass_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x5000,%eax
cmp    $0x1000,%eax
jne    11d2 <t1_dec_refpass_step+0xa2>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <t1_getctxno_mag@plt>
mov    %eax,%edi
call   1050 <mqc_setcurctx@plt>
mov    $0x0,%al
call   1040 <mqc_decode@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118d <t1_dec_refpass_step+0x5d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1193 <t1_dec_refpass_step+0x63>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    11b3 <t1_dec_refpass_step+0x83>
xor    %eax,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11b9 <t1_dec_refpass_step+0x89>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
or     $0x2000,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1_dec_refpass_step>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%edi
mov    %edi,%eax
and    $0x5000,%eax
cmp    $0x1000,%eax
jne    1180 <t1_dec_refpass_step+0x50>
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r14
call   1030 <t1_getctxno_mag@plt>
mov    %eax,%edi
call   1050 <mqc_setcurctx@plt>
xor    %eax,%eax
call   1040 <mqc_decode@plt>
test   %eax,%eax
cmove  %r15d,%ebp
mov    (%r14),%eax
mov    %ebp,%ecx
neg    %ecx
test   %eax,%eax
cmovns %ebp,%ecx
add    %eax,%ecx
mov    %ecx,(%r14)
orb    $0x20,0x1(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @t1_dec_refpass_step(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = and i32 %12, 20480
%14 = icmp eq i32 %13, 4096
br i1 %14, label %15, label %45
15: ; preds = %4
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = call i32 @t1_getctxno_mag(i32 %17)
%19 = call i32 @mqc_setcurctx(i32 %18)
%20 = call i32 (...) @mqc_decode()
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = load i32, i32* %7
br label %27
25: ; preds = %15
%26 = load i32, i32* %8
br label %27
27: ; preds = %25, %23
%28 = phi i32 [ %24, %23 ], [ %26, %25 ]
store i32 %28, i32* %10
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %10
%34 = sub nsw i32 0, %33
br label %37
35: ; preds = %27
%36 = load i32, i32* %10
br label %37
37: ; preds = %35, %32
%38 = phi i32 [ %34, %32 ], [ %36, %35 ]
%39 = load i32*, i32** %6
%40 = load i32, i32* %39
%41 = add nsw i32 %40, %38
store i32 %41, i32* %39
%42 = load i32*, i32** %5
%43 = load i32, i32* %42
%44 = or i32 %43, 8192
store i32 %44, i32* %42
br label %45
45: ; preds = %37, %4
ret void
}

LLVM IR (-O2):
define void @t1_dec_refpass_step(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* %0
%6 = and i32 %5, 20480
%7 = icmp eq i32 %6, 4096
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = tail call i32 @t1_getctxno_mag(i32 %5)
%10 = tail call i32 @mqc_setcurctx(i32 %9)
%11 = tail call i32 (...) @mqc_decode()
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 %3, i32 %2
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 0
%16 = sub nsw i32 0, %13
%17 = select i1 %15, i32 %16, i32 %13
%18 = add nsw i32 %17, %14
store i32 %18, i32* %1
%19 = load i32, i32* %0
%20 = or i32 %19, 8192
store i32 %20, i32* %0
br label %21
21: ; preds = %8, %4
ret void
}