#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 int_abs(int);
int /*<<< orphan*/ mqc_encode(int);
int /*<<< orphan*/ mqc_setcurctx(int /*<<< orphan*/);
int /*<<< orphan*/ t1_getctxno_sc(int);
int /*<<< orphan*/ t1_getctxno_zc(int, int);
scalar_t__ t1_getnmsedec_sig(int, int);
int t1_getspb(int);
int /*<<< orphan*/ t1_updateflags(int *, int);
void t1_enc_sigpass_step(int *fp, int *dp, int orient, int bpno, int one,
                         int *nmsedec) {
  int v;
  if ((*fp & (0x0010 | 0x0001 | 0x0020 | 0x0002 | 0x0040 | 0x0004 | 0x0080 |
              0x0008)) &&
      !(*fp & (0x1000 | 0x4000))) {
    mqc_setcurctx(t1_getctxno_zc(*fp, orient));
    v = int_abs(*dp) & one ? 1 : 0;
    mqc_encode(v);
    if (v) {
      *nmsedec += t1_getnmsedec_sig(int_abs(*dp), bpno + (7 - 1));
      mqc_setcurctx(t1_getctxno_sc(*fp));
      v = *dp < 0 ? 1 : 0;
      mqc_encode(v ^ t1_getspb(*fp));
      t1_updateflags(fp, v);
      *fp |= 0x1000;
    }
    *fp |= 0x4000;
  }
}


x86 assembly (clang, -O0):
<t1_enc_sigpass_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)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0xff,%eax
cmp    $0x0,%eax
je     129f <t1_enc_sigpass_step+0x11f>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x5000,%eax
cmp    $0x0,%eax
jne    129f <t1_enc_sigpass_step+0x11f>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1040 <t1_getctxno_zc@plt>
mov    %eax,%edi
call   1090 <mqc_setcurctx@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1070 <int_abs@plt>
mov    %eax,%edx
and    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <mqc_encode@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1291 <t1_enc_sigpass_step+0x111>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1070 <int_abs@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%esi
add    $0x6,%esi
call   1060 <t1_getnmsedec_sig@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq (%rax),%rcx
add    %rdx,%rcx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <t1_getctxno_sc@plt>
mov    %eax,%edi
call   1090 <mqc_setcurctx@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   10a0 <t1_getspb@plt>
mov    -0x30(%rbp),%edi
xor    %eax,%edi
call   1050 <mqc_encode@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <t1_updateflags@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
or     $0x1000,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
or     $0x4000,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1_enc_sigpass_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%edi
test   %dil,%dil
je     1236 <t1_enc_sigpass_step+0xb6>
mov    %edi,%eax
and    $0x5000,%eax
jne    1236 <t1_enc_sigpass_step+0xb6>
mov    %r9,%r15
mov    %r8d,%r13d
mov    %ecx,%r12d
mov    %rsi,%r14
mov    %edx,%esi
call   1040 <t1_getctxno_zc@plt>
mov    %eax,%edi
call   1090 <mqc_setcurctx@plt>
mov    (%r14),%edi
call   1070 <int_abs@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %r13d,%eax
setne  %dil
call   1050 <mqc_encode@plt>
test   %r13d,%ebp
je     122d <t1_enc_sigpass_step+0xad>
mov    (%r14),%edi
call   1070 <int_abs@plt>
add    $0x6,%r12d
mov    %eax,%edi
mov    %r12d,%esi
call   1060 <t1_getnmsedec_sig@plt>
add    %eax,(%r15)
mov    (%rbx),%edi
call   1030 <t1_getctxno_sc@plt>
mov    %eax,%edi
call   1090 <mqc_setcurctx@plt>
mov    (%r14),%ebp
shr    $0x1f,%ebp
mov    (%rbx),%edi
call   10a0 <t1_getspb@plt>
xor    %ebp,%eax
mov    %eax,%edi
call   1050 <mqc_encode@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <t1_updateflags@plt>
mov    $0x1000,%eax
or     (%rbx),%eax
jmp    122f <t1_enc_sigpass_step+0xaf>
mov    (%rbx),%eax
or     $0x4000,%eax
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @t1_enc_sigpass_step(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32* %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32* %5, i32** %12
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = and i32 %15, 255
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %78
18: ; preds = %6
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = and i32 %20, 20480
%22 = icmp ne i32 %21, 0
br i1 %22, label %78, label %23
23: ; preds = %18
%24 = load i32*, i32** %7
%25 = load i32, i32* %24
%26 = load i32, i32* %9
%27 = call i32 @t1_getctxno_zc(i32 %25, i32 %26)
%28 = call i32 @mqc_setcurctx(i32 %27)
%29 = load i32*, i32** %8
%30 = load i32, i32* %29
%31 = call i32 @int_abs(i32 %30)
%32 = load i32, i32* %11
%33 = and i32 %31, %32
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 0
store i32 %36, i32* %13
%37 = load i32, i32* %13
%38 = call i32 @mqc_encode(i32 %37)
%39 = load i32, i32* %13
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %74
41: ; preds = %23
%42 = load i32*, i32** %8
%43 = load i32, i32* %42
%44 = call i32 @int_abs(i32 %43)
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 6
%47 = call i64 @t1_getnmsedec_sig(i32 %44, i32 %46)
%48 = load i32*, i32** %12
%49 = load i32, i32* %48
%50 = sext i32 %49 to i64
%51 = add nsw i64 %50, %47
%52 = trunc i64 %51 to i32
store i32 %52, i32* %48
%53 = load i32*, i32** %7
%54 = load i32, i32* %53
%55 = call i32 @t1_getctxno_sc(i32 %54)
%56 = call i32 @mqc_setcurctx(i32 %55)
%57 = load i32*, i32** %8
%58 = load i32, i32* %57
%59 = icmp slt i32 %58, 0
%60 = zext i1 %59 to i64
%61 = select i1 %59, i32 1, i32 0
store i32 %61, i32* %13
%62 = load i32, i32* %13
%63 = load i32*, i32** %7
%64 = load i32, i32* %63
%65 = call i32 @t1_getspb(i32 %64)
%66 = xor i32 %62, %65
%67 = call i32 @mqc_encode(i32 %66)
%68 = load i32*, i32** %7
%69 = load i32, i32* %13
%70 = call i32 @t1_updateflags(i32* %68, i32 %69)
%71 = load i32*, i32** %7
%72 = load i32, i32* %71
%73 = or i32 %72, 4096
store i32 %73, i32* %71
br label %74
74: ; preds = %41, %23
%75 = load i32*, i32** %7
%76 = load i32, i32* %75
%77 = or i32 %76, 16384
store i32 %77, i32* %75
br label %78
78: ; preds = %74, %18, %6
ret void
}

