aboutsummaryrefslogtreecommitdiffstats
path: root/fw/pseudo/fp.fp_cmd03__h28.before.c
blob: 4deb54e3870fb85771917bd4948124adaf750281 (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
int __fastcall sub_401000(unsigned __int64 a1, unsigned int a2, int a3)
{
  unsigned __int64 v5; // r2
  bool v6; // zf
  bool v7; // nf
  unsigned int v8; // r12
  int v9; // lr
  unsigned int v10; // r12
  bool v11; // zf
  unsigned int v12; // r1
  unsigned int v13; // r6
  int v14; // r12
  bool v15; // cc
  char v16; // r6
  unsigned __int64 v17; // r0
  unsigned int v18; // r1
  unsigned int v19; // r12
  unsigned __int64 v20; // r0
  unsigned int v21; // r1
  unsigned int v22; // r12
  unsigned __int64 v23; // r0
  unsigned int v24; // r1
  __int64 v25; // r0
  __int64 v26; // r0
  unsigned __int64 v27; // r2
  char v28; // cf
  unsigned __int64 v29; // kr08_8
  unsigned int v30; // r6
  unsigned int v31; // r2
  unsigned int v32; // r2
  int v33; // r0
  bool v34; // cf
  __int64 v35; // r0
  __int64 v36; // r0
  unsigned int v37; // r1
  unsigned int v38; // r12
  __int64 v39; // r0
  __int64 v40; // r0
  unsigned int v41; // r1
  unsigned int v42; // r12
  int v43; // r0
  unsigned __int64 v44; // r2
  bool v45; // cf
  unsigned int v46; // r6
  unsigned __int64 v47; // r2
  bool v48; // cf
  unsigned int v49; // r4
  unsigned int i; // r5
  bool v51; // cf

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