1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // initially compiled with emscripten and then modified over time.
6 // params:
7 // R0: s
8 // R1: c
9 // R2: len
10 // ret: index
11 TEXT memchr<>(SB), NOSPLIT, $0
12 Get R1
13 Set R4
14 Block
15 Block
16 Get R2
17 I32Const $0
18 I32Ne
19 Tee R3
20 Get R0
21 I32Const $3
22 I32And
23 I32Const $0
24 I32Ne
25 I32And
26 If
27 Loop
28 Get R0
29 I32Load8U $0
30 Get R1
31 I32Eq
32 BrIf $2
33 Get R2
34 I32Const $-1
35 I32Add
36 Tee R2
37 I32Const $0
38 I32Ne
39 Tee R3
40 Get R0
41 I32Const $1
42 I32Add
43 Tee R0
44 I32Const $3
45 I32And
46 I32Const $0
47 I32Ne
48 I32And
49 BrIf $0
50 End
51 End
52 Get R3
53 BrIf $0
54 I32Const $0
55 Set R1
56 Br $1
57 End
58 Get R0
59 I32Load8U $0
60 Get R4
61 Tee R3
62 I32Eq
63 If
64 Get R2
65 Set R1
66 Else
67 Get R4
68 I32Const $16843009
69 I32Mul
70 Set R4
71 Block
72 Block
73 Get R2
74 I32Const $3
75 I32GtU
76 If
77 Get R2
78 Set R1
79 Loop
80 Get R0
81 I32Load $0
82 Get R4
83 I32Xor
84 Tee R2
85 I32Const $-2139062144
86 I32And
87 I32Const $-2139062144
88 I32Xor
89 Get R2
90 I32Const $-16843009
91 I32Add
92 I32And
93 I32Eqz
94 If
95 Get R0
96 I32Const $4
97 I32Add
98 Set R0
99 Get R1
100 I32Const $-4
101 I32Add
102 Tee R1
103 I32Const $3
104 I32GtU
105 BrIf $1
106 Br $3
107 End
108 End
109 Else
110 Get R2
111 Set R1
112 Br $1
113 End
114 Br $1
115 End
116 Get R1
117 I32Eqz
118 If
119 I32Const $0
120 Set R1
121 Br $3
122 End
123 End
124 Loop
125 Get R0
126 I32Load8U $0
127 Get R3
128 I32Eq
129 BrIf $2
130 Get R0
131 I32Const $1
132 I32Add
133 Set R0
134 Get R1
135 I32Const $-1
136 I32Add
137 Tee R1
138 BrIf $0
139 I32Const $0
140 Set R1
141 End
142 End
143 End
144 Get R0
145 I32Const $0
146 Get R1
147 Select
148 Return
149
View as plain text