LLVM IR (-O2):
define void @t1_enc_sigpass_step(i32* %0, i32* nocapture %1, i32 %2, i32 %3, i32 %4, i32* nocapture %5) {
%7 = load i32, i32* %0
%8 = and i32 %7, 255
%9 = icmp ne i32 %8, 0
%10 = and i32 %7, 20480
%11 = icmp eq i32 %10, 0
%12 = and i1 %9, %11
br i1 %12, label %13, label %48
13: ; preds = %6
%14 = tail call i32 @t1_getctxno_zc(i32 %7, i32 %2)
%15 = tail call i32 @mqc_setcurctx(i32 %14)
%16 = load i32, i32* %1
%17 = tail call i32 @int_abs(i32 %16)
%18 = and i32 %17, %4
%19 = icmp eq i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = tail call i32 @mqc_encode(i32 %21)
br i1 %19, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %0
br label %45
25: ; preds = %13
%26 = load i32, i32* %1
%27 = tail call i32 @int_abs(i32 %26)
%28 = add nsw i32 %3, 6
%29 = tail call i64 @t1_getnmsedec_sig(i32 %27, i32 %28)
%30 = load i32, i32* %5
%31 = trunc i64 %29 to i32
%32 = add i32 %30, %31
store i32 %32, i32* %5
%33 = load i32, i32* %0
%34 = tail call i32 @t1_getctxno_sc(i32 %33)
%35 = tail call i32 @mqc_setcurctx(i32 %34)
%36 = load i32, i32* %1
%37 = lshr i32 %36, 31
%38 = load i32, i32* %0
%39 = tail call i32 @t1_getspb(i32 %38)
%40 = xor i32 %39, %37
%41 = tail call i32 @mqc_encode(i32 %40)
%42 = tail call i32 @t1_updateflags(i32* %0, i32 %37)
%43 = load i32, i32* %0
%44 = or i32 %43, 4096
br label %45
45: ; preds = %23, %25
%46 = phi i32 [ %24, %23 ], [ %44, %25 ]
%47 = or i32 %46, 16384
store i32 %47, i32* %0
br label %48
48: ; preds = %45, %6
ret void
}