Home | History | Annotate | Line # | Download | only in test_src
sljitTest.c revision 1.1
      1 /*
      2  *    Stack-less Just-In-Time compiler
      3  *
      4  *    Copyright 2009-2010 Zoltan Herczeg (hzmester (at) freemail.hu). All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without modification, are
      7  * permitted provided that the following conditions are met:
      8  *
      9  *   1. Redistributions of source code must retain the above copyright notice, this list of
     10  *      conditions and the following disclaimer.
     11  *
     12  *   2. Redistributions in binary form must reproduce the above copyright notice, this list
     13  *      of conditions and the following disclaimer in the documentation and/or other materials
     14  *      provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
     17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
     19  * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     21  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     22  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #include "sljitLir.h"
     28 
     29 #include <stdio.h>
     30 #include <stdlib.h>
     31 #include <string.h>
     32 
     33 union executable_code {
     34 	void* code;
     35 	sljit_w (SLJIT_CALL *func0)(void);
     36 	sljit_w (SLJIT_CALL *func1)(sljit_w a);
     37 	sljit_w (SLJIT_CALL *func2)(sljit_w a, sljit_w b);
     38 	sljit_w (SLJIT_CALL *func3)(sljit_w a, sljit_w b, sljit_w c);
     39 };
     40 typedef union executable_code executable_code;
     41 
     42 static int successful_tests = 0;
     43 
     44 #define FAILED(cond, text) \
     45 	if (SLJIT_UNLIKELY(cond)) { \
     46 		printf(text); \
     47 		return; \
     48 	}
     49 
     50 #define CHECK(compiler) \
     51 	if (sljit_get_compiler_error(compiler) != SLJIT_ERR_COMPILED) { \
     52 		printf("Compiler error: %d\n", sljit_get_compiler_error(compiler)); \
     53 		sljit_free_compiler(compiler); \
     54 		return; \
     55 	}
     56 
     57 static void cond_set(struct sljit_compiler *compiler, int dst, sljit_w dstw, int type)
     58 {
     59 	/* Testing both sljit_emit_cond_value and sljit_emit_jump. */
     60 	struct sljit_jump* jump;
     61 	struct sljit_label* label;
     62 
     63 	sljit_emit_cond_value(compiler, SLJIT_MOV, dst, dstw, type);
     64 	jump = sljit_emit_jump(compiler, type);
     65 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, dst, dstw, SLJIT_IMM, 2);
     66 	label = sljit_emit_label(compiler);
     67 	sljit_set_label(jump, label);
     68 }
     69 
     70 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
     71 
     72 #define MALLOC_EXEC(result, size) \
     73 	result = SLJIT_MALLOC_EXEC(size); \
     74 	if (!result) { \
     75 		printf("Cannot allocate executable memory\n"); \
     76 		return; \
     77 	} \
     78 	memset(result, 255, size);
     79 
     80 static void test_exec_allocator(void)
     81 {
     82 	/* This is not an sljit test. */
     83 	void *ptr1;
     84 	void *ptr2;
     85 	void *ptr3;
     86 
     87 	MALLOC_EXEC(ptr1, 32);
     88 	MALLOC_EXEC(ptr2, 512);
     89 	MALLOC_EXEC(ptr3, 512);
     90 	SLJIT_FREE_EXEC(ptr2);
     91 	SLJIT_FREE_EXEC(ptr3);
     92 	SLJIT_FREE_EXEC(ptr1);
     93 	MALLOC_EXEC(ptr1, 262104);
     94 	MALLOC_EXEC(ptr2, 32000);
     95 	SLJIT_FREE_EXEC(ptr1);
     96 	MALLOC_EXEC(ptr1, 262104);
     97 	SLJIT_FREE_EXEC(ptr1);
     98 	SLJIT_FREE_EXEC(ptr2);
     99 	MALLOC_EXEC(ptr1, 512);
    100 	MALLOC_EXEC(ptr2, 512);
    101 	MALLOC_EXEC(ptr3, 512);
    102 	SLJIT_FREE_EXEC(ptr2);
    103 	MALLOC_EXEC(ptr2, 512);
    104 	SLJIT_FREE_EXEC(ptr3);
    105 	SLJIT_FREE_EXEC(ptr1);
    106 	SLJIT_FREE_EXEC(ptr2);
    107 #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
    108 	/* Just call the global locks. */
    109 	sljit_grab_lock();
    110 	sljit_release_lock();
    111 #endif
    112 	printf("Executable allocator: ok\n");
    113 }
    114 
    115 #undef MALLOC_EXEC
    116 
    117 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
    118 
    119 static void test1(void)
    120 {
    121 	/* Enter and return from an sljit function. */
    122 	executable_code code;
    123 	struct sljit_compiler* compiler = sljit_create_compiler();
    124 
    125 	FAILED(!compiler, "cannot create compiler\n");
    126 
    127 	/* 3 arguments passed, 3 arguments used. */
    128 	sljit_emit_enter(compiler, 3, 3, 3, 0);
    129 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0);
    130 
    131 	SLJIT_ASSERT(sljit_get_generated_code_size(compiler) == 0);
    132 	code.code = sljit_generate_code(compiler);
    133 	CHECK(compiler);
    134 	SLJIT_ASSERT(compiler->error == SLJIT_ERR_COMPILED);
    135 	SLJIT_ASSERT(sljit_get_generated_code_size(compiler) > 0);
    136 	sljit_free_compiler(compiler);
    137 
    138 	FAILED(code.func3(3, -21, 86) != -21, "test1 case 1 failed\n");
    139 	FAILED(code.func3(4789, 47890, 997) != 47890, "test1 case 2 failed\n");
    140 	sljit_free_code(code.code);
    141 	printf("test1 ok\n");
    142 	successful_tests++;
    143 }
    144 
    145 static void test2(void)
    146 {
    147 	/* Test mov. */
    148 	executable_code code;
    149 	struct sljit_compiler* compiler = sljit_create_compiler();
    150 	sljit_w buf[6];
    151 	static sljit_w data[2] = { 0, -9876 };
    152 
    153 	FAILED(!compiler, "cannot create compiler\n");
    154 
    155 	buf[0] = 5678;
    156 	buf[1] = 0;
    157 	buf[2] = 0;
    158 	buf[3] = 0;
    159 	buf[4] = 0;
    160 	buf[5] = 0;
    161 	sljit_emit_enter(compiler, 1, 3, 2, 0);
    162 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_UNUSED, 0, SLJIT_MEM0(), (sljit_w)&buf);
    163 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9999);
    164 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG1, 0);
    165 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
    166 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
    167 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 0);
    168 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 2);
    169 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_SAVED_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 0);
    170 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 3);
    171 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_SAVED_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM0(), (sljit_w)&buf);
    172 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
    173 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&data);
    174 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
    175 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf - 0x12345678);
    176 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0x12345678);
    177 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
    178 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0);
    179 
    180 	code.code = sljit_generate_code(compiler);
    181 	CHECK(compiler);
    182 	sljit_free_compiler(compiler);
    183 
    184 	FAILED(code.func1((sljit_w)&buf) != 9999, "test2 case 1 failed\n");
    185 	FAILED(buf[1] != 9999, "test2 case 2 failed\n");
    186 	FAILED(buf[2] != 9999, "test2 case 3 failed\n");
    187 	FAILED(buf[3] != 5678, "test2 case 4 failed\n");
    188 	FAILED(buf[4] != -9876, "test2 case 5 failed\n");
    189 	FAILED(buf[5] != 5678, "test2 case 6 failed\n");
    190 	sljit_free_code(code.code);
    191 	printf("test2 ok\n");
    192 	successful_tests++;
    193 }
    194 
    195 static void test3(void)
    196 {
    197 	/* Test not. */
    198 	executable_code code;
    199 	struct sljit_compiler* compiler = sljit_create_compiler();
    200 	sljit_w buf[5];
    201 
    202 	FAILED(!compiler, "cannot create compiler\n");
    203 	buf[0] = 1234;
    204 	buf[1] = 0;
    205 	buf[2] = 9876;
    206 	buf[3] = 0;
    207 	buf[4] = 0x12345678;
    208 
    209 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    210 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_UNUSED, 0, SLJIT_MEM0(), (sljit_w)&buf);
    211 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    212 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM0(), (sljit_w)&buf[1], SLJIT_MEM0(), (sljit_w)&buf[1]);
    213 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_RETURN_REG, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    214 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2);
    215 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)&buf[4] - 0xff0000 - 0x20);
    216 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, (sljit_w)&buf[4] - 0xff0000);
    217 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0xff0000 + 0x20, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), 0xff0000);
    218 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    219 
    220 	code.code = sljit_generate_code(compiler);
    221 	CHECK(compiler);
    222 	sljit_free_compiler(compiler);
    223 
    224 	FAILED(code.func1((sljit_w)&buf) != ~1234, "test3 case 1 failed\n");
    225 	FAILED(buf[1] != ~1234, "test3 case 2 failed\n");
    226 	FAILED(buf[3] != ~9876, "test3 case 3 failed\n");
    227 	FAILED(buf[4] != ~0x12345678, "test3 case 4 failed\n");
    228 
    229 	sljit_free_code(code.code);
    230 	printf("test3 ok\n");
    231 	successful_tests++;
    232 }
    233 
    234 static void test4(void)
    235 {
    236 	/* Test neg. */
    237 	executable_code code;
    238 	struct sljit_compiler* compiler = sljit_create_compiler();
    239 	sljit_w buf[4];
    240 
    241 	FAILED(!compiler, "cannot create compiler\n");
    242 	buf[0] = 0;
    243 	buf[1] = 1234;
    244 	buf[2] = 0;
    245 	buf[3] = 0;
    246 
    247 	sljit_emit_enter(compiler, 2, 3, 2, 0);
    248 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    249 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_SAVED_REG2, 0);
    250 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_MEM0(), (sljit_w)&buf[1]);
    251 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_RETURN_REG, 0, SLJIT_SAVED_REG2, 0);
    252 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 299);
    253 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    254 
    255 	code.code = sljit_generate_code(compiler);
    256 	CHECK(compiler);
    257 	sljit_free_compiler(compiler);
    258 
    259 	FAILED(code.func2((sljit_w)&buf, 4567) != -4567, "test4 case 1 failed\n");
    260 	FAILED(buf[0] != -1234, "test4 case 2 failed\n");
    261 	FAILED(buf[2] != -4567, "test4 case 3 failed\n");
    262 	FAILED(buf[3] != -299, "test4 case 4 failed\n");
    263 
    264 	sljit_free_code(code.code);
    265 	printf("test4 ok\n");
    266 	successful_tests++;
    267 }
    268 
    269 static void test5(void)
    270 {
    271 	/* Test add. */
    272 	executable_code code;
    273 	struct sljit_compiler* compiler = sljit_create_compiler();
    274 	sljit_w buf[9];
    275 
    276 	FAILED(!compiler, "cannot create compiler\n");
    277 	buf[0] = 100;
    278 	buf[1] = 200;
    279 	buf[2] = 300;
    280 	buf[3] = 0;
    281 	buf[4] = 0;
    282 	buf[5] = 0;
    283 	buf[6] = 0;
    284 	buf[7] = 0;
    285 	buf[8] = 313;
    286 
    287 	sljit_emit_enter(compiler, 1, 3, 2, 0);
    288 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_IMM, 16, SLJIT_IMM, 16);
    289 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_IMM, 255, SLJIT_IMM, 255);
    290 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0);
    291 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
    292 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50);
    293 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0);
    294 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w) + 2);
    295 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50);
    296 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    297 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
    298 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4, SLJIT_TEMPORARY_REG1, 0);
    299 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50, SLJIT_TEMPORARY_REG2, 0);
    300 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, 50, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w));
    301 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
    302 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w));
    303 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w));
    304 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
    305 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x1e7d39f2);
    306 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x23de7c06);
    307 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_IMM, 0x3d72e452, SLJIT_TEMPORARY_REG2, 0);
    308 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_IMM, -43, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w));
    309 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1000, SLJIT_TEMPORARY_REG1, 0);
    310 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1430);
    311 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -99, SLJIT_TEMPORARY_REG1, 0);
    312 
    313 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
    314 
    315 	code.code = sljit_generate_code(compiler);
    316 	CHECK(compiler);
    317 	sljit_free_compiler(compiler);
    318 
    319 	FAILED(code.func1((sljit_w)&buf) != 2437 + 2 * sizeof(sljit_w), "test5 case 1 failed\n");
    320 	FAILED(buf[0] != 202 + 2 * sizeof(sljit_w), "test5 case 2 failed\n");
    321 	FAILED(buf[2] != 500, "test5 case 3 failed\n");
    322 	FAILED(buf[3] != 400, "test5 case 4 failed\n");
    323 	FAILED(buf[4] != 200, "test5 case 5 failed\n");
    324 	FAILED(buf[5] != 250, "test5 case 6 failed\n");
    325 	FAILED(buf[6] != 0x425bb5f8, "test5 case 7 failed\n");
    326 	FAILED(buf[7] != 0x5bf01e44, "test5 case 8 failed\n");
    327 	FAILED(buf[8] != 270, "test5 case 9 failed\n");
    328 
    329 	sljit_free_code(code.code);
    330 	printf("test5 ok\n");
    331 	successful_tests++;
    332 }
    333 
    334 static void test6(void)
    335 {
    336 	/* Test addc, sub, subc. */
    337 	executable_code code;
    338 	struct sljit_compiler* compiler = sljit_create_compiler();
    339 	sljit_w buf[10];
    340 
    341 	FAILED(!compiler, "cannot create compiler\n");
    342 	buf[0] = 0;
    343 	buf[1] = 0;
    344 	buf[2] = 0;
    345 	buf[3] = 0;
    346 	buf[4] = 0;
    347 	buf[5] = 0;
    348 	buf[6] = 0;
    349 	buf[7] = 0;
    350 	buf[8] = 0;
    351 	buf[9] = 0;
    352 
    353 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    354 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
    355 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
    356 	sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0, SLJIT_IMM, 0);
    357 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
    358 	sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 4);
    359 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
    360 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 50);
    361 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6000);
    362 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 10);
    363 	sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 5);
    364 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
    365 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2);
    366 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
    367 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5000);
    368 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
    369 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
    370 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG2, 0);
    371 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5000);
    372 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6000, SLJIT_TEMPORARY_REG1, 0);
    373 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_TEMPORARY_REG1, 0);
    374 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
    375 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 32768);
    376 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_TEMPORARY_REG2, 0);
    377 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -32767);
    378 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_TEMPORARY_REG2, 0);
    379 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x52cd3bf4);
    380 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x3da297c6);
    381 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 10);
    382 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 5);
    383 	sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 2);
    384 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, -2220);
    385 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    386 
    387 	code.code = sljit_generate_code(compiler);
    388 	CHECK(compiler);
    389 	sljit_free_compiler(compiler);
    390 
    391 	FAILED(code.func1((sljit_w)&buf) != 2223, "test6 case 1 failed\n");
    392 	FAILED(buf[0] != 1, "test6 case 2 failed\n");
    393 	FAILED(buf[1] != 5, "test6 case 3 failed\n");
    394 	FAILED(buf[2] != 50, "test6 case 4 failed\n");
    395 	FAILED(buf[3] != 4, "test6 case 5 failed\n");
    396 	FAILED(buf[4] != 50, "test6 case 6 failed\n");
    397 	FAILED(buf[5] != 50, "test6 case 7 failed\n");
    398 	FAILED(buf[6] != 1000, "test6 case 8 failed\n");
    399 	FAILED(buf[7] != 100 - 32768, "test6 case 9 failed\n");
    400 	FAILED(buf[8] != 100 + 32767, "test6 case 10 failed\n");
    401 	FAILED(buf[9] != 0x152aa42e, "test6 case 11 failed\n");
    402 
    403 	sljit_free_code(code.code);
    404 	printf("test6 ok\n");
    405 	successful_tests++;
    406 }
    407 
    408 static void test7(void)
    409 {
    410 	/* Test logical operators. */
    411 	executable_code code;
    412 	struct sljit_compiler* compiler = sljit_create_compiler();
    413 	sljit_w buf[8];
    414 
    415 	FAILED(!compiler, "cannot create compiler\n");
    416 	buf[0] = 0xff80;
    417 	buf[1] = 0x0f808080;
    418 	buf[2] = 0;
    419 	buf[3] = 0xaaaaaa;
    420 	buf[4] = 0;
    421 	buf[5] = 0x4040;
    422 	buf[6] = 0;
    423 	buf[7] = 0xc43a7f95;
    424 
    425 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    426 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf0C000);
    427 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x308f);
    428 	sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
    429 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 0xf0f0f0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3);
    430 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xC0F0);
    431 	sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5);
    432 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff0000);
    433 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
    434 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xC0F0);
    435 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5);
    436 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xff0000);
    437 	sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 0xFFFFFF, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
    438 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_IMM, 0xa56c82c0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6);
    439 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7);
    440 	sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_IMM, 0xff00ff00, SLJIT_TEMPORARY_REG1, 0);
    441 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff00ff00);
    442 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x0f);
    443 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0x888888, SLJIT_TEMPORARY_REG2, 0);
    444 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    445 
    446 	code.code = sljit_generate_code(compiler);
    447 	CHECK(compiler);
    448 	sljit_free_compiler(compiler);
    449 
    450 	FAILED(code.func1((sljit_w)&buf) != 0x8808, "test7 case 1 failed\n");
    451 	FAILED(buf[0] != 0x0F807F00, "test7 case 2 failed\n");
    452 	FAILED(buf[1] != 0x0F7F7F7F, "test7 case 3 failed\n");
    453 	FAILED(buf[2] != 0x00F0F08F, "test7 case 4 failed\n");
    454 	FAILED(buf[3] != 0x00A0A0A0, "test7 case 5 failed\n");
    455 	FAILED(buf[4] != 0x00FF80B0, "test7 case 6 failed\n");
    456 	FAILED(buf[5] != 0x00FF4040, "test7 case 7 failed\n");
    457 	FAILED(buf[6] != 0xa56c82c0, "test7 case 8 failed\n");
    458 	FAILED(buf[7] != 0x3b3a8095, "test7 case 9 failed\n");
    459 
    460 	sljit_free_code(code.code);
    461 	printf("test7 ok\n");
    462 	successful_tests++;
    463 }
    464 
    465 static void test8(void)
    466 {
    467 	/* Test flags (neg, cmp, test). */
    468 	executable_code code;
    469 	struct sljit_compiler* compiler = sljit_create_compiler();
    470 	sljit_w buf[20];
    471 
    472 	FAILED(!compiler, "cannot create compiler\n");
    473 	buf[0] = 100;
    474 	buf[1] = 3;
    475 	buf[2] = 3;
    476 	buf[3] = 3;
    477 	buf[4] = 3;
    478 	buf[5] = 3;
    479 	buf[6] = 3;
    480 	buf[7] = 3;
    481 	buf[8] = 3;
    482 	buf[9] = 3;
    483 
    484 	sljit_emit_enter(compiler, 1, 3, 2, 0);
    485 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
    486 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 10);
    487 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 6, SLJIT_IMM, 5);
    488 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_NOT_EQUAL);
    489 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_C_EQUAL);
    490 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3000);
    491 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_C_GREATER);
    492 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_SAVED_REG2, 0);
    493 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_C_LESS);
    494 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG3, 0);
    495 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -15);
    496 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_C_SIG_GREATER);
    497 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG3, 0);
    498 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
    499 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
    500 	sljit_emit_op1(compiler, SLJIT_NEG | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_IMM, (sljit_w)1 << ((sizeof(sljit_w) << 3) - 1));
    501 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_OVERFLOW);
    502 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
    503 	sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    504 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_ZERO);
    505 	sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0);
    506 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_ZERO);
    507 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0xffff, SLJIT_TEMPORARY_REG1, 0);
    508 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffff);
    509 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_C_NOT_ZERO);
    510 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0xffff, SLJIT_TEMPORARY_REG2, 0);
    511 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0xffff);
    512 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
    513 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    514 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    515 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0x1);
    516 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_C_NOT_ZERO);
    517 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
    518 
    519 	code.code = sljit_generate_code(compiler);
    520 	CHECK(compiler);
    521 	sljit_free_compiler(compiler);
    522 
    523 	code.func1((sljit_w)&buf);
    524 	FAILED(buf[1] != 1, "test8 case 1 failed\n");
    525 	FAILED(buf[2] != 0, "test8 case 2 failed\n");
    526 	FAILED(buf[3] != 0, "test8 case 3 failed\n");
    527 	FAILED(buf[4] != 1, "test8 case 4 failed\n");
    528 	FAILED(buf[5] != 1, "test8 case 5 failed\n");
    529 	FAILED(buf[6] != 1, "test8 case 6 failed\n");
    530 	FAILED(buf[7] != 1, "test8 case 7 failed\n");
    531 	FAILED(buf[8] != 0, "test8 case 8 failed\n");
    532 	FAILED(buf[9] != 1, "test8 case 9 failed\n");
    533 	FAILED(buf[10] != 0, "test8 case 10 failed\n");
    534 
    535 	sljit_free_code(code.code);
    536 	printf("test8 ok\n");
    537 	successful_tests++;
    538 }
    539 
    540 static void test9(void)
    541 {
    542 	/* Test shift. */
    543 	executable_code code;
    544 	struct sljit_compiler* compiler = sljit_create_compiler();
    545 	sljit_w buf[13];
    546 
    547 	FAILED(!compiler, "cannot create compiler\n");
    548 	buf[0] = 0;
    549 	buf[1] = 0;
    550 	buf[2] = 0;
    551 	buf[3] = 0;
    552 	buf[4] = 1 << 10;
    553 	buf[5] = 0;
    554 	buf[6] = 0;
    555 	buf[7] = 0;
    556 	buf[8] = 0;
    557 	buf[9] = 3;
    558 	buf[10] = 0;
    559 	buf[11] = 0;
    560 	buf[12] = 0;
    561 
    562 	sljit_emit_enter(compiler, 1, 3, 2, 0);
    563 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf);
    564 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
    565 	sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
    566 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
    567 	sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
    568 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
    569 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
    570 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -64);
    571 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 2);
    572 	sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
    573 
    574 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0xff);
    575 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
    576 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_PREF_SHIFT_REG, 0, SLJIT_PREF_SHIFT_REG, 0, SLJIT_TEMPORARY_REG1, 0);
    577 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_PREF_SHIFT_REG, 0);
    578 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0xff);
    579 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
    580 	sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
    581 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_PREF_SHIFT_REG, 0, SLJIT_TEMPORARY_REG1, 0);
    582 
    583 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0xf);
    584 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
    585 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    586 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_SAVED_REG2, 0);
    587 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    588 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_TEMPORARY_REG1, 0);
    589 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xf00);
    590 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
    591 	sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG1, 0);
    592 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_TEMPORARY_REG2, 0);
    593 
    594 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)buf);
    595 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 9);
    596 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT);
    597 
    598 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 4);
    599 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 2, SLJIT_PREF_SHIFT_REG, 0);
    600 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_PREF_SHIFT_REG, 0);
    601 
    602 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xa9);
    603 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
    604 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x7d00);
    605 	sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 32);
    606 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    607 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
    608 #endif
    609 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    610 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xe30000);
    611 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    612 	sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffc0);
    613 #else
    614 	sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffe0);
    615 #endif
    616 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    617 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x25000000);
    618 	sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xfffe1);
    619 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    620 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
    621 #endif
    622 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 11, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    623 
    624 	SLJIT_ASSERT(SLJIT_TEMPORARY_REG3 == SLJIT_PREF_SHIFT_REG);
    625 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
    626 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x5c);
    627 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
    628 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf600);
    629 	sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
    630 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    631 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
    632 #endif
    633 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    634 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x630000);
    635 	sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
    636 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 12, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
    637 
    638 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
    639 
    640 	code.code = sljit_generate_code(compiler);
    641 	CHECK(compiler);
    642 	sljit_free_compiler(compiler);
    643 
    644 	code.func1((sljit_w)&buf);
    645 	FAILED(buf[0] != 0x3c, "test9 case 1 failed\n");
    646 	FAILED(buf[1] != 0xf0, "test9 case 2 failed\n");
    647 	FAILED(buf[2] != -16, "test9 case 3 failed\n");
    648 	FAILED(buf[3] != 0xff0, "test9 case 4 failed\n");
    649 	FAILED(buf[4] != 4, "test9 case 5 failed\n");
    650 	FAILED(buf[5] != 0xff00, "test9 case 6 failed\n");
    651 	FAILED(buf[6] != 0x3c, "test9 case 7 failed\n");
    652 	FAILED(buf[7] != 0xf0, "test9 case 8 failed\n");
    653 	FAILED(buf[8] != 0xf0, "test9 case 9 failed\n");
    654 	FAILED(buf[9] != 0x18, "test9 case 10 failed\n");
    655 	FAILED(buf[10] != 32, "test9 case 11 failed\n");
    656 	FAILED(buf[11] != 0x4ae37da9, "test9 case 12 failed\n");
    657 	FAILED(buf[12] != 0x63f65c, "test9 case 13 failed\n");
    658 
    659 	sljit_free_code(code.code);
    660 	printf("test9 ok\n");
    661 	successful_tests++;
    662 }
    663 
    664 static void test10(void)
    665 {
    666 	/* Test multiplications. */
    667 	executable_code code;
    668 	struct sljit_compiler* compiler = sljit_create_compiler();
    669 	sljit_w buf[6];
    670 
    671 	FAILED(!compiler, "cannot create compiler\n");
    672 	buf[0] = 3;
    673 	buf[1] = 0;
    674 	buf[2] = 0;
    675 	buf[3] = 6;
    676 	buf[4] = -10;
    677 	buf[5] = 0;
    678 
    679 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    680 
    681 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
    682 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
    683 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
    684 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 7);
    685 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 8);
    686 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
    687 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -3, SLJIT_IMM, -4);
    688 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0);
    689 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -2);
    690 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_TEMPORARY_REG1, 0);
    691 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w) / 2);
    692 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)&buf[3]);
    693 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1);
    694 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9);
    695 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
    696 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG1, 0);
    697 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 11, SLJIT_IMM, 10);
    698 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    699 
    700 	code.code = sljit_generate_code(compiler);
    701 	CHECK(compiler);
    702 	sljit_free_compiler(compiler);
    703 
    704 	FAILED(code.func1((sljit_w)&buf) != 110, "test10 case 1 failed\n");
    705 	FAILED(buf[0] != 15, "test10 case 2 failed\n");
    706 	FAILED(buf[1] != 56, "test10 case 3 failed\n");
    707 	FAILED(buf[2] != 12, "test10 case 4 failed\n");
    708 	FAILED(buf[3] != -12, "test10 case 5 failed\n");
    709 	FAILED(buf[4] != 100, "test10 case 6 failed\n");
    710 	FAILED(buf[5] != 81, "test10 case 7 failed\n");
    711 
    712 	sljit_free_code(code.code);
    713 	printf("test10 ok\n");
    714 	successful_tests++;
    715 }
    716 
    717 static void test11(void)
    718 {
    719 	/* Test rewritable constants. */
    720 	executable_code code;
    721 	struct sljit_compiler* compiler = sljit_create_compiler();
    722 	struct sljit_const* const1;
    723 	struct sljit_const* const2;
    724 	struct sljit_const* const3;
    725 	struct sljit_const* const4;
    726 	void* value;
    727 	sljit_uw const1_addr;
    728 	sljit_uw const2_addr;
    729 	sljit_uw const3_addr;
    730 	sljit_uw const4_addr;
    731 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    732 	sljit_w word_value1 = SLJIT_W(0xaaaaaaaaaaaaaaaa);
    733 	sljit_w word_value2 = SLJIT_W(0xfee1deadfbadf00d);
    734 #else
    735 	sljit_w word_value1 = 0xaaaaaaaal;
    736 	sljit_w word_value2 = 0xfbadf00dl;
    737 #endif
    738 	sljit_w buf[3];
    739 
    740 	FAILED(!compiler, "cannot create compiler\n");
    741 	buf[0] = 0;
    742 	buf[1] = 0;
    743 	buf[2] = 0;
    744 
    745 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    746 
    747 	const1 = sljit_emit_const(compiler, SLJIT_MEM0(), (sljit_w)&buf[0], -0x81b9);
    748 	SLJIT_ASSERT(!sljit_alloc_memory(compiler, 0));
    749 	SLJIT_ASSERT(!sljit_alloc_memory(compiler, 16 * sizeof(sljit_w) + 1));
    750 	value = sljit_alloc_memory(compiler, 16 * sizeof(sljit_w));
    751 	SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
    752 	memset(value, 255, 16 * sizeof(sljit_w));
    753 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
    754 	const2 = sljit_emit_const(compiler, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT - 1, -65535);
    755 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf[0] + 2 * sizeof(sljit_w) - 2);
    756 	const3 = sljit_emit_const(compiler, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, word_value1);
    757 	value = sljit_alloc_memory(compiler, 17);
    758 	SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
    759 	memset(value, 255, 16);
    760 	const4 = sljit_emit_const(compiler, SLJIT_RETURN_REG, 0, 0xf7afcdb7);
    761 
    762 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
    763 
    764 	code.code = sljit_generate_code(compiler);
    765 	CHECK(compiler);
    766 	const1_addr = sljit_get_const_addr(const1);
    767 	const2_addr = sljit_get_const_addr(const2);
    768 	const3_addr = sljit_get_const_addr(const3);
    769 	const4_addr = sljit_get_const_addr(const4);
    770 	sljit_free_compiler(compiler);
    771 
    772 	FAILED(code.func1((sljit_w)&buf) != 0xf7afcdb7, "test11 case 1 failed\n");
    773 	FAILED(buf[0] != -0x81b9, "test11 case 2 failed\n");
    774 	FAILED(buf[1] != -65535, "test11 case 3 failed\n");
    775 	FAILED(buf[2] != word_value1, "test11 case 4 failed\n");
    776 
    777 	sljit_set_const(const1_addr, -1);
    778 	sljit_set_const(const2_addr, word_value2);
    779 	sljit_set_const(const3_addr, 0xbab0fea1);
    780 	sljit_set_const(const4_addr, -60089);
    781 
    782 	FAILED(code.func1((sljit_w)&buf) != -60089, "test11 case 5 failed\n");
    783 	FAILED(buf[0] != -1, "test11 case 6 failed\n");
    784 	FAILED(buf[1] != word_value2, "test11 case 7 failed\n");
    785 	FAILED(buf[2] != 0xbab0fea1, "test11 case 8 failed\n");
    786 
    787 	sljit_free_code(code.code);
    788 	printf("test11 ok\n");
    789 	successful_tests++;
    790 }
    791 
    792 static void test12(void)
    793 {
    794 	/* Test rewriteable jumps. */
    795 	executable_code code;
    796 	struct sljit_compiler* compiler = sljit_create_compiler();
    797 	struct sljit_label *label1;
    798 	struct sljit_label *label2;
    799 	struct sljit_label *label3;
    800 	struct sljit_jump *jump1;
    801 	struct sljit_jump *jump2;
    802 	struct sljit_jump *jump3;
    803 	void* value;
    804 	sljit_uw jump1_addr;
    805 	sljit_uw label1_addr;
    806 	sljit_uw label2_addr;
    807 	sljit_w buf[1];
    808 
    809 	FAILED(!compiler, "cannot create compiler\n");
    810 	buf[0] = 0;
    811 
    812 	sljit_emit_enter(compiler, 2, 3, 2, 0);
    813 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 10);
    814 	jump1 = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_C_SIG_GREATER);
    815 	/* Default handler. */
    816 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 5);
    817 	jump2 = sljit_emit_jump(compiler, SLJIT_JUMP);
    818 	value = sljit_alloc_memory(compiler, 15);
    819 	SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
    820 	memset(value, 255, 15);
    821 	/* Handler 1. */
    822 	label1 = sljit_emit_label(compiler);
    823 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 6);
    824 	jump3 = sljit_emit_jump(compiler, SLJIT_JUMP);
    825 	/* Handler 2. */
    826 	label2 = sljit_emit_label(compiler);
    827 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 7);
    828 	/* Exit. */
    829 	label3 = sljit_emit_label(compiler);
    830 	sljit_set_label(jump2, label3);
    831 	sljit_set_label(jump3, label3);
    832 	/* By default, set to handler 1. */
    833 	sljit_set_label(jump1, label1);
    834 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
    835 
    836 	value = sljit_alloc_memory(compiler, 8);
    837 	SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
    838 	memset(value, 255, 8);
    839 
    840 	code.code = sljit_generate_code(compiler);
    841 	CHECK(compiler);
    842 	jump1_addr = sljit_get_jump_addr(jump1);
    843 	label1_addr = sljit_get_label_addr(label1);
    844 	label2_addr = sljit_get_label_addr(label2);
    845 	sljit_free_compiler(compiler);
    846 
    847 	code.func2((sljit_w)&buf, 4);
    848 	FAILED(buf[0] != 5, "test12 case 1 failed\n");
    849 
    850 	code.func2((sljit_w)&buf, 11);
    851 	FAILED(buf[0] != 6, "test12 case 2 failed\n");
    852 
    853 	sljit_set_jump_addr(jump1_addr, label2_addr);
    854 	code.func2((sljit_w)&buf, 12);
    855 	FAILED(buf[0] != 7, "test12 case 3 failed\n");
    856 
    857 	sljit_set_jump_addr(jump1_addr, label1_addr);
    858 	code.func2((sljit_w)&buf, 13);
    859 	FAILED(buf[0] != 6, "test12 case 4 failed\n");
    860 
    861 	sljit_free_code(code.code);
    862 	printf("test12 ok\n");
    863 	successful_tests++;
    864 }
    865 
    866 static void test13(void)
    867 {
    868 	/* Test fpu monadic functions. */
    869 	executable_code code;
    870 	struct sljit_compiler* compiler = sljit_create_compiler();
    871 	double buf[6];
    872 	sljit_w buf2[6];
    873 
    874 	if (!sljit_is_fpu_available()) {
    875 		printf("no fpu available, test13 skipped\n");
    876 		successful_tests++;
    877 		if (compiler)
    878 			sljit_free_compiler(compiler);
    879 		return;
    880 	}
    881 
    882 	FAILED(!compiler, "cannot create compiler\n");
    883 	buf[0] = 7.75;
    884 	buf[1] = -4.5;
    885 	buf[2] = 0.0;
    886 	buf[3] = 0.0;
    887 	buf[4] = 0.0;
    888 	buf[5] = 0.0;
    889 
    890 	buf2[0] = 10;
    891 	buf2[1] = 10;
    892 	buf2[2] = 10;
    893 	buf2[3] = 10;
    894 	buf2[4] = 10;
    895 	buf2[5] = 10;
    896 
    897 	sljit_emit_enter(compiler, 2, 3, 2, 0);
    898 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM0(), (sljit_w)&buf[2], SLJIT_MEM0(), (sljit_w)&buf[1]);
    899 	sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(double), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
    900 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM0(), (sljit_w)&buf[0]);
    901 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2 * sizeof(double));
    902 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0);
    903 	sljit_emit_fop1(compiler, SLJIT_FNEG, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG1, 0);
    904 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0);
    905 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM0(), (sljit_w)&buf[4], SLJIT_FLOAT_REG4, 0);
    906 	sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG2, 0);
    907 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(double), SLJIT_FLOAT_REG3, 0);
    908 
    909 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    910 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
    911 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_C_FLOAT_GREATER);
    912 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double), SLJIT_FLOAT_REG2, 0);
    913 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w), SLJIT_C_FLOAT_GREATER);
    914 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG2, 0);
    915 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
    916 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS);
    917 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
    918 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 4 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
    919 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 5 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_EQUAL);
    920 
    921 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
    922 
    923 	code.code = sljit_generate_code(compiler);
    924 	CHECK(compiler);
    925 	sljit_free_compiler(compiler);
    926 
    927 	code.func2((sljit_w)&buf, (sljit_w)&buf2);
    928 	FAILED(buf[2] != -4.5, "test13 case 1 failed\n");
    929 	FAILED(buf[3] != 4.5, "test13 case 2 failed\n");
    930 	FAILED(buf[4] != -7.75, "test13 case 3 failed\n");
    931 	FAILED(buf[5] != 4.5, "test13 case 4 failed\n");
    932 
    933 	FAILED(buf2[0] != 1, "test13 case 5 failed\n");
    934 	FAILED(buf2[1] != 0, "test13 case 6 failed\n");
    935 	FAILED(buf2[2] != 1, "test13 case 7 failed\n");
    936 	FAILED(buf2[3] != 0, "test13 case 8 failed\n");
    937 	FAILED(buf2[4] != 0, "test13 case 9 failed\n");
    938 	FAILED(buf2[5] != 1, "test13 case 10 failed\n");
    939 
    940 	sljit_free_code(code.code);
    941 	printf("test13 ok\n");
    942 	successful_tests++;
    943 }
    944 
    945 static void test14(void)
    946 {
    947 	/* Test fpu diadic functions. */
    948 	executable_code code;
    949 	struct sljit_compiler* compiler = sljit_create_compiler();
    950 	double buf[15];
    951 
    952 	if (!sljit_is_fpu_available()) {
    953 		printf("no fpu available, test14 skipped\n");
    954 		successful_tests++;
    955 		if (compiler)
    956 			sljit_free_compiler(compiler);
    957 		return;
    958 	}
    959 	buf[0] = 7.25;
    960 	buf[1] = 3.5;
    961 	buf[2] = 1.75;
    962 	buf[3] = 0.0;
    963 	buf[4] = 0.0;
    964 	buf[5] = 0.0;
    965 	buf[6] = 0.0;
    966 	buf[7] = 0.0;
    967 	buf[8] = 0.0;
    968 	buf[9] = 0.0;
    969 	buf[10] = 0.0;
    970 	buf[11] = 0.0;
    971 	buf[12] = 8.0;
    972 	buf[13] = 4.0;
    973 	buf[14] = 0.0;
    974 
    975 	FAILED(!compiler, "cannot create compiler\n");
    976 	sljit_emit_enter(compiler, 1, 3, 1, 0);
    977 
    978 	/* ADD */
    979 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(double));
    980 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
    981 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
    982 	sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 3, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    983 	sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
    984 	sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
    985 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 4, SLJIT_FLOAT_REG1, 0);
    986 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 5, SLJIT_FLOAT_REG2, 0);
    987 
    988 	/* SUB */
    989 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
    990 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG4, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
    991 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 2);
    992 	sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 6, SLJIT_FLOAT_REG4, 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_FLOAT_SHIFT);
    993 	sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
    994 	sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG4, 0);
    995 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 7, SLJIT_FLOAT_REG3, 0);
    996 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 8, SLJIT_FLOAT_REG4, 0);
    997 
    998 	/* MUL */
    999 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
   1000 	sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 9, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_FLOAT_SHIFT, SLJIT_FLOAT_REG2, 0);
   1001 	sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
   1002 	sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2, SLJIT_FLOAT_REG3, 0);
   1003 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 10, SLJIT_FLOAT_REG2, 0);
   1004 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 11, SLJIT_FLOAT_REG3, 0);
   1005 
   1006 	/* DIV */
   1007 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12);
   1008 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 13);
   1009 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG1, 0);
   1010 	sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12, SLJIT_FLOAT_REG2, 0);
   1011 	sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
   1012 	sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
   1013 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 13, SLJIT_FLOAT_REG1, 0);
   1014 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 14, SLJIT_FLOAT_REG3, 0);
   1015 
   1016 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1017 
   1018 	code.code = sljit_generate_code(compiler);
   1019 	CHECK(compiler);
   1020 	sljit_free_compiler(compiler);
   1021 
   1022 	code.func1((sljit_w)&buf);
   1023 	FAILED(buf[3] != 10.75, "test14 case 1 failed\n");
   1024 	FAILED(buf[4] != 5.25, "test14 case 2 failed\n");
   1025 	FAILED(buf[5] != 7.0, "test14 case 3 failed\n");
   1026 	FAILED(buf[6] != 0.0, "test14 case 4 failed\n");
   1027 	FAILED(buf[7] != 5.5, "test14 case 5 failed\n");
   1028 	FAILED(buf[8] != 3.75, "test14 case 6 failed\n");
   1029 	FAILED(buf[9] != 24.5, "test14 case 7 failed\n");
   1030 	FAILED(buf[10] != 38.5, "test14 case 8 failed\n");
   1031 	FAILED(buf[11] != 9.625, "test14 case 9 failed\n");
   1032 	FAILED(buf[12] != 2.0, "test14 case 10 failed\n");
   1033 	FAILED(buf[13] != 2.0, "test14 case 11 failed\n");
   1034 	FAILED(buf[14] != 0.5, "test14 case 11 failed\n");
   1035 
   1036 	sljit_free_code(code.code);
   1037 	printf("test14 ok\n");
   1038 	successful_tests++;
   1039 }
   1040 
   1041 static sljit_w SLJIT_CALL func(sljit_w a, sljit_w b, sljit_w c)
   1042 {
   1043 	return a + b + c + 5;
   1044 }
   1045 
   1046 static void test15(void)
   1047 {
   1048 	/* Test function call. */
   1049 	executable_code code;
   1050 	struct sljit_compiler* compiler = sljit_create_compiler();
   1051 	struct sljit_jump* jump;
   1052 	sljit_w buf[7];
   1053 
   1054 	FAILED(!compiler, "cannot create compiler\n");
   1055 	buf[0] = 0;
   1056 	buf[1] = 0;
   1057 	buf[2] = 0;
   1058 	buf[3] = 0;
   1059 	buf[4] = 0;
   1060 	buf[5] = 0;
   1061 	buf[6] = SLJIT_FUNC_OFFSET(func);
   1062 
   1063 	sljit_emit_enter(compiler, 1, 4, 1, 0);
   1064 
   1065 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   1066 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 7);
   1067 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -3);
   1068 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
   1069 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_RETURN_REG, 0);
   1070 
   1071 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
   1072 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -10);
   1073 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 2);
   1074 	jump = sljit_emit_jump(compiler, SLJIT_CALL3 | SLJIT_REWRITABLE_JUMP);
   1075 	sljit_set_target(jump, (sljit_w)-1);
   1076 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1077 
   1078 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
   1079 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 40);
   1080 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -3);
   1081 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG1, 0);
   1082 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1083 
   1084 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -60);
   1085 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
   1086 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -30);
   1087 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG2, 0);
   1088 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1089 
   1090 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 10);
   1091 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 16);
   1092 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
   1093 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG3, 0);
   1094 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1095 
   1096 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
   1097 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 110);
   1098 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 120);
   1099 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
   1100 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_EREG1, 0);
   1101 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1102 
   1103 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -10);
   1104 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -16);
   1105 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 6);
   1106 	sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w));
   1107 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
   1108 
   1109 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   1110 
   1111 	code.code = sljit_generate_code(compiler);
   1112 	CHECK(compiler);
   1113 	sljit_set_jump_addr(sljit_get_jump_addr(jump), SLJIT_FUNC_OFFSET(func));
   1114 	sljit_free_compiler(compiler);
   1115 
   1116 	FAILED(code.func1((sljit_w)&buf) != -15, "test15 case 1 failed\n");
   1117 	FAILED(buf[0] != 14, "test15 case 2 failed\n");
   1118 	FAILED(buf[1] != -8, "test15 case 3 failed\n");
   1119 	FAILED(buf[2] != SLJIT_FUNC_OFFSET(func) + 42, "test15 case 4 failed\n");
   1120 	FAILED(buf[3] != SLJIT_FUNC_OFFSET(func) - 85, "test15 case 5 failed\n");
   1121 	FAILED(buf[4] != SLJIT_FUNC_OFFSET(func) + 31, "test15 case 6 failed\n");
   1122 	FAILED(buf[5] != 335, "test15 case 7 failed\n");
   1123 	FAILED(buf[6] != -15, "test15 case 8 failed\n");
   1124 
   1125 	sljit_free_code(code.code);
   1126 	printf("test15 ok\n");
   1127 	successful_tests++;
   1128 }
   1129 
   1130 static void test16(void)
   1131 {
   1132 	/* Ackermann benchmark. */
   1133 	executable_code code;
   1134 	struct sljit_compiler* compiler = sljit_create_compiler();
   1135 	struct sljit_label *entry;
   1136 	struct sljit_label *label;
   1137 	struct sljit_jump *jump;
   1138 	struct sljit_jump *jump1;
   1139 	struct sljit_jump *jump2;
   1140 
   1141 	FAILED(!compiler, "cannot create compiler\n");
   1142 
   1143 	entry = sljit_emit_label(compiler);
   1144 	sljit_emit_enter(compiler, 2, 3, 2, 0);
   1145 	/* If x == 0. */
   1146 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0);
   1147 	jump1 = sljit_emit_jump(compiler, SLJIT_C_EQUAL);
   1148 	/* If y == 0. */
   1149 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0);
   1150 	jump2 = sljit_emit_jump(compiler, SLJIT_C_EQUAL);
   1151 
   1152 	/* Ack(x,y-1). */
   1153 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
   1154 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
   1155 	jump = sljit_emit_jump(compiler, SLJIT_CALL2);
   1156 	sljit_set_label(jump, entry);
   1157 
   1158 	/* Returns with Ack(x-1, Ack(x,y-1)). */
   1159 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_RETURN_REG, 0);
   1160 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
   1161 	jump = sljit_emit_jump(compiler, SLJIT_CALL2);
   1162 	sljit_set_label(jump, entry);
   1163 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   1164 
   1165 	/* Returns with y+1. */
   1166 	label = sljit_emit_label(compiler);
   1167 	sljit_set_label(jump1, label);
   1168 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1, SLJIT_SAVED_REG2, 0);
   1169 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   1170 
   1171 	/* Returns with Ack(x-1,1) */
   1172 	label = sljit_emit_label(compiler);
   1173 	sljit_set_label(jump2, label);
   1174 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
   1175 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
   1176 	jump = sljit_emit_jump(compiler, SLJIT_CALL2);
   1177 	sljit_set_label(jump, entry);
   1178 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   1179 
   1180 	code.code = sljit_generate_code(compiler);
   1181 	CHECK(compiler);
   1182 	sljit_free_compiler(compiler);
   1183 
   1184 	FAILED(code.func2(3, 3) != 61, "test16 case 1 failed\n");
   1185 	/* For benchmarking. */
   1186 	/* FAILED(code.func2(3, 11) != 16381, "test16 case 1 failed\n"); */
   1187 
   1188 	sljit_free_code(code.code);
   1189 	printf("test16 ok\n");
   1190 	successful_tests++;
   1191 }
   1192 
   1193 static void test17(void)
   1194 {
   1195 	/* Test arm constant pool. */
   1196 	executable_code code;
   1197 	struct sljit_compiler* compiler = sljit_create_compiler();
   1198 	int i;
   1199 	sljit_w buf[5];
   1200 
   1201 	FAILED(!compiler, "cannot create compiler\n");
   1202 	buf[0] = 0;
   1203 	buf[1] = 0;
   1204 	buf[2] = 0;
   1205 	buf[3] = 0;
   1206 	buf[4] = 0;
   1207 
   1208 	sljit_emit_enter(compiler, 1, 3, 1, 0);
   1209 	for (i = 0; i <= 0xfff; i++) {
   1210 		sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x81818000 | i);
   1211 		sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x81818000 | i);
   1212 		if ((i & 0x3ff) == 0)
   1213 			sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), (i >> 10) * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1214 	}
   1215 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1216 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1217 
   1218 	code.code = sljit_generate_code(compiler);
   1219 	CHECK(compiler);
   1220 	sljit_free_compiler(compiler);
   1221 
   1222 	code.func1((sljit_w)&buf);
   1223 	FAILED((sljit_uw)buf[0] != 0x81818000, "test17 case 1 failed\n");
   1224 	FAILED((sljit_uw)buf[1] != 0x81818400, "test17 case 2 failed\n");
   1225 	FAILED((sljit_uw)buf[2] != 0x81818800, "test17 case 3 failed\n");
   1226 	FAILED((sljit_uw)buf[3] != 0x81818c00, "test17 case 4 failed\n");
   1227 	FAILED((sljit_uw)buf[4] != 0x81818fff, "test17 case 5 failed\n");
   1228 
   1229 	sljit_free_code(code.code);
   1230 	printf("test17 ok\n");
   1231 	successful_tests++;
   1232 }
   1233 
   1234 static void test18(void)
   1235 {
   1236 	/* Test 64 bit. */
   1237 	executable_code code;
   1238 	struct sljit_compiler* compiler = sljit_create_compiler();
   1239 	sljit_w buf[11];
   1240 
   1241 	FAILED(!compiler, "cannot create compiler\n");
   1242 	buf[0] = 0;
   1243 	buf[1] = 0;
   1244 	buf[2] = 0;
   1245 	buf[3] = 0;
   1246 	buf[4] = 0;
   1247 	buf[5] = 100;
   1248 	buf[6] = 100;
   1249 	buf[7] = 100;
   1250 	buf[8] = 100;
   1251 	buf[9] = 0;
   1252 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
   1253 	buf[10] = SLJIT_W(1) << 32;
   1254 #else
   1255 	buf[10] = 1;
   1256 #endif
   1257 
   1258 	sljit_emit_enter(compiler, 1, 3, 2, 0);
   1259 
   1260 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1261 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, SLJIT_W(0x1122334455667788));
   1262 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x1122334455667788));
   1263 
   1264 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(1000000000000));
   1265 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(1000000000000));
   1266 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, SLJIT_W(5000000000000), SLJIT_TEMPORARY_REG1, 0);
   1267 
   1268 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
   1269 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
   1270 
   1271 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
   1272 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
   1273 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_C_ZERO);
   1274 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_SAVED_REG2, 0);
   1275 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
   1276 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_ZERO);
   1277 
   1278 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
   1279 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x2208080808));
   1280 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_LESS);
   1281 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1104040404));
   1282 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_NOT_ZERO);
   1283 
   1284 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
   1285 	sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_IMM, SLJIT_W(0xffff0000), SLJIT_TEMPORARY_REG1, 0);
   1286 
   1287 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_IMM, -1);
   1288 #else
   1289 	/* 32 bit operations. */
   1290 
   1291 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0x11223344);
   1292 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 0x44332211);
   1293 
   1294 #endif
   1295 
   1296 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1297 
   1298 	code.code = sljit_generate_code(compiler);
   1299 	CHECK(compiler);
   1300 	sljit_free_compiler(compiler);
   1301 
   1302 	code.func1((sljit_w)&buf);
   1303 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1304 	FAILED(buf[0] != SLJIT_W(0x1122334455667788), "test18 case 1 failed\n");
   1305 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
   1306 	FAILED(buf[1] != 0x55667788, "test18 case 2 failed\n");
   1307 #else
   1308 	FAILED(buf[1] != SLJIT_W(0x5566778800000000), "test18 case 2 failed\n");
   1309 #endif
   1310 	FAILED(buf[2] != SLJIT_W(2000000000000), "test18 case 3 failed\n");
   1311 	FAILED(buf[3] != SLJIT_W(4000000000000), "test18 case 4 failed\n");
   1312 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
   1313 	FAILED(buf[4] != 0x28282828, "test18 case 5 failed\n");
   1314 #else
   1315 	FAILED(buf[4] != SLJIT_W(0x2828282800000000), "test18 case 5 failed\n");
   1316 #endif
   1317 	FAILED(buf[5] != 0, "test18 case 6 failed\n");
   1318 	FAILED(buf[6] != 1, "test18 case 7 failed\n");
   1319 	FAILED(buf[7] != 1, "test18 case 8 failed\n");
   1320 	FAILED(buf[8] != 0, "test18 case 9 failed\n");
   1321 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
   1322 	FAILED(buf[9] != 0xfff00000, "test18 case 10 failed\n");
   1323 	FAILED(buf[10] != 0xffffffff, "test18 case 11 failed\n");
   1324 #else
   1325 	FAILED(buf[9] != SLJIT_W(0xfff0000000000000), "test18 case 10 failed\n");
   1326 	FAILED(buf[10] != SLJIT_W(0xffffffff00000000), "test18 case 11 failed\n");
   1327 #endif
   1328 #else
   1329 	FAILED(buf[0] != 0x11223344, "test18 case 1 failed\n");
   1330 	FAILED(buf[1] != 0x44332211, "test18 case 2 failed\n");
   1331 #endif
   1332 
   1333 	sljit_free_code(code.code);
   1334 	printf("test18 ok\n");
   1335 	successful_tests++;
   1336 }
   1337 
   1338 static void test19(void)
   1339 {
   1340 	/* Test arm partial instruction caching. */
   1341 	executable_code code;
   1342 	struct sljit_compiler* compiler = sljit_create_compiler();
   1343 	sljit_w buf[10];
   1344 
   1345 	FAILED(!compiler, "cannot create compiler\n");
   1346 	buf[0] = 6;
   1347 	buf[1] = 4;
   1348 	buf[2] = 0;
   1349 	buf[3] = 0;
   1350 	buf[4] = 0;
   1351 	buf[5] = 0;
   1352 	buf[6] = 2;
   1353 	buf[7] = 0;
   1354 
   1355 	sljit_emit_enter(compiler, 1, 3, 1, 0);
   1356 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
   1357 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1358 	SLJIT_ASSERT(compiler->cache_arg == 0);
   1359 #endif
   1360 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM0(), (sljit_w)&buf[2], SLJIT_MEM0(), (sljit_w)&buf[1], SLJIT_MEM0(), (sljit_w)&buf[0]);
   1361 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1362 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1363 #endif
   1364 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   1365 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
   1366 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[0], SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[0]);
   1367 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1368 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1369 #endif
   1370 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_IMM, 2);
   1371 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1372 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1373 #endif
   1374 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[0] + 4 * sizeof(sljit_w));
   1375 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1376 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1377 #endif
   1378 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_IMM, 10);
   1379 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
   1380 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[5], SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[5]);
   1381 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1382 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1383 #endif
   1384 
   1385 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1386 
   1387 	code.code = sljit_generate_code(compiler);
   1388 	CHECK(compiler);
   1389 	sljit_free_compiler(compiler);
   1390 
   1391 	code.func1((sljit_w)&buf);
   1392 	FAILED(buf[0] != 10, "test19 case 1 failed\n");
   1393 	FAILED(buf[1] != 4, "test19 case 2 failed\n");
   1394 	FAILED(buf[2] != 14, "test19 case 3 failed\n");
   1395 	FAILED(buf[3] != 14, "test19 case 4 failed\n");
   1396 	FAILED(buf[4] != 8, "test19 case 5 failed\n");
   1397 	FAILED(buf[5] != 6, "test19 case 6 failed\n");
   1398 	FAILED(buf[6] != 12, "test19 case 7 failed\n");
   1399 	FAILED(buf[7] != 10, "test19 case 8 failed\n");
   1400 
   1401 	sljit_free_code(code.code);
   1402 	printf("test19 ok\n");
   1403 	successful_tests++;
   1404 }
   1405 
   1406 static void test20(void)
   1407 {
   1408 	/* Test stack. */
   1409 	executable_code code;
   1410 	struct sljit_compiler* compiler = sljit_create_compiler();
   1411 	struct sljit_jump* jump;
   1412 	struct sljit_label* label;
   1413 	sljit_w buf[6];
   1414 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1415 	sljit_w offset_value = SLJIT_W(0x1234567812345678);
   1416 #else
   1417 	sljit_w offset_value = SLJIT_W(0x12345678);
   1418 #endif
   1419 
   1420 	FAILED(!compiler, "cannot create compiler\n");
   1421 	buf[0] = 5;
   1422 	buf[1] = 12;
   1423 	buf[2] = 0;
   1424 	buf[3] = 0;
   1425 	buf[4] = 111;
   1426 	buf[5] = -12345;
   1427 
   1428 	sljit_emit_enter(compiler, 1, 5, 5, 4 * sizeof(sljit_w));
   1429 
   1430 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw), SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   1431 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw));
   1432 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, -1);
   1433 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, -1);
   1434 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, -1);
   1435 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, -1);
   1436 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw));
   1437 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   1438 	sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG1, 0, -offset_value);
   1439 	sljit_get_local_base(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, -0x1234);
   1440 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   1441 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_TEMPORARY_REG1), offset_value, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0x1234 + sizeof(sljit_w));
   1442 
   1443 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_uw));
   1444 	/* Dummy last instructions. */
   1445 	sljit_emit_const(compiler, SLJIT_TEMPORARY_REG1, 0, -9);
   1446 	sljit_emit_label(compiler);
   1447 
   1448 	code.code = sljit_generate_code(compiler);
   1449 	CHECK(compiler);
   1450 	sljit_free_compiler(compiler);
   1451 
   1452 	FAILED(code.func1((sljit_w)&buf) != -12345, "test20 case 1 failed\n")
   1453 
   1454 	FAILED(buf[2] != 60, "test20 case 2 failed\n");
   1455 	FAILED(buf[3] != 17, "test20 case 3 failed\n");
   1456 	FAILED(buf[4] != 7, "test20 case 4 failed\n");
   1457 	sljit_free_code(code.code);
   1458 
   1459 	compiler = sljit_create_compiler();
   1460 	sljit_emit_enter(compiler, 0, 3, 0, SLJIT_MAX_LOCAL_SIZE);
   1461 
   1462 	sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG1, 0, SLJIT_MAX_LOCAL_SIZE - sizeof(sljit_w));
   1463 	sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG2, 0, -(sljit_w)sizeof(sljit_w));
   1464 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -1);
   1465 	label = sljit_emit_label(compiler);
   1466 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
   1467 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
   1468 	jump = sljit_emit_jump(compiler, SLJIT_C_NOT_EQUAL);
   1469 	sljit_set_label(jump, label);
   1470 
   1471 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1472 
   1473 	code.code = sljit_generate_code(compiler);
   1474 	CHECK(compiler);
   1475 	sljit_free_compiler(compiler);
   1476 
   1477 	/* Just survive this code. */
   1478 	code.func0();
   1479 
   1480 	sljit_free_code(code.code);
   1481 	printf("test20 ok\n");
   1482 	successful_tests++;
   1483 }
   1484 
   1485 static void test21(void)
   1486 {
   1487 	/* Test fake enter. The parts of the jit code can be separated in the memory. */
   1488 	executable_code code1;
   1489 	executable_code code2;
   1490 	struct sljit_compiler* compiler = sljit_create_compiler();
   1491 	struct sljit_jump* jump;
   1492 	sljit_uw addr;
   1493 	sljit_w buf[4];
   1494 
   1495 	FAILED(!compiler, "cannot create compiler\n");
   1496 	buf[0] = 9;
   1497 	buf[1] = -6;
   1498 	buf[2] = 0;
   1499 	buf[3] = 0;
   1500 
   1501 	sljit_emit_enter(compiler, 1, 3, 2, 2 * sizeof(sljit_w));
   1502 
   1503 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_IMM, 10);
   1504 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   1505 	jump = sljit_emit_jump(compiler, SLJIT_JUMP | SLJIT_REWRITABLE_JUMP);
   1506 	sljit_set_target(jump, 0);
   1507 
   1508 	code1.code = sljit_generate_code(compiler);
   1509 	CHECK(compiler);
   1510 	addr = sljit_get_jump_addr(jump);
   1511 	sljit_free_compiler(compiler);
   1512 
   1513 	compiler = sljit_create_compiler();
   1514 	FAILED(!compiler, "cannot create compiler\n");
   1515 
   1516 	/* Other part of the jit code. */
   1517 	sljit_set_context(compiler, 1, 3, 2, 2 * sizeof(sljit_w));
   1518 
   1519 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   1520 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   1521 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
   1522 
   1523 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   1524 
   1525 	code2.code = sljit_generate_code(compiler);
   1526 	CHECK(compiler);
   1527 	sljit_free_compiler(compiler);
   1528 
   1529 	sljit_set_jump_addr(addr, SLJIT_FUNC_OFFSET(code2.code));
   1530 
   1531 	FAILED(code1.func1((sljit_w)&buf) != 19, "test21 case 1 failed\n");
   1532 	FAILED(buf[2] != -16, "test21 case 2 failed\n");
   1533 	FAILED(buf[3] != 100, "test21 case 3 failed\n");
   1534 
   1535 	sljit_free_code(code1.code);
   1536 	sljit_free_code(code2.code);
   1537 	printf("test21 ok\n");
   1538 	successful_tests++;
   1539 }
   1540 
   1541 static void test22(void)
   1542 {
   1543 	/* Test simple byte and half-int data transfers. */
   1544 	executable_code code;
   1545 	struct sljit_compiler* compiler = sljit_create_compiler();
   1546 	sljit_w buf[9];
   1547 	short sbuf[7];
   1548 	signed char bbuf[5];
   1549 
   1550 	FAILED(!compiler, "cannot create compiler\n");
   1551 	buf[0] = 5;
   1552 	buf[1] = 0;
   1553 	buf[2] = 0;
   1554 	buf[3] = 0;
   1555 	buf[4] = 0;
   1556 	buf[5] = 0;
   1557 	buf[6] = 0;
   1558 	buf[7] = 0;
   1559 	buf[8] = 0;
   1560 
   1561 	sbuf[0] = 0;
   1562 	sbuf[1] = 0;
   1563 	sbuf[2] = -9;
   1564 	sbuf[3] = 0;
   1565 	sbuf[4] = 0;
   1566 	sbuf[5] = 0;
   1567 	sbuf[6] = 0;
   1568 
   1569 	bbuf[0] = 0;
   1570 	bbuf[1] = 0;
   1571 	bbuf[2] = -56;
   1572 	bbuf[3] = 0;
   1573 	bbuf[4] = 0;
   1574 
   1575 	sljit_emit_enter(compiler, 3, 3, 3, 0);
   1576 
   1577 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
   1578 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0);
   1579 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_IMM, -13);
   1580 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w));
   1581 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
   1582 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w));
   1583 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   1584 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_TEMPORARY_REG2, 0);
   1585 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
   1586 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
   1587 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
   1588 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_TEMPORARY_REG2, 0);
   1589 
   1590 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -13);
   1591 	sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_IMM, 0x1234);
   1592 	sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short));
   1593 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1594 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_MEM1(SLJIT_SAVED_REG2), -(int)sizeof(short));
   1595 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff0000 + 8000);
   1596 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 2);
   1597 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
   1598 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 3);
   1599 	sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
   1600 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -9317);
   1601 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 5 * sizeof(short));
   1602 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
   1603 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1);
   1604 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_TEMPORARY_REG2, 0);
   1605 
   1606 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_MEM1(SLJIT_SAVED_REG3), 0, SLJIT_IMM, -45);
   1607 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char), SLJIT_IMM, 0x12);
   1608 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2 * sizeof(char));
   1609 	sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char));
   1610 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
   1611 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0);
   1612 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG2, 0);
   1613 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
   1614 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char), SLJIT_SAVED_REG2, 0);
   1615 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM2(SLJIT_SAVED_REG3, SLJIT_TEMPORARY_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
   1616 
   1617 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1618 
   1619 	code.code = sljit_generate_code(compiler);
   1620 	CHECK(compiler);
   1621 	sljit_free_compiler(compiler);
   1622 
   1623 	code.func3((sljit_w)&buf, (sljit_w)&sbuf, (sljit_w)&bbuf);
   1624 	FAILED(buf[1] != -13, "test22 case 1 failed\n");
   1625 	FAILED(buf[2] != 5, "test22 case 2 failed\n");
   1626 	FAILED(buf[3] != -13, "test22 case 3 failed\n");
   1627 	FAILED(buf[4] != (sljit_w)&buf[3], "test22 case 4 failed\n");
   1628 	FAILED(buf[5] != (sljit_w)&buf[4], "test22 case 5 failed\n");
   1629 	FAILED(buf[6] != (sljit_w)&buf[4], "test22 case 6 failed\n");
   1630 	FAILED(buf[7] != -9, "test22 case 7 failed\n");
   1631 	FAILED(buf[8] != -56, "test22 case 8 failed\n");
   1632 
   1633 	FAILED(sbuf[0] != -13, "test22 case 9 failed\n");
   1634 	FAILED(sbuf[1] != 0x1234, "test22 case 10 failed\n");
   1635 	FAILED(sbuf[3] != 0x1234, "test22 case 11 failed\n");
   1636 	FAILED(sbuf[4] != 8000, "test22 case 12 failed\n");
   1637 	FAILED(sbuf[5] != -9317, "test22 case 13 failed\n");
   1638 	FAILED(sbuf[6] != -9317, "test22 case 14 failed\n");
   1639 
   1640 	FAILED(bbuf[0] != -45, "test22 case 15 failed\n");
   1641 	FAILED(bbuf[1] != 0x12, "test22 case 16 failed\n");
   1642 	FAILED(bbuf[3] != -56, "test22 case 17 failed\n");
   1643 	FAILED(bbuf[4] != 2, "test22 case 18 failed\n");
   1644 
   1645 	sljit_free_code(code.code);
   1646 	printf("test22 ok\n");
   1647 	successful_tests++;
   1648 }
   1649 
   1650 static void test23(void)
   1651 {
   1652 	/* Test 32 bit / 64 bit signed / unsigned int transfer and conversion.
   1653 	   This test has do real things on 64 bit systems, but works on 32 bit systems as well. */
   1654 	executable_code code;
   1655 	struct sljit_compiler* compiler = sljit_create_compiler();
   1656 	sljit_w buf[9];
   1657 	int ibuf[5];
   1658 	union {
   1659 		int asint;
   1660 		sljit_ub asbytes[4];
   1661 	} u;
   1662 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1663 	sljit_w garbage = SLJIT_W(0x1234567812345678);
   1664 #else
   1665 	sljit_w garbage = 0x12345678;
   1666 #endif
   1667 
   1668 	FAILED(!compiler, "cannot create compiler\n");
   1669 	buf[0] = 0;
   1670 	buf[1] = 0;
   1671 	buf[2] = 0;
   1672 	buf[3] = 0;
   1673 	buf[4] = 0;
   1674 	buf[5] = 0;
   1675 	buf[6] = 0;
   1676 	buf[7] = 0;
   1677 	buf[8] = 0;
   1678 
   1679 	ibuf[0] = 0;
   1680 	ibuf[1] = 0;
   1681 	ibuf[2] = -5791;
   1682 	ibuf[3] = 43579;
   1683 	ibuf[4] = 658923;
   1684 
   1685 	sljit_emit_enter(compiler, 2, 3, 3, 0);
   1686 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, 34567);
   1687 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   1688 	sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), 2, SLJIT_IMM, -7654);
   1689 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
   1690 	sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
   1691 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
   1692 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
   1693 	sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
   1694 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1695 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
   1696 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
   1697 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   1698 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1699 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x0f00f00);
   1700 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0x7777);
   1701 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 0x7777 + 2 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1702 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0x7777);
   1703 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), -0x7777 + (int)sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1704 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 16 - sizeof(sljit_w));
   1705 	sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
   1706 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
   1707 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
   1708 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_IMM, 64, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0);
   1709 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   1710 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[6], SLJIT_MEM0(), (sljit_w)&buf[6]);
   1711 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_IMM, 0x123456);
   1712 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_REG1, 0);
   1713 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, sizeof(sljit_w));
   1714 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 100000 * sizeof(sljit_w));
   1715 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 100001 * sizeof(sljit_w), SLJIT_SAVED_REG1, 0);
   1716 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, sizeof(sljit_w));
   1717 	sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int), SLJIT_IMM, 0x12345678);
   1718 
   1719 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x2bd700 | 243);
   1720 	sljit_emit_return(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG2, 0);
   1721 
   1722 	code.code = sljit_generate_code(compiler);
   1723 	CHECK(compiler);
   1724 	sljit_free_compiler(compiler);
   1725 
   1726 	FAILED(code.func2((sljit_w)&buf, (sljit_w)&ibuf) != -13, "test23 case 1 failed\n");
   1727 	FAILED(buf[0] != -5791, "test23 case 2 failed\n");
   1728 	FAILED(buf[1] != 43579, "test23 case 3 failed\n");
   1729 	FAILED(buf[2] != 658923, "test23 case 4 failed\n");
   1730 	FAILED(buf[3] != 0x0f00f00, "test23 case 5 failed\n");
   1731 	FAILED(buf[4] != 0x0f00f00, "test23 case 6 failed\n");
   1732 	FAILED(buf[5] != 80, "test23 case 7 failed\n");
   1733 	FAILED(buf[6] != 0x123456, "test23 case 8 failed\n");
   1734 	FAILED(buf[7] != (sljit_w)&buf[5], "test23 case 9 failed\n");
   1735 	FAILED(buf[8] != (sljit_w)&buf[8] - 100000 * sizeof(sljit_w), "test23 case 10 failed\n");
   1736 
   1737 	FAILED(ibuf[0] != 34567, "test23 case 11 failed\n");
   1738 	FAILED(ibuf[1] != -7654, "test23 case 12 failed\n");
   1739 	u.asint = ibuf[4];
   1740 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
   1741 	FAILED(u.asbytes[0] != 0x78, "test23 case 13 failed\n");
   1742 	FAILED(u.asbytes[1] != 0x56, "test23 case 14 failed\n");
   1743 	FAILED(u.asbytes[2] != 0x34, "test23 case 15 failed\n");
   1744 	FAILED(u.asbytes[3] != 0x12, "test23 case 16 failed\n");
   1745 #else
   1746 	FAILED(u.asbytes[0] != 0x12, "test23 case 13 failed\n");
   1747 	FAILED(u.asbytes[1] != 0x34, "test23 case 14 failed\n");
   1748 	FAILED(u.asbytes[2] != 0x56, "test23 case 15 failed\n");
   1749 	FAILED(u.asbytes[3] != 0x78, "test23 case 16 failed\n");
   1750 #endif
   1751 
   1752 	sljit_free_code(code.code);
   1753 	printf("test23 ok\n");
   1754 	successful_tests++;
   1755 }
   1756 
   1757 static void test24(void)
   1758 {
   1759 	/* Some complicated addressing modes. */
   1760 	executable_code code;
   1761 	struct sljit_compiler* compiler = sljit_create_compiler();
   1762 	sljit_w buf[6];
   1763 	short sbuf[5];
   1764 	sljit_b bbuf[4];
   1765 
   1766 	FAILED(!compiler, "cannot create compiler\n");
   1767 
   1768 	buf[0] = 100567;
   1769 	buf[1] = 75799;
   1770 	buf[2] = 0;
   1771 	buf[3] = -8;
   1772 	buf[4] = -50;
   1773 	buf[5] = 0;
   1774 
   1775 	sbuf[0] = 30000;
   1776 	sbuf[1] = 0;
   1777 	sbuf[2] = 0;
   1778 	sbuf[3] = -12345;
   1779 	sbuf[4] = 0;
   1780 
   1781 	bbuf[0] = -128;
   1782 	bbuf[1] = 0;
   1783 	bbuf[2] = 0;
   1784 	bbuf[3] = 99;
   1785 
   1786 	sljit_emit_enter(compiler, 3, 3, 3, 0);
   1787 
   1788 	/* Nothing should be updated. */
   1789 	sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_MEM0(), (sljit_w)&sbuf[1], SLJIT_MEM0(), (sljit_w)&sbuf[0]);
   1790 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1791 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1792 #endif
   1793 	sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_MEM0(), (sljit_w)&bbuf[1], SLJIT_MEM0(), (sljit_w)&bbuf[0]);
   1794 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1795 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1796 #endif
   1797 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
   1798 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM0(), (sljit_w)&sbuf[3]);
   1799 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1800 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1801 #endif
   1802 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf[0]);
   1803 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
   1804 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 2);
   1805 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 0);
   1806 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1807 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1808 #endif
   1809 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(signed char));
   1810 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(signed char));
   1811 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&bbuf[1], SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&bbuf[0]);
   1812 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1813 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1814 #endif
   1815 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 2 * sizeof(signed char));
   1816 
   1817 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(short));
   1818 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&sbuf[3], SLJIT_TEMPORARY_REG2, 0);
   1819 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
   1820 	SLJIT_ASSERT(compiler->cache_arg == 0);
   1821 #endif
   1822 
   1823 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
   1824 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
   1825 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   1826 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1827 #endif
   1828 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
   1829 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0);
   1830 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
   1831 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   1832 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1833 #endif
   1834 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
   1835 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
   1836 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 4);
   1837 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT);
   1838 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   1839 	SLJIT_ASSERT(compiler->cache_arg > 0);
   1840 #endif
   1841 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   1842 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   1843 
   1844 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1845 
   1846 	code.code = sljit_generate_code(compiler);
   1847 	CHECK(compiler);
   1848 	sljit_free_compiler(compiler);
   1849 
   1850 	code.func3((sljit_w)&buf, (sljit_w)&sbuf, (sljit_w)&bbuf);
   1851 	FAILED(buf[2] != 176366, "test24 case 1 failed\n");
   1852 	FAILED(buf[3] != 64, "test24 case 2 failed\n");
   1853 	FAILED(buf[4] != -100, "test24 case 3 failed\n");
   1854 	FAILED(buf[5] != -100 + (sljit_w)&buf[5] + (sljit_w)&buf[4], "test24 case 4 failed\n");
   1855 
   1856 	FAILED(sbuf[1] != 30000, "test24 case 5 failed\n");
   1857 	FAILED(sbuf[2] != -12345, "test24 case 6 failed\n");
   1858 	FAILED(sbuf[4] != sizeof(short), "test24 case 7 failed\n");
   1859 
   1860 	FAILED(bbuf[1] != -128, "test24 case 8 failed\n");
   1861 	FAILED(bbuf[2] != 99, "test24 case 9 failed\n");
   1862 
   1863 	sljit_free_code(code.code);
   1864 	printf("test24 ok\n");
   1865 	successful_tests++;
   1866 }
   1867 
   1868 static void test25(void)
   1869 {
   1870 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1871 	/* 64 bit loads. */
   1872 	executable_code code;
   1873 	struct sljit_compiler* compiler = sljit_create_compiler();
   1874 	sljit_w buf[14];
   1875 
   1876 	FAILED(!compiler, "cannot create compiler\n");
   1877 	buf[0] = 7;
   1878 	buf[1] = 0;
   1879 	buf[2] = 0;
   1880 	buf[3] = 0;
   1881 	buf[4] = 0;
   1882 	buf[5] = 0;
   1883 	buf[6] = 0;
   1884 	buf[7] = 0;
   1885 	buf[8] = 0;
   1886 	buf[9] = 0;
   1887 	buf[10] = 0;
   1888 	buf[11] = 0;
   1889 	buf[12] = 0;
   1890 	buf[13] = 0;
   1891 
   1892 	sljit_emit_enter(compiler, 1, 3, 1, 0);
   1893 
   1894 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0);
   1895 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 1 * sizeof(sljit_w), SLJIT_IMM, 0x7fff);
   1896 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_IMM, -0x8000);
   1897 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_IMM, 0x7fffffff);
   1898 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(-0x80000000));
   1899 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x1234567887654321));
   1900 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xff80000000));
   1901 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x3ff0000000));
   1902 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xfffffff800100000));
   1903 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xfffffff80010f000));
   1904 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00000008001));
   1905 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00080010000));
   1906 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00080018001));
   1907 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00ffff00000));
   1908 
   1909 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1910 
   1911 	code.code = sljit_generate_code(compiler);
   1912 	CHECK(compiler);
   1913 	sljit_free_compiler(compiler);
   1914 
   1915 	code.func1((sljit_w)&buf);
   1916 	FAILED(buf[0] != 0, "test25 case 1 failed\n");
   1917 	FAILED(buf[1] != 0x7fff, "test25 case 2 failed\n");
   1918 	FAILED(buf[2] != -0x8000, "test25 case 3 failed\n");
   1919 	FAILED(buf[3] != 0x7fffffff, "test25 case 4 failed\n");
   1920 	FAILED(buf[4] != SLJIT_W(-0x80000000), "test25 case 5 failed\n");
   1921 	FAILED(buf[5] != SLJIT_W(0x1234567887654321), "test25 case 6 failed\n");
   1922 	FAILED(buf[6] != SLJIT_W(0xff80000000), "test25 case 7 failed\n");
   1923 	FAILED(buf[7] != SLJIT_W(0x3ff0000000), "test25 case 8 failed\n");
   1924 	FAILED((sljit_uw)buf[8] != SLJIT_W(0xfffffff800100000), "test25 case 9 failed\n");
   1925 	FAILED((sljit_uw)buf[9] != SLJIT_W(0xfffffff80010f000), "test25 case 10 failed\n");
   1926 	FAILED(buf[10] != SLJIT_W(0x07fff00000008001), "test25 case 11 failed\n");
   1927 	FAILED(buf[11] != SLJIT_W(0x07fff00080010000), "test25 case 12 failed\n");
   1928 	FAILED(buf[12] != SLJIT_W(0x07fff00080018001), "test25 case 13 failed\n");
   1929 	FAILED(buf[13] != SLJIT_W(0x07fff00ffff00000), "test25 case 14 failed\n");
   1930 
   1931 	sljit_free_code(code.code);
   1932 #endif
   1933 	printf("test25 ok\n");
   1934 	successful_tests++;
   1935 }
   1936 
   1937 static void test26(void)
   1938 {
   1939 	/* Aligned access without aligned offsets. */
   1940 	executable_code code;
   1941 	struct sljit_compiler* compiler = sljit_create_compiler();
   1942 	sljit_w buf[4];
   1943 	int ibuf[4];
   1944 	double dbuf[4];
   1945 
   1946 	FAILED(!compiler, "cannot create compiler\n");
   1947 
   1948 	buf[0] = -2789;
   1949 	buf[1] = 0;
   1950 	buf[2] = 4;
   1951 	buf[3] = -4;
   1952 
   1953 	ibuf[0] = -689;
   1954 	ibuf[1] = 0;
   1955 	ibuf[2] = -6;
   1956 	ibuf[3] = 3;
   1957 
   1958 	dbuf[0] = 5.75;
   1959 	dbuf[1] = 0.0;
   1960 	dbuf[2] = 0.0;
   1961 	dbuf[3] = -4.0;
   1962 
   1963 	sljit_emit_enter(compiler, 3, 3, 3, 0);
   1964 
   1965 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 3);
   1966 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
   1967 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), -3);
   1968 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) - 1, SLJIT_TEMPORARY_REG1, 0);
   1969 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), -1);
   1970 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) - 3, SLJIT_TEMPORARY_REG1, 0);
   1971 
   1972 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 100);
   1973 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w) * 2 - 103, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2 - 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3 - 3);
   1974 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 100);
   1975 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(int) * 2 - 101, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) * 2 - 1, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) * 3 - 1);
   1976 
   1977 	if (sljit_is_fpu_available()) {
   1978 		sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 3);
   1979 		sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) - 3, SLJIT_MEM1(SLJIT_SAVED_REG3), -3);
   1980 		sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) * 2 - 3, SLJIT_MEM1(SLJIT_SAVED_REG3), -3, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) - 3);
   1981 		sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 2);
   1982 		sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sizeof(double) * 3 - 4) >> 1);
   1983 		sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 1);
   1984 		sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(double) * 3 - 5, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) * 2 - 3, SLJIT_MEM2(SLJIT_TEMPORARY_REG3, SLJIT_TEMPORARY_REG2), 1);
   1985 	}
   1986 
   1987 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   1988 
   1989 	code.code = sljit_generate_code(compiler);
   1990 	CHECK(compiler);
   1991 	sljit_free_compiler(compiler);
   1992 
   1993 	code.func3((sljit_w)&buf, (sljit_w)&ibuf, (sljit_w)&dbuf);
   1994 
   1995 	FAILED(buf[1] != -689, "test26 case 1 failed\n");
   1996 	FAILED(buf[2] != -16, "test26 case 2 failed\n");
   1997 	FAILED(ibuf[1] != -2789, "test26 case 3 failed\n");
   1998 	FAILED(ibuf[2] != -18, "test26 case 4 failed\n");
   1999 
   2000 	if (sljit_is_fpu_available()) {
   2001 		FAILED(dbuf[1] != 5.75, "test26 case 5 failed\n");
   2002 		FAILED(dbuf[2] != 11.5, "test26 case 6 failed\n");
   2003 		FAILED(dbuf[3] != -2.875, "test26 case 7 failed\n");
   2004 	}
   2005 
   2006 	sljit_free_code(code.code);
   2007 	printf("test26 ok\n");
   2008 	successful_tests++;
   2009 }
   2010 
   2011 static void test27(void)
   2012 {
   2013 #define SET_NEXT_BYTE(type) \
   2014 		cond_set(compiler, SLJIT_TEMPORARY_REG3, 0, type); \
   2015 		sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
   2016 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2017 #define RESULT(i) i
   2018 #else
   2019 #define RESULT(i) (3 - i)
   2020 #endif
   2021 
   2022 	/* Playing with conditional flags. */
   2023 	executable_code code;
   2024 	struct sljit_compiler* compiler = sljit_create_compiler();
   2025 	sljit_b buf[37];
   2026 	int i;
   2027 
   2028 	for (i = 0; i < 37; ++i)
   2029 		buf[i] = 10;
   2030 
   2031 	FAILED(!compiler, "cannot create compiler\n");
   2032 
   2033 	/* 3 arguments passed, 3 arguments used. */
   2034 	sljit_emit_enter(compiler, 1, 3, 3, 0);
   2035 
   2036 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
   2037 
   2038 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1001);
   2039 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
   2040 	/* 0x100100000 on 64 bit machines, 0x100000 on 32 bit machines. */
   2041 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x800000);
   2042 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2043 	sljit_emit_op0(compiler, SLJIT_NOP); /* Nop should keep the flags. */
   2044 	SET_NEXT_BYTE(SLJIT_C_GREATER);
   2045 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2046 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2047 	sljit_emit_op0(compiler, SLJIT_NOP); /* Nop should keep the flags. */
   2048 	SET_NEXT_BYTE(SLJIT_C_GREATER);
   2049 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2050 
   2051 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1000);
   2052 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
   2053 	sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x10);
   2054 	/* 0x100000010 on 64 bit machines, 0x10 on 32 bit machines. */
   2055 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80);
   2056 	SET_NEXT_BYTE(SLJIT_C_GREATER);
   2057 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2058 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80);
   2059 	SET_NEXT_BYTE(SLJIT_C_GREATER);
   2060 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2061 
   2062 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2063 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2064 	/* 0xff..ff on all machines. */
   2065 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2066 	SET_NEXT_BYTE(SLJIT_C_LESS_EQUAL);
   2067 	SET_NEXT_BYTE(SLJIT_C_GREATER_EQUAL);
   2068 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -1);
   2069 	SET_NEXT_BYTE(SLJIT_C_SIG_GREATER);
   2070 	SET_NEXT_BYTE(SLJIT_C_SIG_LESS);
   2071 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
   2072 	SET_NEXT_BYTE(SLJIT_C_EQUAL);
   2073 	SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
   2074 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_O | SLJIT_SET_U, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -2);
   2075 	SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
   2076 	SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
   2077 	SET_NEXT_BYTE(SLJIT_C_GREATER_EQUAL);
   2078 	SET_NEXT_BYTE(SLJIT_C_LESS_EQUAL);
   2079 
   2080 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80000000);
   2081 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
   2082 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
   2083 	/* 0x80..0 on 64 bit machines, 0 on 32 bit machines. */
   2084 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0xffffffff);
   2085 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2086 	SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
   2087 	SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
   2088 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2089 	SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
   2090 	SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
   2091 
   2092 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2093 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2094 	sljit_emit_op2(compiler, SLJIT_SUBC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2095 	sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6, SLJIT_TEMPORARY_REG1, 0);
   2096 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG1, 0);
   2097 
   2098 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
   2099 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2100 	sljit_emit_op2(compiler, SLJIT_ADDC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2101 	sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9);
   2102 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG1, 0);
   2103 
   2104 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2105 	sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (8 * sizeof(sljit_w)) - 1);
   2106 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2107 	SET_NEXT_BYTE(SLJIT_C_EQUAL);
   2108 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   2109 	SET_NEXT_BYTE(SLJIT_C_EQUAL);
   2110 
   2111 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2112 	sljit_emit_op2(compiler, SLJIT_ASHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2113 	SET_NEXT_BYTE(SLJIT_C_EQUAL);
   2114 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2115 	sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffc0);
   2116 	SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
   2117 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
   2118 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2119 	sljit_emit_op2(compiler, SLJIT_ASHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
   2120 	SET_NEXT_BYTE(SLJIT_C_EQUAL);
   2121 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
   2122 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2123 	sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
   2124 	SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
   2125 
   2126 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2127 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
   2128 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   2129 	sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1, SLJIT_TEMPORARY_REG1, 0);
   2130 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
   2131 	sljit_emit_op2(compiler, SLJIT_SUBC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2132 	sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1, SLJIT_TEMPORARY_REG1, 0);
   2133 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
   2134 
   2135 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -34);
   2136 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1234);
   2137 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2138 	SET_NEXT_BYTE(SLJIT_C_SIG_LESS);
   2139 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2140 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x12300000000) - 43);
   2141 #else
   2142 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -43);
   2143 #endif
   2144 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -96);
   2145 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_S | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2146 	SET_NEXT_BYTE(SLJIT_C_LESS);
   2147 	SET_NEXT_BYTE(SLJIT_C_SIG_GREATER);
   2148 
   2149 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2150 
   2151 	code.code = sljit_generate_code(compiler);
   2152 	CHECK(compiler);
   2153 	sljit_free_compiler(compiler);
   2154 
   2155 	code.func1((sljit_w)&buf);
   2156 	sljit_free_code(code.code);
   2157 
   2158 	FAILED(buf[0] != RESULT(1), "test27 case 1 failed\n");
   2159 	FAILED(buf[1] != RESULT(2), "test27 case 2 failed\n");
   2160 	FAILED(buf[2] != 2, "test27 case 3 failed\n");
   2161 	FAILED(buf[3] != 1, "test27 case 4 failed\n");
   2162 	FAILED(buf[4] != RESULT(1), "test27 case 5 failed\n");
   2163 	FAILED(buf[5] != RESULT(2), "test27 case 6 failed\n");
   2164 	FAILED(buf[6] != 2, "test27 case 7 failed\n");
   2165 	FAILED(buf[7] != 1, "test27 case 8 failed\n");
   2166 
   2167 	FAILED(buf[8] != 2, "test27 case 9 failed\n");
   2168 	FAILED(buf[9] != 1, "test27 case 10 failed\n");
   2169 	FAILED(buf[10] != 2, "test27 case 11 failed\n");
   2170 	FAILED(buf[11] != 1, "test27 case 12 failed\n");
   2171 	FAILED(buf[12] != 1, "test27 case 13 failed\n");
   2172 	FAILED(buf[13] != 2, "test27 case 14 failed\n");
   2173 	FAILED(buf[14] != 2, "test27 case 15 failed\n");
   2174 	FAILED(buf[15] != 1, "test27 case 16 failed\n");
   2175 	FAILED(buf[16] != 1, "test27 case 17 failed\n");
   2176 	FAILED(buf[17] != 2, "test27 case 18 failed\n");
   2177 
   2178 	FAILED(buf[18] != RESULT(1), "test27 case 19 failed\n");
   2179 	FAILED(buf[19] != RESULT(2), "test27 case 20 failed\n");
   2180 	FAILED(buf[20] != 2, "test27 case 21 failed\n");
   2181 	FAILED(buf[21] != 1, "test27 case 22 failed\n");
   2182 
   2183 	FAILED(buf[22] != 5, "test27 case 23 failed\n");
   2184 	FAILED(buf[23] != 9, "test27 case 24 failed\n");
   2185 
   2186 	FAILED(buf[24] != 2, "test27 case 25 failed\n");
   2187 	FAILED(buf[25] != 1, "test27 case 26 failed\n");
   2188 
   2189 	FAILED(buf[26] != 1, "test27 case 27 failed\n");
   2190 	FAILED(buf[27] != 1, "test27 case 28 failed\n");
   2191 	FAILED(buf[28] != 1, "test27 case 29 failed\n");
   2192 	FAILED(buf[29] != 1, "test27 case 30 failed\n");
   2193 
   2194 	FAILED(buf[30] != 1, "test27 case 31 failed\n");
   2195 	FAILED(buf[31] != 0, "test27 case 32 failed\n");
   2196 
   2197 	FAILED(buf[32] != 2, "test27 case 33 failed\n");
   2198 	FAILED(buf[33] != 1, "test27 case 34 failed\n");
   2199 	FAILED(buf[34] != 2, "test27 case 35 failed\n");
   2200 	FAILED(buf[35] != 1, "test27 case 36 failed\n");
   2201 	FAILED(buf[36] != 10, "test27 case 37 failed\n");
   2202 	printf("test27 ok\n");
   2203 	successful_tests++;
   2204 #undef SET_NEXT_BYTE
   2205 #undef RESULT
   2206 }
   2207 
   2208 static void test28(void)
   2209 {
   2210 	/* Test mov. */
   2211 	executable_code code;
   2212 	struct sljit_compiler* compiler = sljit_create_compiler();
   2213 	struct sljit_const* const1;
   2214 	struct sljit_label* label;
   2215 	sljit_uw label_addr;
   2216 	sljit_w buf[5];
   2217 
   2218 	FAILED(!compiler, "cannot create compiler\n");
   2219 
   2220 	buf[0] = -36;
   2221 	buf[1] = 8;
   2222 	buf[2] = 0;
   2223 	buf[3] = 10;
   2224 	buf[4] = 0;
   2225 
   2226 	FAILED(!compiler, "cannot create compiler\n");
   2227 	sljit_emit_enter(compiler, 1, 5, 5, 0);
   2228 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, -234);
   2229 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
   2230 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_SAVED_EREG1, 0, SLJIT_TEMPORARY_EREG1, 0, SLJIT_TEMPORARY_EREG2, 0);
   2231 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
   2232 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0);
   2233 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_C_NOT_ZERO);
   2234 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
   2235 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w));
   2236 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_EREG2, 0, SLJIT_SAVED_EREG2, 0, SLJIT_TEMPORARY_EREG2, 0);
   2237 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_EREG2, 0);
   2238 	const1 = sljit_emit_const(compiler, SLJIT_SAVED_EREG1, 0, 0);
   2239 	sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_SAVED_EREG1, 0);
   2240 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_EREG1, 0, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 100);
   2241 	label = sljit_emit_label(compiler);
   2242 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
   2243 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0);
   2244 
   2245 	code.code = sljit_generate_code(compiler);
   2246 	CHECK(compiler);
   2247 	label_addr = sljit_get_label_addr(label);
   2248 	sljit_set_const(sljit_get_const_addr(const1), label_addr);
   2249 	sljit_free_compiler(compiler);
   2250 
   2251 	FAILED(code.func1((sljit_w)&buf) != 8, "test28 case 1 failed\n");
   2252 	FAILED(buf[1] != -1872, "test28 case 2 failed\n");
   2253 	FAILED(buf[2] != 1, "test28 case 3 failed\n");
   2254 	FAILED(buf[3] != 2, "test28 case 4 failed\n");
   2255 	FAILED(buf[4] != label_addr, "test28 case 5 failed\n");
   2256 
   2257 	sljit_free_code(code.code);
   2258 	printf("test28 ok\n");
   2259 	successful_tests++;
   2260 }
   2261 
   2262 static void test29(void)
   2263 {
   2264 	/* Test signed/unsigned bytes and halfs. */
   2265 	executable_code code;
   2266 	struct sljit_compiler* compiler = sljit_create_compiler();
   2267 
   2268 	sljit_w buf[25];
   2269 	buf[0] = 0;
   2270 	buf[1] = 0;
   2271 	buf[2] = 0;
   2272 	buf[3] = 0;
   2273 	buf[4] = 0;
   2274 	buf[5] = 0;
   2275 	buf[6] = 0;
   2276 	buf[7] = 0;
   2277 	buf[8] = 0;
   2278 	buf[9] = 0;
   2279 	buf[10] = 0;
   2280 	buf[11] = 0;
   2281 	buf[12] = 0;
   2282 	buf[13] = 0;
   2283 	buf[14] = 0;
   2284 	buf[15] = 0;
   2285 	buf[16] = 0;
   2286 	buf[17] = 0;
   2287 	buf[18] = 0;
   2288 	buf[19] = 0;
   2289 	buf[20] = 0;
   2290 	buf[21] = 0;
   2291 	buf[22] = 0;
   2292 	buf[23] = 0;
   2293 	buf[24] = 0;
   2294 
   2295 	FAILED(!compiler, "cannot create compiler\n");
   2296 	sljit_emit_enter(compiler, 1, 5, 5, 0);
   2297 
   2298 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -187);
   2299 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
   2300 	sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -605);
   2301 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2302 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -56);
   2303 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2304 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0xcde5);
   2305 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2306 
   2307 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -45896);
   2308 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2309 	sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1472797);
   2310 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2311 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -12890);
   2312 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2313 	sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0x9cb0a6);
   2314 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2315 
   2316 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2317 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-3580429715));
   2318 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2319 	sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-100722768662));
   2320 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2321 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-1457052677972));
   2322 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2323 	sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, SLJIT_W(0xcef97a70b5));
   2324 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2325 #else
   2326 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 4 * sizeof(sljit_uw));
   2327 #endif
   2328 
   2329 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -187);
   2330 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2331 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2332 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -605);
   2333 	sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
   2334 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2335 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -56);
   2336 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
   2337 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2338 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0xcde5);
   2339 	sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
   2340 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2341 
   2342 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -45896);
   2343 	sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2344 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2345 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -1472797);
   2346 	sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
   2347 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2348 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -12890);
   2349 	sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
   2350 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2351 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0x9cb0a6);
   2352 	sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
   2353 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2354 
   2355 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2356 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(-3580429715));
   2357 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2358 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2359 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, SLJIT_W(-100722768662));
   2360 	sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
   2361 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2362 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, SLJIT_W(-1457052677972));
   2363 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
   2364 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
   2365 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, SLJIT_W(0xcef97a70b5));
   2366 	sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
   2367 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
   2368 #else
   2369 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 4 * sizeof(sljit_uw));
   2370 #endif
   2371 
   2372 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 0x9faa5);
   2373 	sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_SAVED_REG3, 0, SLJIT_SAVED_REG3, 0);
   2374 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_SAVED_REG3, 0);
   2375 
   2376 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2377 
   2378 	code.code = sljit_generate_code(compiler);
   2379 	CHECK(compiler);
   2380 	sljit_free_compiler(compiler);
   2381 
   2382 	code.func1((sljit_w)&buf);
   2383 	FAILED(buf[0] != 69, "test29 case 1 failed\n");
   2384 	FAILED(buf[1] != -93, "test29 case 2 failed\n");
   2385 	FAILED(buf[2] != 200, "test29 case 3 failed\n");
   2386 	FAILED(buf[3] != 0xe5, "test29 case 4 failed\n");
   2387 	FAILED(buf[4] != 19640, "test29 case 5 failed\n");
   2388 	FAILED(buf[5] != -31005, "test29 case 6 failed\n");
   2389 	FAILED(buf[6] != 52646, "test29 case 7 failed\n");
   2390 	FAILED(buf[7] != 0xb0a6, "test29 case 8 failed\n");
   2391 
   2392 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2393 	FAILED(buf[8] != SLJIT_W(714537581), "test29 case 9 failed\n");
   2394 	FAILED(buf[9] != SLJIT_W(-1938520854), "test29 case 10 failed\n");
   2395 	FAILED(buf[10] != SLJIT_W(3236202668), "test29 case 11 failed\n");
   2396 	FAILED(buf[11] != SLJIT_W(0xf97a70b5), "test29 case 12 failed\n");
   2397 #endif
   2398 
   2399 	FAILED(buf[12] != 69, "test29 case 13 failed\n");
   2400 	FAILED(buf[13] != -93, "test29 case 14 failed\n");
   2401 	FAILED(buf[14] != 200, "test29 case 15 failed\n");
   2402 	FAILED(buf[15] != 0xe5, "test29 case 16 failed\n");
   2403 	FAILED(buf[16] != 19640, "test29 case 17 failed\n");
   2404 	FAILED(buf[17] != -31005, "test29 case 18 failed\n");
   2405 	FAILED(buf[18] != 52646, "test29 case 19 failed\n");
   2406 	FAILED(buf[19] != 0xb0a6, "test29 case 20 failed\n");
   2407 
   2408 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2409 	FAILED(buf[20] != SLJIT_W(714537581), "test29 case 21 failed\n");
   2410 	FAILED(buf[21] != SLJIT_W(-1938520854), "test29 case 22 failed\n");
   2411 	FAILED(buf[22] != SLJIT_W(3236202668), "test29 case 23 failed\n");
   2412 	FAILED(buf[23] != SLJIT_W(0xf97a70b5), "test29 case 24 failed\n");
   2413 #endif
   2414 
   2415 	FAILED(buf[24] != -91, "test29 case 25 failed\n");
   2416 
   2417 	sljit_free_code(code.code);
   2418 	printf("test29 ok\n");
   2419 	successful_tests++;
   2420 }
   2421 
   2422 static void test30(void)
   2423 {
   2424 	/* Test unused results. */
   2425 	executable_code code;
   2426 	struct sljit_compiler* compiler = sljit_create_compiler();
   2427 
   2428 	sljit_w buf[1];
   2429 	buf[0] = 0;
   2430 
   2431 	FAILED(!compiler, "cannot create compiler\n");
   2432 	sljit_emit_enter(compiler, 1, 5, 5, 0);
   2433 
   2434 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2435 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
   2436 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1);
   2437 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 1);
   2438 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 1);
   2439 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
   2440 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 1);
   2441 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 1);
   2442 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 1);
   2443 
   2444 	/* Some calculations with unused results. */
   2445 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0);
   2446 	sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0);
   2447 	sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2448 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2449 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2450 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2451 	sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_EREG1, 0, SLJIT_TEMPORARY_REG3, 0);
   2452 	sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 5);
   2453 	sljit_emit_op2(compiler, SLJIT_AND, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0xff);
   2454 	sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0);
   2455 
   2456 	/* Testing that any change happens. */
   2457 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2458 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
   2459 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_EREG1, 0);
   2460 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_EREG2, 0);
   2461 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0);
   2462 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
   2463 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_EREG1, 0);
   2464 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_EREG2, 0);
   2465 
   2466 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2467 
   2468 	code.code = sljit_generate_code(compiler);
   2469 	CHECK(compiler);
   2470 	sljit_free_compiler(compiler);
   2471 
   2472 	code.func1((sljit_w)&buf);
   2473 	FAILED(buf[0] != 9, "test30 case 1 failed\n");
   2474 	sljit_free_code(code.code);
   2475 	printf("test30 ok\n");
   2476 	successful_tests++;
   2477 }
   2478 
   2479 static void test31(void)
   2480 {
   2481 	/* Integer mul and set flags. */
   2482 	executable_code code;
   2483 	struct sljit_compiler* compiler = sljit_create_compiler();
   2484 
   2485 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2486 	sljit_w big_word = SLJIT_W(0x7fffffff00000000);
   2487 	sljit_w big_word2 = SLJIT_W(0x7fffffff00000012);
   2488 #else
   2489 	sljit_w big_word = 0x7fffffff;
   2490 	sljit_w big_word2 = 0x00000012;
   2491 #endif
   2492 
   2493 	sljit_w buf[12];
   2494 	buf[0] = 3;
   2495 	buf[1] = 3;
   2496 	buf[2] = 3;
   2497 	buf[3] = 3;
   2498 	buf[4] = 3;
   2499 	buf[5] = 3;
   2500 	buf[6] = 3;
   2501 	buf[7] = 3;
   2502 	buf[8] = 3;
   2503 	buf[9] = 3;
   2504 	buf[10] = 3;
   2505 	buf[11] = 3;
   2506 
   2507 	FAILED(!compiler, "cannot create compiler\n");
   2508 
   2509 	sljit_emit_enter(compiler, 1, 3, 5, 0);
   2510 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
   2511 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -45);
   2512 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_C_MUL_NOT_OVERFLOW);
   2513 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
   2514 
   2515 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, big_word);
   2516 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -2);
   2517 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 33); /* Should not change flags. */
   2518 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0); /* Should not change flags. */
   2519 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
   2520 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
   2521 
   2522 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x3f6b0);
   2523 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 0x2a783);
   2524 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_EREG1, 0, SLJIT_SAVED_EREG2, 0);
   2525 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
   2526 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   2527 
   2528 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, big_word2);
   2529 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG2, 0);
   2530 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 23);
   2531 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
   2532 
   2533 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -23);
   2534 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
   2535 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -23);
   2536 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
   2537 
   2538 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 67);
   2539 	sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -23);
   2540 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   2541 
   2542 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2543 
   2544 	code.code = sljit_generate_code(compiler);
   2545 	CHECK(compiler);
   2546 	sljit_free_compiler(compiler);
   2547 
   2548 	code.func1((sljit_w)&buf);
   2549 
   2550 	FAILED(buf[0] != 1, "test31 case 1 failed\n");
   2551 	FAILED(buf[1] != 2, "test31 case 2 failed\n");
   2552 /* Qemu issues for 64 bit muls. */
   2553 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2554 	FAILED(buf[2] != 1, "test31 case 3 failed\n");
   2555 	FAILED(buf[3] != 2, "test31 case 4 failed\n");
   2556 #endif
   2557 	FAILED(buf[4] != 1, "test31 case 5 failed\n");
   2558 	FAILED((buf[5] & 0xffffffff) != 0x85540c10, "test31 case 6 failed\n");
   2559 	FAILED(buf[6] != 2, "test31 case 7 failed\n");
   2560 	FAILED(buf[7] != 1, "test31 case 8 failed\n");
   2561 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2562 	FAILED(buf[8] != 1, "test31 case 9 failed\n");
   2563 #endif
   2564 	FAILED(buf[9] != -1541, "test31 case 10 failed\n");
   2565 	sljit_free_code(code.code);
   2566 	printf("test31 ok\n");
   2567 	successful_tests++;
   2568 }
   2569 
   2570 static void test32(void)
   2571 {
   2572 	/* Floating point set flags. */
   2573 	executable_code code;
   2574 	struct sljit_compiler* compiler = sljit_create_compiler();
   2575 
   2576 	sljit_w buf[16];
   2577 	union {
   2578 		double value;
   2579 		struct {
   2580 			int value1;
   2581 			int value2;
   2582 		} u;
   2583 	} dbuf[4];
   2584 
   2585 	buf[0] = 5;
   2586 	buf[1] = 5;
   2587 	buf[2] = 5;
   2588 	buf[3] = 5;
   2589 	buf[4] = 5;
   2590 	buf[5] = 5;
   2591 	buf[6] = 5;
   2592 	buf[7] = 5;
   2593 	buf[8] = 5;
   2594 	buf[9] = 5;
   2595 	buf[10] = 5;
   2596 	buf[11] = 5;
   2597 	buf[12] = 5;
   2598 	buf[13] = 5;
   2599 	buf[14] = 5;
   2600 	buf[15] = 5;
   2601 
   2602 	/* Two NaNs */
   2603 	dbuf[0].u.value1 = 0x7fffffff;
   2604 	dbuf[0].u.value2 = 0x7fffffff;
   2605 	dbuf[1].u.value1 = 0x7fffffff;
   2606 	dbuf[1].u.value2 = 0x7fffffff;
   2607 	dbuf[2].value = -13.0;
   2608 	dbuf[3].value = 27.0;
   2609 
   2610 	if (!sljit_is_fpu_available()) {
   2611 		printf("no fpu available, test32 skipped\n");
   2612 		successful_tests++;
   2613 		if (compiler)
   2614 			sljit_free_compiler(compiler);
   2615 		return;
   2616 	}
   2617 
   2618 	FAILED(!compiler, "cannot create compiler\n");
   2619 	SLJIT_ASSERT(sizeof(double) == 8 && sizeof(int) == 4 && sizeof(dbuf[0]) == 8);
   2620 
   2621 	sljit_emit_enter(compiler, 2, 1, 2, 0);
   2622 
   2623 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 0);
   2624 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double), SLJIT_FLOAT_REG1, 0);
   2625 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(double));
   2626 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_C_FLOAT_NAN);
   2627 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_FLOAT_NOT_NAN);
   2628 
   2629 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double));
   2630 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
   2631 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_FLOAT_NAN);
   2632 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_NAN);
   2633 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS);
   2634 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_C_FLOAT_GREATER_EQUAL);
   2635 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_FLOAT_GREATER);
   2636 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS_EQUAL);
   2637 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
   2638 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_EQUAL);
   2639 
   2640 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double));
   2641 	sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(double));
   2642 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_C_FLOAT_NAN);
   2643 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
   2644 
   2645 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(double), SLJIT_FLOAT_REG1, 0);
   2646 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_NAN);
   2647 
   2648 	sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0);
   2649 	sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 0);
   2650 	cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_C_FLOAT_NAN);
   2651 
   2652 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2653 
   2654 	code.code = sljit_generate_code(compiler);
   2655 	CHECK(compiler);
   2656 	sljit_free_compiler(compiler);
   2657 
   2658 	code.func2((sljit_w)&buf, (sljit_w)&dbuf);
   2659 
   2660 	FAILED(buf[0] != 1, "test32 case 1 failed\n");
   2661 	FAILED(buf[1] != 2, "test32 case 2 failed\n");
   2662 	FAILED(buf[2] != 2, "test32 case 3 failed\n");
   2663 	FAILED(buf[3] != 1, "test32 case 4 failed\n");
   2664 	FAILED(buf[4] != 1, "test32 case 5 failed\n");
   2665 	FAILED(buf[5] != 2, "test32 case 6 failed\n");
   2666 	FAILED(buf[6] != 2, "test32 case 7 failed\n");
   2667 	FAILED(buf[7] != 1, "test32 case 8 failed\n");
   2668 	FAILED(buf[8] != 2, "test32 case 9 failed\n");
   2669 	FAILED(buf[9] != 1, "test32 case 10 failed\n");
   2670 	FAILED(buf[10] != 2, "test32 case 11 failed\n");
   2671 	FAILED(buf[11] != 1, "test32 case 12 failed\n");
   2672 	FAILED(buf[12] != 2, "test32 case 13 failed\n");
   2673 	FAILED(buf[13] != 1, "test32 case 14 failed\n");
   2674 
   2675 	sljit_free_code(code.code);
   2676 	printf("test32 ok\n");
   2677 	successful_tests++;
   2678 }
   2679 
   2680 static void test33(void)
   2681 {
   2682 	/* Test keep flags. */
   2683 	executable_code code;
   2684 	struct sljit_compiler* compiler = sljit_create_compiler();
   2685 
   2686 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   2687 	sljit_w big_word = SLJIT_W(0x8000000000000003);
   2688 #else
   2689 	sljit_w big_word = 0x80000003;
   2690 #endif
   2691 
   2692 	sljit_w buf[12];
   2693 	buf[0] = 3;
   2694 	buf[1] = 3;
   2695 	buf[2] = 3;
   2696 	buf[3] = 3;
   2697 	buf[4] = 3;
   2698 	buf[5] = 3;
   2699 	buf[6] = 3;
   2700 	buf[7] = 3;
   2701 	buf[8] = 3;
   2702 	buf[9] = 3;
   2703 	buf[10] = 3;
   2704 	buf[11] = 3;
   2705 
   2706 	FAILED(!compiler, "cannot create compiler\n");
   2707 
   2708 	sljit_emit_enter(compiler, 1, 3, 3, 0);
   2709 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, big_word);
   2710 	sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E | SLJIT_SET_C, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, big_word);
   2711 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
   2712 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   2713 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   2714 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_NOT_ZERO);
   2715 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2716 	sljit_emit_op2(compiler, SLJIT_ADDC | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2717 	sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
   2718 
   2719 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   2720 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   2721 	sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
   2722 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_EQUAL);
   2723 
   2724 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, 0x124);
   2725 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
   2726 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   2727 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_KEEP_FLAGS, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   2728 	sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_C_NOT_EQUAL);
   2729 
   2730 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   2731 
   2732 	code.code = sljit_generate_code(compiler);
   2733 	CHECK(compiler);
   2734 	sljit_free_compiler(compiler);
   2735 
   2736 	code.func1((sljit_w)&buf);
   2737 
   2738 	FAILED(buf[0] != 6, "test33 case 1 failed\n");
   2739 	FAILED(buf[1] != 1, "test33 case 2 failed\n");
   2740 	FAILED(buf[2] != 8, "test33 case 3 failed\n");
   2741 	FAILED(buf[3] != 16, "test33 case 4 failed\n");
   2742 	FAILED(buf[4] != 1, "test33 case 5 failed\n");
   2743 	FAILED(buf[5] != 0x125, "test33 case 6 failed\n");
   2744 
   2745 	sljit_free_code(code.code);
   2746 	printf("test33 ok\n");
   2747 	successful_tests++;
   2748 }
   2749 
   2750 static void test34(void)
   2751 {
   2752 	/* Test fast calls. */
   2753 	executable_code codeA;
   2754 	executable_code codeB;
   2755 	executable_code codeC;
   2756 	executable_code codeD;
   2757 	executable_code codeE;
   2758 	executable_code codeF;
   2759 	struct sljit_compiler* compiler;
   2760 	struct sljit_jump *jump;
   2761 	struct sljit_label* label;
   2762 	sljit_uw addr;
   2763 
   2764 	sljit_w buf[2];
   2765 	buf[0] = 0;
   2766 	buf[1] = 0;
   2767 
   2768 	/* A */
   2769 	compiler = sljit_create_compiler();
   2770 	FAILED(!compiler, "cannot create compiler\n");
   2771 	sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2772 
   2773 	sljit_emit_fast_enter(compiler, SLJIT_TEMPORARY_REG2, 0);
   2774 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
   2775 	sljit_emit_fast_return(compiler, SLJIT_TEMPORARY_REG2, 0);
   2776 
   2777 	codeA.code = sljit_generate_code(compiler);
   2778 	CHECK(compiler);
   2779 	sljit_free_compiler(compiler);
   2780 
   2781 	/* B */
   2782 	compiler = sljit_create_compiler();
   2783 	FAILED(!compiler, "cannot create compiler\n");
   2784 	sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2785 
   2786 	sljit_emit_fast_enter(compiler, SLJIT_TEMPORARY_EREG2, 0);
   2787 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6);
   2788 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeA.code));
   2789 	sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_TEMPORARY_REG2, 0);
   2790 	sljit_emit_fast_return(compiler, SLJIT_TEMPORARY_EREG2, 0);
   2791 
   2792 	codeB.code = sljit_generate_code(compiler);
   2793 	CHECK(compiler);
   2794 	sljit_free_compiler(compiler);
   2795 
   2796 	/* C */
   2797 	compiler = sljit_create_compiler();
   2798 	FAILED(!compiler, "cannot create compiler\n");
   2799 	sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2800 
   2801 	sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
   2802 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   2803 	jump = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_FAST_CALL);
   2804 	sljit_set_target(jump, SLJIT_FUNC_OFFSET(codeB.code));
   2805 	sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
   2806 
   2807 	codeC.code = sljit_generate_code(compiler);
   2808 	CHECK(compiler);
   2809 	sljit_free_compiler(compiler);
   2810 
   2811 	/* D */
   2812 	compiler = sljit_create_compiler();
   2813 	FAILED(!compiler, "cannot create compiler\n");
   2814 	sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2815 
   2816 	sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   2817 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 10);
   2818 	sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeC.code));
   2819 	sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   2820 
   2821 	codeD.code = sljit_generate_code(compiler);
   2822 	CHECK(compiler);
   2823 	sljit_free_compiler(compiler);
   2824 
   2825 	/* E */
   2826 	compiler = sljit_create_compiler();
   2827 	FAILED(!compiler, "cannot create compiler\n");
   2828 	sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2829 
   2830 	sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2831 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 12);
   2832 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, SLJIT_FUNC_OFFSET(codeD.code));
   2833 	sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
   2834 	sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   2835 
   2836 	codeE.code = sljit_generate_code(compiler);
   2837 	CHECK(compiler);
   2838 	sljit_free_compiler(compiler);
   2839 
   2840 	/* F */
   2841 	compiler = sljit_create_compiler();
   2842 	FAILED(!compiler, "cannot create compiler\n");
   2843 
   2844 	sljit_emit_enter(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
   2845 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2846 	sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeE.code));
   2847 	label = sljit_emit_label(compiler);
   2848 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
   2849 
   2850 	codeF.code = sljit_generate_code(compiler);
   2851 	CHECK(compiler);
   2852 	addr = sljit_get_label_addr(label);
   2853 	sljit_free_compiler(compiler);
   2854 
   2855 	FAILED(codeF.func1((sljit_w)&buf) != 40, "test34 case 1 failed\n");
   2856 	FAILED(buf[0] != addr, "test34 case 2 failed\n");
   2857 
   2858 	sljit_free_code(codeA.code);
   2859 	sljit_free_code(codeB.code);
   2860 	sljit_free_code(codeC.code);
   2861 	sljit_free_code(codeD.code);
   2862 	sljit_free_code(codeE.code);
   2863 	sljit_free_code(codeF.code);
   2864 
   2865 	printf("test34 ok\n");
   2866 	successful_tests++;
   2867 }
   2868 
   2869 static void test35(void)
   2870 {
   2871 	/* More complicated tests for fast calls. */
   2872 	executable_code codeA;
   2873 	executable_code codeB;
   2874 	executable_code codeC;
   2875 	struct sljit_compiler* compiler;
   2876 	struct sljit_jump *jump;
   2877 	struct sljit_label* label;
   2878 	sljit_uw return_addr, jump_addr;
   2879 
   2880 	sljit_w buf[1];
   2881 	buf[0] = 0;
   2882 
   2883 	/* A */
   2884 	compiler = sljit_create_compiler();
   2885 	FAILED(!compiler, "cannot create compiler\n");
   2886 	sljit_set_context(compiler, 0, 2, 2, 0);
   2887 
   2888 	sljit_emit_fast_enter(compiler, SLJIT_MEM0(), (sljit_w)&buf[0]);
   2889 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   2890 	jump = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_FAST_CALL);
   2891 	sljit_set_target(jump, 0);
   2892 	label = sljit_emit_label(compiler);
   2893 	sljit_emit_fast_return(compiler, SLJIT_MEM0(), (sljit_w)&buf[0]);
   2894 
   2895 	codeA.code = sljit_generate_code(compiler);
   2896 	CHECK(compiler);
   2897 	return_addr = sljit_get_label_addr(label);
   2898 	jump_addr = sljit_get_jump_addr(jump);
   2899 	sljit_free_compiler(compiler);
   2900 
   2901 	/* B */
   2902 	compiler = sljit_create_compiler();
   2903 	FAILED(!compiler, "cannot create compiler\n");
   2904 	sljit_set_context(compiler, 0, 2, 2, 0);
   2905 
   2906 	sljit_emit_fast_enter(compiler, SLJIT_UNUSED, 0);
   2907 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
   2908 	sljit_emit_fast_return(compiler, SLJIT_IMM, return_addr);
   2909 
   2910 	codeB.code = sljit_generate_code(compiler);
   2911 	CHECK(compiler);
   2912 	sljit_free_compiler(compiler);
   2913 	sljit_set_jump_addr(jump_addr, SLJIT_FUNC_OFFSET(codeB.code));
   2914 
   2915 	/* C */
   2916 	compiler = sljit_create_compiler();
   2917 	FAILED(!compiler, "cannot create compiler\n");
   2918 
   2919 	sljit_emit_enter(compiler, 0, 2, 2, 0);
   2920 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2921 	sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeA.code));
   2922 	label = sljit_emit_label(compiler);
   2923 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
   2924 
   2925 	codeC.code = sljit_generate_code(compiler);
   2926 	CHECK(compiler);
   2927 	return_addr = sljit_get_label_addr(label);
   2928 	sljit_free_compiler(compiler);
   2929 
   2930 	FAILED(codeC.func0() != 12, "test35 case 1 failed\n");
   2931 	FAILED(buf[0] != return_addr, "test35 case 2 failed\n");
   2932 
   2933 	sljit_free_code(codeA.code);
   2934 	sljit_free_code(codeB.code);
   2935 	sljit_free_code(codeC.code);
   2936 
   2937 	printf("test35 ok\n");
   2938 	successful_tests++;
   2939 }
   2940 
   2941 static int cmp_test(struct sljit_compiler *compiler, int type, int src1, sljit_w src1w, int src2, sljit_w src2w)
   2942 {
   2943 	/* 2 = true, 1 = false */
   2944 	struct sljit_jump* jump;
   2945 	struct sljit_label* label;
   2946 
   2947 	if (sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_IMM, 2))
   2948 		return compiler->error;
   2949 	jump = sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
   2950 	if (!jump)
   2951 		return compiler->error;
   2952 	if (sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 1))
   2953 		return compiler->error;
   2954 	label = sljit_emit_label(compiler);
   2955 	if (!label)
   2956 		return compiler->error;
   2957 	sljit_set_label(jump, label);
   2958 	return SLJIT_SUCCESS;
   2959 }
   2960 
   2961 #define TEST_CASES	(7 + 10 + 12 + 11 + 4)
   2962 static void test36(void)
   2963 {
   2964 	/* Compare instruction. */
   2965 	executable_code code;
   2966 	struct sljit_compiler* compiler = sljit_create_compiler();
   2967 
   2968 	sljit_b buf[TEST_CASES];
   2969 	sljit_b compare_buf[TEST_CASES] = {
   2970 		1, 1, 2, 2, 1, 2, 2,
   2971 		1, 1, 2, 2, 2, 1, 2, 2, 1, 1,
   2972 		2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2,
   2973 		2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2,
   2974 		2, 1, 1, 2
   2975 	};
   2976 	sljit_w data[4];
   2977 	int i;
   2978 
   2979 	FAILED(!compiler, "cannot create compiler\n");
   2980 	for (i = 0; i < TEST_CASES; ++i)
   2981 		buf[i] = 100;
   2982 	data[0] = 32;
   2983 	data[1] = -9;
   2984 	data[2] = 43;
   2985 	data[3] = -13;
   2986 
   2987 	sljit_emit_enter(compiler, 2, 3, 2, 0);
   2988 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
   2989 
   2990 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 13);
   2991 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 15);
   2992 	cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_IMM, 9, SLJIT_TEMPORARY_REG1, 0);
   2993 	cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   2994 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
   2995 	cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_IMM, -13);
   2996 	cmp_test(compiler, SLJIT_C_NOT_EQUAL, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG1, 0);
   2997 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   2998 	cmp_test(compiler, SLJIT_C_NOT_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG1, 0);
   2999 	cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
   3000 	cmp_test(compiler, SLJIT_C_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3001 
   3002 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, 0);
   3003 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -8);
   3004 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
   3005 	cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3006 	cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3007 	cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3008 	cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
   3009 	cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w));
   3010 	cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG2, 0);
   3011 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w));
   3012 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
   3013 	cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
   3014 
   3015 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   3016 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
   3017 	cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w));
   3018 	cmp_test(compiler, SLJIT_C_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   3019 	cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -10);
   3020 	cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
   3021 	cmp_test(compiler, SLJIT_C_GREATER_EQUAL, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
   3022 	cmp_test(compiler, SLJIT_C_GREATER_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
   3023 	cmp_test(compiler, SLJIT_C_GREATER, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
   3024 	cmp_test(compiler, SLJIT_C_LESS_EQUAL, SLJIT_IMM, 7, SLJIT_TEMPORARY_REG1, 0);
   3025 	cmp_test(compiler, SLJIT_C_GREATER, SLJIT_IMM, 1, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
   3026 	cmp_test(compiler, SLJIT_C_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3027 	cmp_test(compiler, SLJIT_C_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3028 	cmp_test(compiler, SLJIT_C_GREATER | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3029 
   3030 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -3);
   3031 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3032 	cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3033 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
   3034 	cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   3035 	cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -1);
   3036 	cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -1);
   3037 	cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3038 	cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3039 	cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_IMM, -4, SLJIT_TEMPORARY_REG1, 0);
   3040 	cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_IMM, -1, SLJIT_TEMPORARY_REG2, 0);
   3041 	cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -1);
   3042 
   3043 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3044 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xf00000004));
   3045 	cmp_test(compiler, SLJIT_C_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3046 	cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3047 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xff0000004));
   3048 	cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3049 	cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3050 #else
   3051 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
   3052 	cmp_test(compiler, SLJIT_C_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3053 	cmp_test(compiler, SLJIT_C_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3054 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf0000004);
   3055 	cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3056 	cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
   3057 #endif
   3058 
   3059 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   3060 
   3061 	code.code = sljit_generate_code(compiler);
   3062 	CHECK(compiler);
   3063 	sljit_free_compiler(compiler);
   3064 
   3065 	code.func2((sljit_w)&buf, (sljit_w)&data);
   3066 
   3067 	for (i = 0; i < TEST_CASES; ++i)
   3068 		if (SLJIT_UNLIKELY(buf[i] != compare_buf[i])) {
   3069 			printf("test36 case %d failed\n", i + 1);
   3070 			return;
   3071 		}
   3072 	sljit_free_code(code.code);
   3073 
   3074 	printf("test36 ok\n");
   3075 	successful_tests++;
   3076 }
   3077 #undef TEST_CASES
   3078 
   3079 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3080 #define BITN(n) (SLJIT_W(1) << (63 - (n)))
   3081 #define RESN(n) (n)
   3082 #else
   3083 #define BITN(n) (1 << (31 - ((n) & 0x1f)))
   3084 #define RESN(n) ((n) & 0x1f)
   3085 #endif
   3086 
   3087 static void test37(void)
   3088 {
   3089 	/* Test count leading zeroes. */
   3090 	executable_code code;
   3091 	struct sljit_compiler* compiler = sljit_create_compiler();
   3092 	sljit_w buf[15];
   3093 	int ibuf[2];
   3094 	int i;
   3095 
   3096 	FAILED(!compiler, "cannot create compiler\n");
   3097 
   3098 	for (i = 0; i < 15; i++)
   3099 		buf[i] = -1;
   3100 	buf[3] = 0;
   3101 	buf[7] = BITN(13);
   3102 	ibuf[0] = -1;
   3103 	ibuf[1] = -1;
   3104 	sljit_emit_enter(compiler, 2, 1, 2, 0);
   3105 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(27));
   3106 	sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
   3107 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(47));
   3108 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3109 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_ZERO);
   3110 	sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w));
   3111 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
   3112 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   3113 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_ZERO);
   3114 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3115 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3116 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_TEMPORARY_REG1, 0);
   3117 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
   3118 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0);
   3119 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_ZERO);
   3120 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w));
   3121 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3122 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_NOT_ZERO);
   3123 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(58));
   3124 	sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3125 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w));
   3126 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_C_NOT_ZERO);
   3127 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
   3128 	sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3129 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3130 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xff08a00000));
   3131 #else
   3132 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x08a00000);
   3133 #endif
   3134 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int), SLJIT_TEMPORARY_REG1, 0);
   3135 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   3136 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3137 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3138 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xffc8a00000));
   3139 #else
   3140 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xc8a00000);
   3141 #endif
   3142 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E | SLJIT_INT_OP, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0);
   3143 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_C_ZERO);
   3144 	sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   3145 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3146 
   3147 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   3148 
   3149 	code.code = sljit_generate_code(compiler);
   3150 	CHECK(compiler);
   3151 	sljit_free_compiler(compiler);
   3152 
   3153 	code.func2((sljit_w)&buf, (sljit_w)&ibuf);
   3154 	FAILED(buf[0] != RESN(27), "test37 case 1 failed\n");
   3155 	FAILED(buf[1] != RESN(47), "test37 case 2 failed\n");
   3156 	FAILED(buf[2] != 0, "test37 case 3 failed\n");
   3157 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3158 	FAILED(buf[3] != 64, "test37 case 4 failed\n");
   3159 #else
   3160 	FAILED(buf[3] != 32, "test37 case 4 failed\n");
   3161 #endif
   3162 	FAILED(buf[4] != 1, "test37 case 5 failed\n");
   3163 	FAILED(buf[5] != 0, "test37 case 6 failed\n");
   3164 	FAILED(ibuf[0] != 32, "test37 case 7 failed\n");
   3165 	FAILED(buf[6] != 1, "test37 case 8 failed\n");
   3166 	FAILED(buf[7] != RESN(13), "test37 case 9 failed\n");
   3167 	FAILED(buf[8] != 0, "test37 case 10 failed\n");
   3168 	FAILED(buf[9] != RESN(58), "test37 case 11 failed\n");
   3169 	FAILED(buf[10] != 0, "test37 case 12 failed\n");
   3170 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3171 	FAILED(buf[11] != 64, "test37 case 13 failed\n");
   3172 #else
   3173 	FAILED(buf[11] != 32, "test37 case 13 failed\n");
   3174 #endif
   3175 	FAILED(ibuf[1] != 4, "test37 case 14 failed\n");
   3176 	FAILED(buf[12] != 4, "test37 case 15 failed\n");
   3177 	FAILED(buf[13] != 1, "test37 case 16 failed\n");
   3178 	FAILED(buf[14] != 0, "test37 case 17 failed\n");
   3179 
   3180 	sljit_free_code(code.code);
   3181 	printf("test37 ok\n");
   3182 	successful_tests++;
   3183 }
   3184 #undef BITN
   3185 #undef RESN
   3186 
   3187 static void test38(void)
   3188 {
   3189 #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
   3190 	/* Test stack utility. */
   3191 	executable_code code;
   3192 	struct sljit_compiler* compiler = sljit_create_compiler();
   3193 	struct sljit_jump* alloc_fail;
   3194 	struct sljit_jump* alloc2_fail;
   3195 	struct sljit_jump* alloc3_fail;
   3196 	struct sljit_jump* jump;
   3197 	struct sljit_label* label;
   3198 
   3199 	FAILED(!compiler, "cannot create compiler\n");
   3200 
   3201 	sljit_emit_enter(compiler, 0, 2, 1, 0);
   3202 
   3203 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8192);
   3204 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 65536);
   3205 	sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_allocate_stack));
   3206 	alloc_fail = sljit_emit_cmp(compiler, SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
   3207 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_RETURN_REG, 0);
   3208 
   3209 	/* Write 8k data. */
   3210 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
   3211 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8192);
   3212 	label = sljit_emit_label(compiler);
   3213 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
   3214 	jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3215 	sljit_set_label(jump, label);
   3216 
   3217 	/* Grow stack. */
   3218 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
   3219 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, 65536);
   3220 	sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize));
   3221 	alloc2_fail = sljit_emit_cmp(compiler, SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
   3222 
   3223 	/* Write 64k data. */
   3224 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
   3225 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 65536);
   3226 	label = sljit_emit_label(compiler);
   3227 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
   3228 	jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3229 	sljit_set_label(jump, label);
   3230 
   3231 	/* Shrink stack. */
   3232 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
   3233 	sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, 32768);
   3234 	sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize));
   3235 	alloc3_fail = sljit_emit_cmp(compiler, SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
   3236 
   3237 	/* Write 32k data. */
   3238 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
   3239 	sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, limit), SLJIT_IMM, sizeof(sljit_w));
   3240 	label = sljit_emit_label(compiler);
   3241 	sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
   3242 	jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3243 	sljit_set_label(jump, label);
   3244 
   3245 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
   3246 	sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_free_stack));
   3247 
   3248 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
   3249 	label = sljit_emit_label(compiler);
   3250 	sljit_set_label(alloc_fail, label);
   3251 	sljit_set_label(alloc2_fail, label);
   3252 	sljit_set_label(alloc3_fail, label);
   3253 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   3254 
   3255 	code.code = sljit_generate_code(compiler);
   3256 	CHECK(compiler);
   3257 	sljit_free_compiler(compiler);
   3258 
   3259 	/* Just survive this. */
   3260 	FAILED(code.func0() != 1, "test38 case 1 failed\n");
   3261 	sljit_free_code(code.code);
   3262 #endif
   3263 	printf("test38 ok\n");
   3264 	successful_tests++;
   3265 }
   3266 
   3267 static void test39(void)
   3268 {
   3269 	/* Test error handling. */
   3270 	executable_code code;
   3271 	struct sljit_compiler* compiler = sljit_create_compiler();
   3272 	struct sljit_jump* jump;
   3273 
   3274 	FAILED(!compiler, "cannot create compiler\n");
   3275 
   3276 	/* Such assignment should never happen in a regular program. */
   3277 	compiler->error = -3967;
   3278 
   3279 	SLJIT_ASSERT(sljit_emit_enter(compiler, 2, 5, 5, 32) == -3967);
   3280 	SLJIT_ASSERT(sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0) == -3967);
   3281 	SLJIT_ASSERT(sljit_emit_op0(compiler, SLJIT_NOP) == -3967);
   3282 	SLJIT_ASSERT(sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), 1) == -3967);
   3283 	SLJIT_ASSERT(sljit_emit_op2(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 64, SLJIT_MEM1(SLJIT_SAVED_REG1), -64) == -3967);
   3284 	SLJIT_ASSERT(sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0) == -3967);
   3285 	SLJIT_ASSERT(sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_SAVED_REG1), 0, SLJIT_FLOAT_REG3, 0) == -3967);
   3286 	SLJIT_ASSERT(!sljit_emit_label(compiler));
   3287 	jump = sljit_emit_jump(compiler, SLJIT_CALL3);
   3288 	SLJIT_ASSERT(!jump);
   3289 	sljit_set_label(jump, (struct sljit_label*)0x123450);
   3290 	sljit_set_target(jump, 0x123450);
   3291 	jump = sljit_emit_cmp(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3292 	SLJIT_ASSERT(!jump);
   3293 	SLJIT_ASSERT(sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 8) == -3967);
   3294 	SLJIT_ASSERT(sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_C_MUL_OVERFLOW) == -3967);
   3295 	SLJIT_ASSERT(!sljit_emit_const(compiler, SLJIT_TEMPORARY_REG1, 0, 99));
   3296 
   3297 	SLJIT_ASSERT(!compiler->labels && !compiler->jumps && !compiler->consts);
   3298 	SLJIT_ASSERT(!compiler->last_label && !compiler->last_jump && !compiler->last_const);
   3299 	SLJIT_ASSERT(!compiler->buf->next && !compiler->buf->used_size);
   3300 	SLJIT_ASSERT(!compiler->abuf->next && !compiler->abuf->used_size);
   3301 
   3302 	code.code = sljit_generate_code(compiler);
   3303 	SLJIT_ASSERT(!code.code && sljit_get_compiler_error(compiler) == -3967);
   3304 	sljit_free_compiler(compiler);
   3305 
   3306 	printf("test39 ok\n");
   3307 	successful_tests++;
   3308 }
   3309 
   3310 static void test40(void)
   3311 {
   3312 	/* Test emit_cond_value. */
   3313 	executable_code code;
   3314 	struct sljit_compiler* compiler = sljit_create_compiler();
   3315 	sljit_w buf[9];
   3316 
   3317 	FAILED(!compiler, "cannot create compiler\n");
   3318 	buf[0] = -100;
   3319 	buf[1] = -100;
   3320 	buf[2] = -100;
   3321 	buf[3] = -8;
   3322 	buf[4] = -100;
   3323 	buf[5] = -100;
   3324 	buf[6] = 0;
   3325 	buf[7] = 0;
   3326 	buf[8] = -100;
   3327 
   3328 	sljit_emit_enter(compiler, 1, 3, 4, sizeof(sljit_w));
   3329 
   3330 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
   3331 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_IMM, -6, SLJIT_TEMPORARY_REG1, 0);
   3332 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x123456);
   3333 	sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_C_SIG_LESS);
   3334 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
   3335 
   3336 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -13);
   3337 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, -13, SLJIT_TEMPORARY_REG1, 0);
   3338 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_IMM, 0);
   3339 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_C_EQUAL);
   3340 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_EQUAL);
   3341 	sljit_emit_op2(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
   3342 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
   3343 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_C_EQUAL);
   3344 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_C_EQUAL);
   3345 
   3346 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -13);
   3347 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 3);
   3348 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3349 	sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_C_SIG_LESS);
   3350 
   3351 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -8);
   3352 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 33);
   3353 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
   3354 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0);
   3355 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_C_GREATER);
   3356 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_SAVED_REG2, 0, SLJIT_C_EQUAL);
   3357 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x88);
   3358 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_SAVED_EREG1, 0, SLJIT_C_NOT_EQUAL);
   3359 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_SAVED_REG2, 0);
   3360 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_SAVED_EREG1, 0);
   3361 
   3362 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x84);
   3363 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0x180, SLJIT_TEMPORARY_REG1, 0);
   3364 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_EQUAL);
   3365 	sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_EQUAL);
   3366 
   3367 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   3368 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
   3369 	sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_C_NOT_EQUAL);
   3370 	sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_NOT_EQUAL);
   3371 
   3372 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   3373 
   3374 	code.code = sljit_generate_code(compiler);
   3375 	CHECK(compiler);
   3376 	sljit_free_compiler(compiler);
   3377 
   3378 	code.func1((sljit_w)&buf);
   3379 	FAILED(buf[0] != 0x123457, "test40 case 1 failed\n");
   3380 	FAILED(buf[1] != 1, "test40 case 2 failed\n");
   3381 	FAILED(buf[2] != 0, "test40 case 3 failed\n");
   3382 	FAILED(buf[3] != -7, "test40 case 4 failed\n");
   3383 	FAILED(buf[4] != 0, "test40 case 5 failed\n");
   3384 	FAILED(buf[5] != 0x89, "test40 case 6 failed\n");
   3385 	FAILED(buf[6] != 0, "test40 case 7 failed\n");
   3386 	FAILED(buf[7] != 1, "test40 case 8 failed\n");
   3387 	FAILED(buf[8] != 1, "test40 case 9 failed\n");
   3388 
   3389 	printf("test40 ok\n");
   3390 	successful_tests++;
   3391 }
   3392 
   3393 static void test41(void)
   3394 {
   3395 	/* Test inline assembly. */
   3396 	executable_code code;
   3397 	struct sljit_compiler* compiler = sljit_create_compiler();
   3398 	int i;
   3399 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
   3400 	sljit_ub inst[16];
   3401 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
   3402 	sljit_ub inst[16];
   3403 	int reg;
   3404 #else
   3405 	sljit_ui inst;
   3406 #endif
   3407 
   3408 	for (i = 1; i <= SLJIT_NO_REGISTERS; i++) {
   3409 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
   3410 		if (i == SLJIT_TEMPORARY_EREG1 || i == SLJIT_TEMPORARY_EREG2
   3411 				|| i == SLJIT_SAVED_EREG1 || i == SLJIT_SAVED_EREG2) {
   3412 			SLJIT_ASSERT(sljit_get_register_index(i) == -1);
   3413 			continue;
   3414 		}
   3415 #endif
   3416 		SLJIT_ASSERT(sljit_get_register_index(i) >= 0 && sljit_get_register_index(i) < 32);
   3417 	}
   3418 
   3419 	FAILED(!compiler, "cannot create compiler\n");
   3420 	sljit_emit_enter(compiler, 2, 3, 3, 0);
   3421 
   3422 	/* Returns with the sum of SLJIT_SAVED_REG1 and SLJIT_SAVED_REG2. */
   3423 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
   3424 	/* lea SLJIT_RETURN_REG, [SLJIT_SAVED_REG1, SLJIT_SAVED_REG2] */
   3425 	inst[0] = 0x48;
   3426 	inst[1] = 0x8d;
   3427 	inst[2] = 0x04 | ((sljit_get_register_index(SLJIT_RETURN_REG) & 0x7) << 3);
   3428 	inst[3] = (sljit_get_register_index(SLJIT_SAVED_REG1) & 0x7)
   3429 		| ((sljit_get_register_index(SLJIT_SAVED_REG2) & 0x7) << 3);
   3430 	sljit_emit_op_custom(compiler, inst, 4);
   3431 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
   3432 	/* lea SLJIT_RETURN_REG, [SLJIT_SAVED_REG1, SLJIT_SAVED_REG2] */
   3433 	inst[0] = 0x48; /* REX_W */
   3434 	inst[1] = 0x8d;
   3435 	inst[2] = 0x04;
   3436 	reg = sljit_get_register_index(SLJIT_RETURN_REG);
   3437 	inst[2] |= ((reg & 0x7) << 3);
   3438 	if (reg > 7)
   3439 		inst[0] |= 0x04; /* REX_R */
   3440 	reg = sljit_get_register_index(SLJIT_SAVED_REG1);
   3441 	inst[3] = reg & 0x7;
   3442 	if (reg > 7)
   3443 		inst[0] |= 0x01; /* REX_B */
   3444 	reg = sljit_get_register_index(SLJIT_SAVED_REG2);
   3445 	inst[3] |= (reg & 0x7) << 3;
   3446 	if (reg > 7)
   3447 		inst[0] |= 0x02; /* REX_X */
   3448 	sljit_emit_op_custom(compiler, inst, 4);
   3449 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
   3450 	/* add rd, rn, rm */
   3451 	inst = 0xe0800000 | (sljit_get_register_index(SLJIT_RETURN_REG) << 12)
   3452 		| (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
   3453 		| sljit_get_register_index(SLJIT_SAVED_REG2);
   3454 	sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
   3455 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
   3456 	/* add rd, rn, rm */
   3457 	inst = 0xeb000000 | (sljit_get_register_index(SLJIT_RETURN_REG) << 8)
   3458 		| (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
   3459 		| sljit_get_register_index(SLJIT_SAVED_REG2);
   3460 	sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
   3461 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
   3462 	/* add rD, rA, rB */
   3463 	inst = (31 << 26) | (266 << 1) | (sljit_get_register_index(SLJIT_RETURN_REG) << 21)
   3464 		| (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
   3465 		| (sljit_get_register_index(SLJIT_SAVED_REG2) << 11);
   3466 	sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
   3467 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   3468 	/* addu rd, rs, rt */
   3469 	inst = 33 | (sljit_get_register_index(SLJIT_RETURN_REG) << 11)
   3470 		| (sljit_get_register_index(SLJIT_SAVED_REG1) << 21)
   3471 		| (sljit_get_register_index(SLJIT_SAVED_REG2) << 16);
   3472 	sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
   3473 #else
   3474 	inst = 0;
   3475 	sljit_emit_op_custom(compiler, &inst, 0);
   3476 #endif
   3477 
   3478 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   3479 
   3480 	code.code = sljit_generate_code(compiler);
   3481 	CHECK(compiler);
   3482 	sljit_free_compiler(compiler);
   3483 
   3484 	FAILED(code.func2(32, -11) != 21, "test41 case 1 failed\n");
   3485 	FAILED(code.func2(1000, 234) != 1234, "test41 case 2 failed\n");
   3486 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3487 	FAILED(code.func2(SLJIT_W(0x20f0a04090c06070), SLJIT_W(0x020f0a04090c0607)) != SLJIT_W(0x22ffaa4499cc6677), "test41 case 3 failed\n");
   3488 #endif
   3489 
   3490 	printf("test41 ok\n");
   3491 	successful_tests++;
   3492 }
   3493 
   3494 static void test42(void)
   3495 {
   3496 	/* Test long multiply and division. */
   3497 	executable_code code;
   3498 	struct sljit_compiler* compiler = sljit_create_compiler();
   3499 	int i;
   3500 	sljit_w buf[7 + 8 + 4];
   3501 
   3502 	FAILED(!compiler, "cannot create compiler\n");
   3503 	for (i = 0; i < 7 + 8; i++)
   3504 		buf[i] = -1;
   3505 
   3506 	sljit_emit_enter(compiler, 1, 5, 5, 0);
   3507 
   3508 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -0x1fb308a);
   3509 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0xf50c873);
   3510 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0x8a0475b);
   3511 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0x9dc849b);
   3512 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -0x7c69a35);
   3513 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x5a4d0c4);
   3514 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 0x9a3b06d);
   3515 
   3516 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3517 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
   3518 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
   3519 	sljit_emit_op0(compiler, SLJIT_UMUL);
   3520 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3521 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3522 
   3523 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
   3524 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
   3525 	sljit_emit_op0(compiler, SLJIT_SMUL);
   3526 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3527 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3528 
   3529 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
   3530 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
   3531 	sljit_emit_op0(compiler, SLJIT_UDIV);
   3532 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3533 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3534 
   3535 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
   3536 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
   3537 	sljit_emit_op0(compiler, SLJIT_SDIV);
   3538 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3539 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3540 
   3541 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x5cf783d3cf0a74b0));
   3542 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3d5df42d03a28fc7));
   3543 	sljit_emit_op0(compiler, SLJIT_UDIV | SLJIT_INT_OP);
   3544 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   3545 	sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
   3546 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 15 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3547 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 16 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3548 
   3549 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x371df5197ba26a28));
   3550 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x46c78a5cfd6a420c));
   3551 	sljit_emit_op0(compiler, SLJIT_SDIV | SLJIT_INT_OP);
   3552 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
   3553 	sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
   3554 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 17 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3555 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 18 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3556 
   3557 #else
   3558 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
   3559 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
   3560 	sljit_emit_op0(compiler, SLJIT_UMUL);
   3561 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3562 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3563 
   3564 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
   3565 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
   3566 	sljit_emit_op0(compiler, SLJIT_SMUL);
   3567 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3568 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3569 
   3570 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
   3571 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
   3572 	sljit_emit_op0(compiler, SLJIT_UDIV);
   3573 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3574 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3575 
   3576 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
   3577 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
   3578 	sljit_emit_op0(compiler, SLJIT_SDIV);
   3579 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3580 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3581 
   3582 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xcf0a74b0);
   3583 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x03a28fc7);
   3584 	sljit_emit_op0(compiler, SLJIT_UDIV | SLJIT_INT_OP);
   3585 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 15 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3586 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 16 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3587 
   3588 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x7ba26a28);
   3589 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)0xfd6a420c);
   3590 	sljit_emit_op0(compiler, SLJIT_SDIV | SLJIT_INT_OP);
   3591 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 17 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
   3592 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 18 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
   3593 #endif
   3594 
   3595 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG3, 0);
   3596 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_EREG1, 0);
   3597 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_TEMPORARY_EREG2, 0);
   3598 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_REG2, 0);
   3599 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_SAVED_REG3, 0);
   3600 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
   3601 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_SAVED_EREG2, 0);
   3602 
   3603 	sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
   3604 
   3605 	code.code = sljit_generate_code(compiler);
   3606 	CHECK(compiler);
   3607 	sljit_free_compiler(compiler);
   3608 
   3609 	code.func1((sljit_w)&buf);
   3610 
   3611 	FAILED(buf[0] != -0x1fb308a, "test42 case 1 failed\n");
   3612 	FAILED(buf[1] != 0xf50c873, "test42 case 2 failed\n");
   3613 	FAILED(buf[2] != 0x8a0475b, "test42 case 3 failed\n");
   3614 	FAILED(buf[3] != 0x9dc849b, "test42 case 4 failed\n");
   3615 	FAILED(buf[4] != -0x7c69a35, "test42 case 5 failed\n");
   3616 	FAILED(buf[5] != 0x5a4d0c4, "test42 case 6 failed\n");
   3617 	FAILED(buf[6] != 0x9a3b06d, "test42 case 7 failed\n");
   3618 
   3619 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   3620 	FAILED(buf[7] != SLJIT_W(-4388959407985636971), "test42 case 8 failed\n");
   3621 	FAILED(buf[8] != SLJIT_W(2901680654366567099), "test42 case 9 failed\n");
   3622 	FAILED(buf[9] != SLJIT_W(-4388959407985636971), "test42 case 10 failed\n");
   3623 	FAILED(buf[10] != SLJIT_W(-1677173957268872740), "test42 case 11 failed\n");
   3624 	FAILED(buf[11] != SLJIT_W(2), "test42 case 12 failed\n");
   3625 	FAILED(buf[12] != SLJIT_W(2532236178951865933), "test42 case 13 failed\n");
   3626 	FAILED(buf[13] != SLJIT_W(-1), "test42 case 14 failed\n");
   3627 	FAILED(buf[14] != SLJIT_W(-2177944059851366166), "test42 case 15 failed\n");
   3628 #else
   3629 	FAILED(buf[7] != -1587000939, "test42 case 8 failed\n");
   3630 	FAILED(buf[8] != 665003983, "test42 case 9 failed\n");
   3631 	FAILED(buf[9] != -1587000939, "test42 case 10 failed\n");
   3632 	FAILED(buf[10] != -353198352, "test42 case 11 failed\n");
   3633 	FAILED(buf[11] != 2, "test42 case 12 failed\n");
   3634 	FAILED(buf[12] != 768706125, "test42 case 13 failed\n");
   3635 	FAILED(buf[13] != -1, "test42 case 14 failed\n");
   3636 	FAILED(buf[14] != -471654166, "test42 case 15 failed\n");
   3637 #endif
   3638 
   3639 	FAILED(buf[15] != SLJIT_W(56), "test42 case 16 failed\n");
   3640 	FAILED(buf[16] != SLJIT_W(58392872), "test42 case 17 failed\n");
   3641 	FAILED(buf[17] != SLJIT_W(-47), "test42 case 18 failed\n");
   3642 	FAILED(buf[18] != SLJIT_W(35949148), "test42 case 19 failed\n");
   3643 	printf("test42 ok\n");
   3644 	successful_tests++;
   3645 }
   3646 
   3647 static void test43(void)
   3648 {
   3649 	/* Test floating point compare. */
   3650 	executable_code code;
   3651 	struct sljit_compiler* compiler = sljit_create_compiler();
   3652 	struct sljit_jump* jump;
   3653 
   3654 	union {
   3655 		double value;
   3656 		struct {
   3657 			int value1;
   3658 			int value2;
   3659 		} u;
   3660 	} dbuf[4];
   3661 
   3662 	if (!sljit_is_fpu_available()) {
   3663 		printf("no fpu available, test43 skipped\n");
   3664 		successful_tests++;
   3665 		if (compiler)
   3666 			sljit_free_compiler(compiler);
   3667 		return;
   3668 	}
   3669 
   3670 	FAILED(!compiler, "cannot create compiler\n");
   3671 
   3672 	dbuf[0].value = 12.125;
   3673 	/* a NaN */
   3674 	dbuf[1].u.value1 = 0x7fffffff;
   3675 	dbuf[1].u.value2 = 0x7fffffff;
   3676 	dbuf[2].value = -13.5;
   3677 	dbuf[3].value = 12.125;
   3678 
   3679 	sljit_emit_enter(compiler, 1, 1, 1, 0);
   3680 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
   3681 	/* dbuf[0] < dbuf[2] -> -2 */
   3682 	jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_FLOAT_SHIFT);
   3683 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_IMM, -2);
   3684 
   3685 	sljit_set_label(jump, sljit_emit_label(compiler));
   3686 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
   3687 	/* dbuf[0] and dbuf[1] is not NaN -> 5 */
   3688 	jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_NAN, SLJIT_MEM0(), (sljit_w)&dbuf[1], SLJIT_FLOAT_REG2, 0);
   3689 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_IMM, 5);
   3690 
   3691 	sljit_set_label(jump, sljit_emit_label(compiler));
   3692 	sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(double));
   3693 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 11);
   3694 	/* dbuf[0] == dbuf[3] -> 11 */
   3695 	jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_EQUAL, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_FLOAT_REG3, 0);
   3696 
   3697 	/* else -> -17 */
   3698 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, -17);
   3699 	sljit_set_label(jump, sljit_emit_label(compiler));
   3700 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
   3701 
   3702 	code.code = sljit_generate_code(compiler);
   3703 	CHECK(compiler);
   3704 	sljit_free_compiler(compiler);
   3705 
   3706 	FAILED(code.func1((sljit_w)&dbuf) != 11, "test43 case 1 failed\n");
   3707 	dbuf[3].value = 12;
   3708 	FAILED(code.func1((sljit_w)&dbuf) != -17, "test43 case 2 failed\n");
   3709 	dbuf[1].value = 0;
   3710 	FAILED(code.func1((sljit_w)&dbuf) != 5, "test43 case 3 failed\n");
   3711 	dbuf[2].value = 20;
   3712 	FAILED(code.func1((sljit_w)&dbuf) != -2, "test43 case 4 failed\n");
   3713 
   3714 	printf("test43 ok\n");
   3715 	successful_tests++;
   3716 }
   3717 
   3718 void sljit_test(void)
   3719 {
   3720 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
   3721 	test_exec_allocator();
   3722 #endif
   3723 	test1();
   3724 	test2();
   3725 	test3();
   3726 	test4();
   3727 	test5();
   3728 	test6();
   3729 	test7();
   3730 	test8();
   3731 	test9();
   3732 	test10();
   3733 	test11();
   3734 	test12();
   3735 	test13();
   3736 	test14();
   3737 	test15();
   3738 	test16();
   3739 	test17();
   3740 	test18();
   3741 	test19();
   3742 	test20();
   3743 	test21();
   3744 	test22();
   3745 	test23();
   3746 	test24();
   3747 	test25();
   3748 	test26();
   3749 	test27();
   3750 	test28();
   3751 	test29();
   3752 	test30();
   3753 	test31();
   3754 	test32();
   3755 	test33();
   3756 	test34();
   3757 	test35();
   3758 	test36();
   3759 	test37();
   3760 	test38();
   3761 	test39();
   3762 	test40();
   3763 	test41();
   3764 	test42();
   3765 	test43();
   3766 	printf("On %s%s: ", sljit_get_platform_name(), sljit_is_fpu_available() ? " (+fpu)" : "");
   3767 	if (successful_tests == 43)
   3768 		printf("All tests are passed!\n");
   3769 	else
   3770 		printf("Successful test ratio: %d%%.\n", successful_tests * 100 / 43);
   3771 }
   3772