// File: nmmmnu[P]HM3/test/test_stringref.cc
// Function: test_stringref(char const*, StringRef const&)
static void test_stringref(const char *module, const StringRef &sr){
	PRINTF_TEST("! empty",		! sr.empty()				);

	PRINTF_TEST("size",		sr.size() == strlen(hello)		);
	PRINTF_TEST("size",		sr.length() == strlen(hello)		);

	PRINTF_TEST("data",		strcmp(sr.data(), hello) == 0		);
	PRINTF_TEST("data",		strcmp(sr.c_str(), hello) == 0		);

	PRINTF_TEST("cmp char * MO",	sr.compare("bello") != 0		);
	PRINTF_TEST("cmp char *",	sr.compare(hello) == 0			);
	PRINTF_TEST("cmp char []",	sr.compare(hello_c) == 0		);
	PRINTF_TEST("cmp string",	sr.compare(std::string(hello)) == 0	);
	PRINTF_TEST("cmp StringRef",	sr.compare(StringRef(hello)) == 0	);

	PRINTF_TEST("cmp ___",		sr.compare("_aaaa") > 0			);
	PRINTF_TEST("cmp ~~~",		sr.compare("~aaaa") < 0			);

	PRINTF_TEST("== char *",	sr == hello				);
	PRINTF_TEST("== char []",	sr == hello_c				);
	PRINTF_TEST("== string",	sr == std::string(hello)		);
	PRINTF_TEST("== StringRef",	sr == StringRef(hello)			);

	PRINTF_TEST("eq char *",	sr.equals(hello, strlen(hello))		);

	PRINTF_TEST("|= char *",	sr != bla				);
	PRINTF_TEST("!= char []",	sr != bla_c				);
	PRINTF_TEST("|= string",	sr != std::string(bla)			);
	PRINTF_TEST("|= StringRef",	sr != StringRef(bla)			);

	PRINTF_TEST("[] char *",	sr[0] == hello[0]			);

	size_t i = 0;
	for(auto it = sr.begin(); it < sr.end(); ++it){
		PRINTF_TEST("iterator",	sr[i] == *it				);
		++i;
	}

	std::cout <<  sr << '\n';
}

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movq %rdi, 0x290(%rsp)
movq %rsi, 0x288(%rsp)
movq 0x290(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x288(%rsp), %rdi
callq 0x2f00
movq 0x120(%rsp), %rsi
movb %al, %dl
leaq 0x21f4(%rip), %rax      # 0x4069
movq %rax, 0x178(%rsp)
leaq 0x21e2(%rip), %rcx      # 0x4066
movq %rcx, 0x180(%rsp)
testb %dl, %dl
cmovneq %rax, %rcx
leaq 0x21b5(%rip), %rdi      # 0x404e
movq %rdi, 0x188(%rsp)
leaq 0x21c6(%rip), %rdx      # 0x406e
xorl %eax, %eax
movb %al, 0x19f(%rsp)
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x288(%rsp), %rdi
callq 0x2ee0
movq %rax, 0x128(%rsp)
movq 0x41ee(%rip), %rdi      # 0x60d0
callq 0x1070
movq 0x128(%rsp), %r8
movq 0x130(%rsp), %rsi
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rdx
movq 0x188(%rsp), %rdi
movq %rax, %r9
movb 0x19f(%rsp), %al
subq %r9, %r8
cmoveq %rdx, %rcx
leaq 0x227e(%rip), %rdx      # 0x41a5
movq %rdx, 0x148(%rsp)
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x288(%rsp), %rdi
callq 0x3250
movq %rax, 0x138(%rsp)
movq 0x4170(%rip), %rdi      # 0x60d0
callq 0x1070
movq 0x138(%rsp), %r9
movq 0x140(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %r8
movq 0x188(%rsp), %rdi
movq %rax, %r10
movb 0x19f(%rsp), %al
subq %r10, %r9
cmoveq %r8, %rcx
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x288(%rsp), %rdi
callq 0x2ef0
movq %rax, %rdi
movq 0x40fe(%rip), %rsi      # 0x60d0
callq 0x1120
movq 0x150(%rsp), %rsi
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rdx
movq 0x188(%rsp), %rdi
movl %eax, %r8d
movb 0x19f(%rsp), %al
testl %r8d, %r8d
cmoveq %rdx, %rcx
leaq 0x2187(%rip), %rdx      # 0x4196
movq %rdx, 0x160(%rsp)
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x288(%rsp), %rdi
callq 0x3260
movq %rax, %rdi
movq 0x408d(%rip), %rsi      # 0x60d0
callq 0x1120
movq 0x158(%rsp), %rsi
movq 0x160(%rsp), %rdx
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %r8
movq 0x188(%rsp), %rdi
movl %eax, %r9d
movb 0x19f(%rsp), %al
testl %r9d, %r9d
cmoveq %r8, %rcx
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x2024(%rip), %rsi      # 0x40c9
callq 0x3270
movq 0x168(%rsp), %rsi
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rdx
movq 0x188(%rsp), %rdi
movl %eax, %r8d
movb 0x19f(%rsp), %al
testl %r8d, %r8d
cmovneq %rdx, %rcx
leaq 0x1fd9(%rip), %rdx      # 0x40bb
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x288(%rsp), %rdi
movq 0x3fca(%rip), %rsi      # 0x60d0
callq 0x3270
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rdx
movq 0x188(%rsp), %rdi
movl %eax, %r8d
movb 0x19f(%rsp), %al
testl %r8d, %r8d
cmoveq %rdx, %rcx
leaq 0x1f8c(%rip), %rdx      # 0x40cf
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x205e(%rip), %rsi      # 0x41c5
callq 0x3270
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rdx
movq 0x188(%rsp), %rdi
movq 0x190(%rsp), %rsi
movl %eax, %r8d
movb 0x19f(%rsp), %al
testl %r8d, %r8d
cmoveq %rdx, %rcx
leaq 0x1f36(%rip), %rdx      # 0x40da
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x3f00(%rip), %rax      # 0x60d0
movq %rax, 0x1b0(%rsp)
leaq 0x267(%rsp), %rdi
movq %rdi, 0x1b8(%rsp)
callq 0x1150
movq 0x1b0(%rsp), %rsi
movq 0x1b8(%rsp), %rdx
leaq 0x268(%rsp), %rdi
callq 0x1110
jmp 0x220c
movq 0x1a8(%rsp), %rdi
leaq 0x268(%rsp), %rsi
callq 0x32c0
movq 0x1a0(%rsp), %rsi
testl %eax, %eax
leaq 0x1e34(%rip), %rax      # 0x4066
leaq 0x1e30(%rip), %rcx      # 0x4069
cmoveq %rax, %rcx
leaq 0x1e0a(%rip), %rdi      # 0x404e
leaq 0x1e9b(%rip), %rdx      # 0x40e6
xorl %eax, %eax
callq 0x1030
jmp 0x2254
leaq 0x268(%rsp), %rdi
callq 0x1090
leaq 0x267(%rsp), %rdi
callq 0x10c0
movq 0x290(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x3e3b(%rip), %rsi      # 0x60d0
leaq 0x240(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x2b90
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x3310
movq 0xb8(%rsp), %rsi
testl %eax, %eax
leaq 0x1d96(%rip), %rax      # 0x4066
movq %rax, 0xe0(%rsp)
leaq 0x1d8a(%rip), %rcx      # 0x4069
movq %rcx, 0xd8(%rsp)
cmoveq %rax, %rcx
leaq 0x1d5c(%rip), %rdi      # 0x404e
movq %rdi, 0xe8(%rsp)
leaq 0x1df0(%rip), %rdx      # 0x40f1
xorl %eax, %eax
movb %al, 0xff(%rsp)
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x1dd9(%rip), %rsi      # 0x4107
callq 0x3270
movq 0xc0(%rsp), %rsi
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movl %eax, %r8d
movb 0xff(%rsp), %al
testl %r8d, %r8d
cmovgq %rdx, %rcx
leaq 0x1d94(%rip), %rdx      # 0x40ff
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x1d86(%rip), %rsi      # 0x4115
callq 0x3270
movq 0xc8(%rsp), %rsi
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movl %eax, %r8d
movb 0xff(%rsp), %al
testl %r8d, %r8d
cmovsq %rdx, %rcx
leaq 0x1d41(%rip), %rdx      # 0x410d
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x288(%rsp), %rdi
movq 0x3ce0(%rip), %rsi      # 0x60d0
callq 0x2f60
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movb %al, %r8b
movb 0xff(%rsp), %al
testb %r8b, %r8b
cmovneq %rdx, %rcx
leaq 0x1cee(%rip), %rdx      # 0x411b
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x1d74(%rip), %rsi      # 0x41c5
callq 0x2f60
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movb %al, %r8b
movb 0xff(%rsp), %al
testb %r8b, %r8b
cmovneq %rdx, %rcx
leaq 0x1c97(%rip), %rdx      # 0x4125
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x3c16(%rip), %rax      # 0x60d0
movq %rax, 0x110(%rsp)
leaq 0x21f(%rsp), %rdi
movq %rdi, 0x118(%rsp)
callq 0x1150
movq 0x110(%rsp), %rsi
movq 0x118(%rsp), %rdx
leaq 0x220(%rsp), %rdi
callq 0x1110
jmp 0x24f6
movq 0x108(%rsp), %rdi
leaq 0x220(%rsp), %rsi
callq 0x2fb0
movq 0x100(%rsp), %rsi
movb %al, %dl
leaq 0x1b4a(%rip), %rax      # 0x4066
leaq 0x1b46(%rip), %rcx      # 0x4069
testb %dl, %dl
cmovneq %rax, %rcx
leaq 0x1b1e(%rip), %rdi      # 0x404e
leaq 0x1bf9(%rip), %rdx      # 0x4130
xorl %eax, %eax
callq 0x1030
jmp 0x2540
leaq 0x220(%rsp), %rdi
callq 0x1090
leaq 0x21f(%rsp), %rdi
callq 0x10c0
movq 0x290(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x3b55(%rip), %rsi      # 0x60d0
leaq 0x208(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x2b90
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3000
movq 0x38(%rsp), %rsi
movb %al, %dl
leaq 0x1abc(%rip), %rax      # 0x4066
movq %rax, 0x68(%rsp)
leaq 0x1ab3(%rip), %rcx      # 0x4069
movq %rcx, 0x60(%rsp)
testb %dl, %dl
cmovneq %rax, %rcx
leaq 0x1a86(%rip), %rdi      # 0x404e
movq %rdi, 0x70(%rsp)
leaq 0x1b66(%rip), %rdx      # 0x413a
xorl %eax, %eax
movb %al, 0x87(%rsp)
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x3acd(%rip), %rdi      # 0x60d0
movq %rdi, 0x48(%rsp)
callq 0x1070
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rax, %rdx
callq 0x30a0
movq 0x50(%rsp), %rsi
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rdi
movb %al, %r8b
movb 0x87(%rsp), %al
testb %r8b, %r8b
cmovneq %rdx, %rcx
leaq 0x1a40(%rip), %rdx      # 0x408b
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x288(%rsp), %rdi
movq 0x3a5c(%rip), %rsi      # 0x60c8
callq 0x3360
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rdi
movb %al, %r8b
movb 0x87(%rsp), %al
testb %r8b, %r8b
cmovneq %rdx, %rcx
leaq 0x1aaa(%rip), %rdx      # 0x4147
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x1b0d(%rip), %rsi      # 0x41cb
callq 0x3360
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
movb %al, %r8b
movb 0x87(%rsp), %al
testb %r8b, %r8b
cmovneq %rdx, %rcx
leaq 0x1a62(%rip), %rdx      # 0x4151
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x39ad(%rip), %rax      # 0x60c8
movq %rax, 0x98(%rsp)
leaq 0x1e7(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x1150
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x1e8(%rsp), %rdi
callq 0x1110
jmp 0x2757
movq 0x90(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x3390
movq 0x88(%rsp), %rsi
movb %al, %dl
leaq 0x18e9(%rip), %rax      # 0x4066
leaq 0x18e5(%rip), %rcx      # 0x4069
testb %dl, %dl
cmovneq %rax, %rcx
leaq 0x18bd(%rip), %rdi      # 0x404e
leaq 0x19c4(%rip), %rdx      # 0x415c
xorl %eax, %eax
callq 0x1030
jmp 0x27a1
leaq 0x1e8(%rsp), %rdi
callq 0x1090
leaq 0x1e7(%rsp), %rdi
callq 0x10c0
movq 0x290(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38ec(%rip), %rsi      # 0x60c8
leaq 0x1d0(%rsp), %rdi
callq 0x2b90
movq 0x10(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x33c0
movq 0x18(%rsp), %rsi
movb %al, %dl
leaq 0x1860(%rip), %rcx      # 0x4069
leaq 0x1856(%rip), %rax      # 0x4066
testb $0x1, %dl
cmovneq %rax, %rcx
leaq 0x1830(%rip), %rdi      # 0x404e
leaq 0x1941(%rip), %rdx      # 0x4166
movb $0x0, %al
callq 0x1030
movq 0x290(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x288(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x33f0
movq 0x20(%rsp), %rsi
movsbl (%rax), %edx
movq 0x3877(%rip), %rax      # 0x60d0
movsbl (%rax), %edi
leaq 0x1806(%rip), %rcx      # 0x4069
leaq 0x17fc(%rip), %rax      # 0x4066
cmpl %edi, %edx
cmoveq %rax, %rcx
leaq 0x17d7(%rip), %rdi      # 0x404e
leaq 0x18f5(%rip), %rdx      # 0x4173
movb $0x0, %al
callq 0x1030
movq $0x0, 0x1c8(%rsp)
movq 0x288(%rsp), %rdi
callq 0x3410
movq %rax, 0x1c0(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x288(%rsp), %rdi
callq 0x3420
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x2a2f
movq 0x290(%rsp), %rax
movq %rax, (%rsp)
movq 0x288(%rsp), %rdi
movq 0x1c8(%rsp), %rsi
callq 0x33f0
movq (%rsp), %rsi
movsbl (%rax), %edx
movq 0x1c0(%rsp), %rax
movsbl (%rax), %edi
leaq 0x175e(%rip), %rcx      # 0x4069
leaq 0x1754(%rip), %rax      # 0x4066
cmpl %edi, %edx
cmoveq %rax, %rcx
leaq 0x172f(%rip), %rdi      # 0x404e
leaq 0x1857(%rip), %rdx      # 0x417d
movb $0x0, %al
callq 0x1030
movq 0x1c8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c8(%rsp)
movq 0x1c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c0(%rsp)
jmp 0x28a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0x2991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x1090
leaq 0x267(%rsp), %rdi
callq 0x10c0
jmp 0x2a58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0x29da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x1090
leaq 0x21f(%rsp), %rdi
callq 0x10c0
jmp 0x2a58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0x2a20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x1090
leaq 0x1e7(%rsp), %rdi
callq 0x10c0
jmp 0x2a58
movq 0x288(%rsp), %rsi
movq 0x359a(%rip), %rdi      # 0x5fd8
callq 0x3440
movq %rax, %rdi
movl $0xa, %esi
callq 0x10e0
addq $0x298, %rsp            # imm = 0x298
retq
movq 0x258(%rsp), %rdi
callq 0x1140
nopw %cs:(%rax,%rax)