aboutsummaryrefslogtreecommitdiffstats
path: root/fw/pseudo/fp.fp_cmd03__h28.after.c
blob: d634d45a2db6c829e30a7ce949a179726ad31f22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// local variable allocation has failed, the output may be wrong!
int __fastcall fp_cmd03__h28(void *ctx, struct ta_params *params)
{
  unsigned int v2; // r2
  int v3; // r3
  int v4; // r4
  unsigned int v5; // r5
  unsigned __int64 v6; // r2
  bool v7; // zf
  bool v8; // nf
  unsigned int v9; // r12
  int v10; // lr
  unsigned int v11; // r12
  int v12; // r1
  bool v13; // zf
  unsigned int v14; // r1
  unsigned int v15; // r1
  unsigned int v16; // r6
  int v17; // r12
  bool v18; // cc
  char v19; // r6
  unsigned __int64 v20; // r0
  unsigned int v21; // r1
  unsigned int v22; // r12
  unsigned __int64 v23; // r0
  unsigned int v24; // r1
  unsigned int v25; // r12
  unsigned __int64 v26; // r0
  unsigned int v27; // r1
  __int64 v28; // r0
  __int64 v29; // r0
  unsigned __int64 v30; // r2
  char v31; // cf
  unsigned int v32; // r4
  unsigned int v33; // r6
  unsigned int v34; // r2
  unsigned int v35; // r2
  __int64 v36; // r0
  bool v37; // cf
  __int64 v38; // r0
  __int64 v39; // r0
  unsigned int v40; // r1
  unsigned int v41; // r12
  __int64 v42; // r0
  __int64 v43; // r0
  unsigned int v44; // r1
  unsigned int v45; // r12
  __int64 v46; // r0
  unsigned __int64 v47; // r2
  bool v48; // cf
  unsigned int v49; // r6
  unsigned __int64 v50; // r2
  bool v51; // cf
  int v52; // r1
  int v53; // r1
  unsigned int v54; // r4
  unsigned int i; // r5
  bool v56; // cf

  v4 = v3;
  v5 = v2;
  v6 = *(_QWORD *)&ctx;
  v7 = v4 == 0;
  v8 = v4 < 0;
  if ( v4 != 0 )
    v9 = v4;
  else
    v9 = v5;
  v10 = __clz(v9);
  v11 = v9 << (v10 + 1);
  if ( v4 != 0 )
  {
    v10 = 63 - v10;
    v7 = v10 == 0;
    v8 = v10 < 0;
  }
  if ( v7 )
  {
    v10 = 31 - v10;
    v8 = v10 < 0;
  }
  if ( v8 )
  {
    if ( *(_QWORD *)&ctx != 0 )
      v52 = -1;
    return v53;
  }
  else
  {
    v13 = v12 == 0;
    if ( v12 != 0 )
    {
      v15 = 63 - __clz(v14);
      v13 = v15 == 0;
    }
    else
    {
      v15 = __clz((unsigned int)ctx);
    }
    if ( v13 )
      v15 = 31 - v15;
    v16 = v15 - v10;
    if ( (int)(v15 - v10) < 0 )
    {
      return 0;
    }
    else if ( (int)(4 - v16) < 0 )
    {
      if ( v10 - 32 <= 4 )
        v11 |= v5 >> (v10 - 32);
      v17 = dword_4012F4[v11 >> 28];
      v18 = (unsigned int)v10 > 0x1F;
      if ( (unsigned int)v10 > 0x1F )
        LOBYTE(v10) = v10 - 32;
      v19 = 32 - v10;
      if ( v18 )
      {
        LODWORD(v38) = 0;
        HIDWORD(v38) = v17 * v5;
        v39 = (unsigned int)v17 * (unsigned __int64)(unsigned int)v4 + v38;
        v40 = -((HIDWORD(v39) << v19) | ((unsigned int)v39 >> v10));
        if ( (_DWORD)v39 << (32 - v10) != 0 )
          --v40;
        v41 = v17 + (((unsigned int)v17 * (unsigned __int64)v40) >> 32);
        LODWORD(v42) = 0;
        HIDWORD(v42) = v41 * v5;
        v43 = v41 * (unsigned __int64)(unsigned int)v4 + v42;
        v44 = -((HIDWORD(v43) << (32 - v10)) | ((unsigned int)v43 >> v10));
        if ( (_DWORD)v43 << (32 - v10) != 0 )
          --v44;
        v45 = v41 + ((v41 * (unsigned __int64)v44) >> 32) - 1;
        LODWORD(v46) = 0;
        HIDWORD(v46) = v45 * v6;
        ctx = (void *)((unsigned int)((v45 * (unsigned __int64)HIDWORD(v6) + v46) >> 32) >> v10);
        v47 = v6 - __PAIR64__(v4, v5) * (unsigned int)ctx;
        v48 = HIDWORD(v47) >= v4;
        if ( HIDWORD(v47) == v4 )
          v48 = (unsigned int)v47 >= v5;
        if ( v48 )
        {
          v49 = (unsigned int)((v45 * (unsigned __int64)HIDWORD(v47)
                              + ((v45 * (unsigned __int64)(unsigned int)v47) >> 32)) >> 32) >> v10;
          ctx = (char *)ctx + v49;
          v50 = v47 - __PAIR64__(v4, v5) * v49;
          v51 = HIDWORD(v50) >= v4;
          if ( HIDWORD(v50) == v4 )
            v51 = (unsigned int)v50 >= v5;
          if ( v51 )
            return (int)ctx + 1;
        }
      }
      else
      {
        v20 = (unsigned int)v17 * (unsigned __int64)v5;
        v21 = -((HIDWORD(v20) << v19) | ((unsigned int)v20 >> v10));
        if ( (_DWORD)v20 << v19 != 0 )
          --v21;
        v22 = v17 + (((unsigned int)v17 * (unsigned __int64)v21) >> 32);
        v23 = v22 * (unsigned __int64)v5;
        v24 = -((HIDWORD(v23) << v19) | ((unsigned int)v23 >> v10));
        if ( (_DWORD)v23 << v19 != 0 )
          --v24;
        v25 = v22 + ((v22 * (unsigned __int64)v24) >> 32);
        if ( HIDWORD(v6) != 0 )
        {
          v26 = v25 * (unsigned __int64)v5;
          v27 = -((HIDWORD(v26) << v19) | ((unsigned int)v26 >> v10));
          if ( (_DWORD)v26 << v19 != 0 )
            --v27;
          v25 += (v25 * (unsigned __int64)v27) >> 32;
        }
        LODWORD(v28) = 0;
        HIDWORD(v28) = v25 * v6;
        v29 = v25 * (unsigned __int64)HIDWORD(v6) + v28;
        ctx = (void *)(((unsigned int)v29 >> v10) | (HIDWORD(v29) << v19));
        HIDWORD(v29) >>= v10;
        v30 = v6 - *(_QWORD *)&ctx * v5;
        v31 = HIDWORD(v30) != 0;
        if ( HIDWORD(v30) == 0 )
          v31 = (unsigned int)v30 >= v5;
        if ( v31 )
        {
          v32 = (v25 * (unsigned __int64)HIDWORD(v30) + ((v25 * (unsigned __int64)(unsigned int)v30) >> 32)) >> 32;
          v33 = ((unsigned int)((v30 * v25) >> 32) >> v10) | (v32 << (32 - v10));
          *(_QWORD *)&ctx += __PAIR64__(v32 >> v10, v33);
          v34 = v30 - v33 * v5;
          if ( v34 >= v5 )
          {
            v35 = v34 - v5;
            v36 = *(_QWORD *)&ctx + 1LL;
            v37 = v35 >= v5;
            if ( v35 >= v5 )
              v35 -= v5;
            *(_QWORD *)&ctx = v36 + v37 + (v35 >= v5);
          }
        }
      }
    }
    else
    {
      ctx = nullptr;
      v54 = (v4 << v16) | (v5 >> (32 - v16));
      for ( i = v5 << v16; ; i = (i >> 1) | (v31 << 31) )
      {
        v56 = v6 >= __PAIR64__(v54, i);
        if ( v6 >= __PAIR64__(v54, i) )
          v6 -= __PAIR64__(v54, i);
        ctx = (char *)ctx + v56 + (_DWORD)ctx;
        v31 = v16-- != 0;
        if ( !v31 )
          break;
        v31 = v54 & 1;
        v54 >>= 1;
      }
    }
  }
  return (int)ctx;
}