1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14# fmod(a0, a1) == a2
15.function i32 fmod(f64 a0, f64 a1, f64 a2) {
16    lda.64 a0
17    fmod2.64 a1
18    fcmpl.64 a2
19    return
20}
21
22.function i32 main() {
23    fmovi.64 v0, 5.3
24    fmovi.64 v1, 2.0
25    fmovi.64 v2, 1.2999999999999998
26    call fmod, v0, v1, v2
27    jnez end
28
29    fmovi.64 v0, -18.5
30    fmovi.64 v1, 4.2
31    fmovi.64 v2, -1.6999999999999993
32    call fmod, v0, v1, v2
33    jnez end
34
35    fmovi.64 v0, 2.1
36    fmovi.64 v1, 4.2
37    fmovi.64 v2, 2.1
38    call fmod, v0, v1, v2
39    jnez end
40
41    fmovi.64 v0, 18.5
42    fmovi.64 v1, 4.2
43    fmovi.64 v2, 1.6999999999999993
44    call fmod, v0, v1, v2
45    jnez end
46
47    fmovi.64 v0, 4.0
48    fmovi.64 v1, 4.0
49    fmovi.64 v2, 0.0
50    call fmod, v0, v1, v2
51
52end:
53    return
54}
55