clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name k_rem_pio2f.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/lib/libm/obj -resource-dir /usr/local/lib/clang/13.0.0 -include namespace.h -I /usr/src/lib/libm/arch/amd64 -I /usr/src/lib/libm/src -I /usr/src/lib/libm/src/ld80 -I /usr/src/lib/libm/hidden -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/lib/libm/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/lib/libm/src/k_rem_pio2f.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | #include "math.h" |
17 | #include "math_private.h" |
18 | |
19 | |
20 | |
21 | |
22 | static const int init_jk[] = {4,7,9}; |
23 | |
24 | static const float PIo2[] = { |
25 | 1.5703125000e+00, |
26 | 4.5776367188e-04, |
27 | 2.5987625122e-05, |
28 | 7.5437128544e-08, |
29 | 6.0026650317e-11, |
30 | 7.3896444519e-13, |
31 | 5.3845816694e-15, |
32 | 5.6378512969e-18, |
33 | 8.3009228831e-20, |
34 | 3.2756352257e-22, |
35 | 6.3331015649e-25, |
36 | }; |
37 | |
38 | static const float |
39 | zero = 0.0, |
40 | one = 1.0, |
41 | two8 = 2.5600000000e+02, |
42 | twon8 = 3.9062500000e-03; |
43 | |
44 | int |
45 | __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, |
46 | const int32_t *ipio2) |
47 | { |
48 | int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; |
49 | float z,fw,f[20],fq[20],q[20]; |
50 | |
51 | |
52 | jk = init_jk[prec]; |
53 | jp = jk; |
54 | |
55 | |
56 | jx = nx-1; |
57 | jv = (e0-3)/8; if(jv<0) jv=0; |
| |
| |
58 | q0 = e0-8*(jv+1); |
59 | |
60 | |
61 | j = jv-jx; m = jx+jk; |
62 | for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; |
| |
| 4 | | Loop condition is false. Execution continues on line 65 | |
|
63 | |
64 | |
65 | for (i=0;i<=jk;i++) { |
| |
| 6 | | Loop condition is false. Execution continues on line 69 | |
|
66 | for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; |
67 | } |
68 | |
69 | jz = jk; |
70 | recompute: |
71 | |
72 | for(i=0,j=jz,z=q[jz];j>0;i++,j--) { |
| 7 | | Loop condition is false. Execution continues on line 79 | |
|
73 | fw = (float)((int32_t)(twon8* z)); |
74 | iq[i] = (int32_t)(z-two8*fw); |
75 | z = q[j-1]+fw; |
76 | } |
77 | |
78 | |
79 | z = scalbnf(z,q0); |
80 | z -= (float)8.0*floorf(z*(float)0.125); |
81 | n = (int32_t) z; |
82 | z -= (float)n; |
83 | ih = 0; |
84 | if(q0>0) { |
| |
| |
85 | i = (iq[jz-1]>>(8-q0)); n += i; |
86 | iq[jz-1] -= i<<(8-q0); |
87 | ih = iq[jz-1]>>(7-q0); |
88 | } |
89 | else if(q0==0) ih = iq[jz-1]>>8; |
| 10 | | Assuming 'q0' is not equal to 0 | |
|
| |
90 | else if(z>=(float)0.5) ih=2; |
| 12 | | Assuming the condition is false | |
|
| |
91 | |
92 | if(ih>0) { |
| |
93 | n += 1; carry = 0; |
94 | for(i=0;i<jz ;i++) { |
95 | j = iq[i]; |
96 | if(carry==0) { |
97 | if(j!=0) { |
98 | carry = 1; iq[i] = 0x100- j; |
99 | } |
100 | } else iq[i] = 0xff - j; |
101 | } |
102 | if(q0>0) { |
103 | switch(q0) { |
104 | case 1: |
105 | iq[jz-1] &= 0x7f; break; |
106 | case 2: |
107 | iq[jz-1] &= 0x3f; break; |
108 | } |
109 | } |
110 | if(ih==2) { |
111 | z = one - z; |
112 | if(carry!=0) z -= scalbnf(one,q0); |
113 | } |
114 | } |
115 | |
116 | |
117 | if(z==zero) { |
| 15 | | Assuming 'z' is not equal to 'zero' | |
|
| |
118 | j = 0; |
119 | for (i=jz-1;i>=jk;i--) j |= iq[i]; |
120 | if(j==0) { |
121 | for(k=1;iq[jk-k]==0;k++); |
122 | |
123 | for(i=jz+1;i<=jz+k;i++) { |
124 | f[jx+i] = (float) ipio2[jv+i]; |
125 | for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; |
126 | q[i] = fw; |
127 | } |
128 | jz += k; |
129 | goto recompute; |
130 | } |
131 | } |
132 | |
133 | |
134 | if(z==(float)0.0) { |
| 17 | | Assuming the condition is true | |
|
| |
135 | jz -= 1; q0 -= 8; |
136 | while(iq[jz]==0) { jz--; q0-=8;} |
| 19 | | Loop condition is false. Execution continues on line 148 | |
|
137 | } else { |
138 | z = scalbnf(z,-q0); |
139 | if(z>=two8) { |
140 | fw = (float)((int32_t)(twon8*z)); |
141 | iq[jz] = (int32_t)(z-two8*fw); |
142 | jz += 1; q0 += 8; |
143 | iq[jz] = (int32_t) fw; |
144 | } else iq[jz] = (int32_t) z ; |
145 | } |
146 | |
147 | |
148 | fw = scalbnf(one,q0); |
149 | for(i=jz;i>=0;i--) { |
| |
| 21 | | Loop condition is false. Execution continues on line 154 | |
|
150 | q[i] = fw*(float)iq[i]; fw*=twon8; |
151 | } |
152 | |
153 | |
154 | for(i=jz;i>=0;i--) { |
| 22 | | Loop condition is false. Execution continues on line 160 | |
|
155 | for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; |
156 | fq[jz-i] = fw; |
157 | } |
158 | |
159 | |
160 | switch(prec) { |
| 23 | | Control jumps to 'case 3:' at line 175 | |
|
161 | case 0: |
162 | fw = 0.0; |
163 | for (i=jz;i>=0;i--) fw += fq[i]; |
164 | y[0] = (ih==0)? fw: -fw; |
165 | break; |
166 | case 1: |
167 | case 2: |
168 | fw = 0.0; |
169 | for (i=jz;i>=0;i--) fw += fq[i]; |
170 | y[0] = (ih==0)? fw: -fw; |
171 | fw = fq[0]-fw; |
172 | for (i=1;i<=jz;i++) fw += fq[i]; |
173 | y[1] = (ih==0)? fw: -fw; |
174 | break; |
175 | case 3: |
176 | for (i=jz;i>0;i--) { |
| 24 | | Loop condition is false. Execution continues on line 181 | |
|
177 | fw = fq[i-1]+fq[i]; |
178 | fq[i] += fq[i-1]-fw; |
179 | fq[i-1] = fw; |
180 | } |
181 | for (i=jz;i>1;i--) { |
| 25 | | Loop condition is false. Execution continues on line 186 | |
|
182 | fw = fq[i-1]+fq[i]; |
183 | fq[i] += fq[i-1]-fw; |
184 | fq[i-1] = fw; |
185 | } |
186 | for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; |
| 26 | | Loop condition is false. Execution continues on line 187 | |
|
187 | if(ih==0) { |
| |
188 | y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; |
| 28 | | Assigned value is garbage or undefined |
|
189 | } else { |
190 | y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; |
191 | } |
192 | } |
193 | return n&7; |
194 | } |