#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_sc(int);
int /*<<< orphan*/ t1_getctxno_zc(int, int);
int t1_getspb(int);
int /*<<< orphan*/ t1_updateflags(int *, int);
void t1_dec_clnpass_step(int *fp, int *dp, int orient, int oneplushalf,
                         int partial) {
  int v;
  if (partial)
    goto label_partial;
  if (!(*fp & (0x1000 | 0x4000))) {
    mqc_setcurctx(t1_getctxno_zc(*fp, orient));
    if (mqc_decode()) {
    label_partial:
      mqc_setcurctx(t1_getctxno_sc(*fp));
      v = mqc_decode() ^ t1_getspb(*fp);
      *dp = v ? -oneplushalf : oneplushalf;
      t1_updateflags(fp, v);
      *fp |= 0x1000;
    }
  }
  *fp &= ~0x4000;
}


x86 assembly (clang, -O0):
<t1_dec_clnpass_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    %r8d,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1189 <t1_dec_clnpass_step+0x29>
jmp    11c7 <t1_dec_clnpass_step+0x67>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x5000,%eax
cmp    $0x0,%eax
jne    123d <t1_dec_clnpass_step+0xdd>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1050 <t1_getctxno_zc@plt>
mov    %eax,%edi
call   1070 <mqc_setcurctx@plt>
mov    $0x0,%al
call   1040 <mqc_decode@plt>
cmp    $0x0,%eax
je     1238 <t1_dec_clnpass_step+0xd8>
jmp    11c7 <t1_dec_clnpass_step+0x67>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <t1_getctxno_sc@plt>
mov    %eax,%edi
call   1070 <mqc_setcurctx@plt>
mov    $0x0,%al
call   1040 <mqc_decode@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1080 <t1_getspb@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     120f <t1_dec_clnpass_step+0xaf>
xor    %eax,%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1215 <t1_dec_clnpass_step+0xb5>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1060 <t1_updateflags@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
or     $0x1000,%ecx
mov    %ecx,(%rax)
jmp    123d <t1_dec_clnpass_step+0xdd>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    $0xffffbfff,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1_dec_clnpass_step>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
test   %r8d,%r8d
je     11b4 <t1_dec_clnpass_step+0x54>
mov    (%rbx),%edi
call   1030 <t1_getctxno_sc@plt>
mov    %eax,%edi
call   1070 <mqc_setcurctx@plt>
xor    %eax,%eax
call   1040 <mqc_decode@plt>
mov    %eax,%ebp
mov    (%rbx),%edi
call   1080 <t1_getspb@plt>
mov    %r15d,%ecx
neg    %ecx
xor    %eax,%ebp
cmove  %r15d,%ecx
mov    %ecx,(%r14)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <t1_updateflags@plt>
mov    $0x1000,%edi
or     (%rbx),%edi
jmp    11be <t1_dec_clnpass_step+0x5e>
mov    (%rbx),%edi
test   $0x5000,%edi
je     11d1 <t1_dec_clnpass_step+0x71>
and    $0xffffbfff,%edi
mov    %edi,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%esi
call   1050 <t1_getctxno_zc@plt>
mov    %eax,%edi
call   1070 <mqc_setcurctx@plt>
xor    %eax,%eax
call   1040 <mqc_decode@plt>
test   %eax,%eax
jne    1175 <t1_dec_clnpass_step+0x15>
mov    (%rbx),%edi
jmp    11be <t1_dec_clnpass_step+0x5e>

LLVM IR (-O0):
define void @t1_dec_clnpass_step(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %10
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %5
br label %29
15: ; preds = %5
%16 = load i32*, i32** %6
%17 = load i32, i32* %16
%18 = and i32 %17, 20480
%19 = icmp ne i32 %18, 0
br i1 %19, label %56, label %20
20: ; preds = %15
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = load i32, i32* %8
%24 = call i32 @t1_getctxno_zc(i32 %22, i32 %23)
%25 = call i32 @mqc_setcurctx(i32 %24)
%26 = call i32 (...) @mqc_decode()
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %55
28: ; preds = %20
br label %29
29: ; preds = %28, %14
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = call i32 @t1_getctxno_sc(i32 %31)
%33 = call i32 @mqc_setcurctx(i32 %32)
%34 = call i32 (...) @mqc_decode()
%35 = load i32*, i32** %6
%36 = load i32, i32* %35
%37 = call i32 @t1_getspb(i32 %36)
%38 = xor i32 %34, %37
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = load i32, i32* %9
%43 = sub nsw i32 0, %42
br label %46
44: ; preds = %29
%45 = load i32, i32* %9
br label %46
46: ; preds = %44, %41
%47 = phi i32 [ %43, %41 ], [ %45, %44 ]
%48 = load i32*, i32** %7
store i32 %47, i32* %48
%49 = load i32*, i32** %6
%50 = load i32, i32* %11
%51 = call i32 @t1_updateflags(i32* %49, i32 %50)
%52 = load i32*, i32** %6
%53 = load i32, i32* %52
%54 = or i32 %53, 4096
store i32 %54, i32* %52
br label %55
55: ; preds = %46, %20
br label %56
56: ; preds = %55, %15
%57 = load i32*, i32** %6
%58 = load i32, i32* %57
%59 = and i32 %58, -16385
store i32 %59, i32* %57
ret void
}

LLVM IR (-O2):
define void @t1_dec_clnpass_step(i32* %0, i32* nocapture writeonly %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %18
7: ; preds = %5
%8 = load i32, i32* %0
%9 = and i32 %8, 20480
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = tail call i32 @t1_getctxno_zc(i32 %8, i32 %2)
%13 = tail call i32 @mqc_setcurctx(i32 %12)
%14 = tail call i32 (...) @mqc_decode()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = load i32, i32* %0
br label %32
18: ; preds = %11, %5
%19 = load i32, i32* %0
%20 = tail call i32 @t1_getctxno_sc(i32 %19)
%21 = tail call i32 @mqc_setcurctx(i32 %20)
%22 = tail call i32 (...) @mqc_decode()
%23 = load i32, i32* %0
%24 = tail call i32 @t1_getspb(i32 %23)
%25 = xor i32 %24, %22
%26 = icmp eq i32 %25, 0
%27 = sub nsw i32 0, %3
%28 = select i1 %26, i32 %3, i32 %27
store i32 %28, i32* %1
%29 = tail call i32 @t1_updateflags(i32* %0, i32 %25)
%30 = load i32, i32* %0
%31 = or i32 %30, 4096
br label %32
32: ; preds = %16, %18, %7
%33 = phi i32 [ %17, %16 ], [ %31, %18 ], [ %8, %7 ]
%34 = and i32 %33, -16385
store i32 %34, i32* %0
ret void
}