// File: /workspace/github_cpp_makefile_star2_O3/yanlinlin82[P]icpp/icpp.cpp
// Function: call_ext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
int call_ext(const string& name, int sp)
{
	log<3>("[DEBUG] external call: %s\n", name.c_str());
	if (name == "operator<<(ostream,int)") {
		int b = m[sp + 1];
		int a = m[sp + 2];
		log<3>("[DEBUG] args: %d, %d\n", a, b);
		string aa = get_data_symbol(a);
		if (aa == "cout") {
			cout << b;
		} else if (aa == "cerr") {
			cerr << b;
		} else {
			err("Unsupported operator<< for %d('%s')\n", m[a], aa.c_str());
			exit(1);
		}
		return a;
	} else if (name == "operator<<(ostream,const char*)") {
		int b = m[sp + 1];
		int a = m[sp + 2];
		log<3>("[DEBUG] args: %d, %d\n", a, b);
		string aa = get_data_symbol(a);
		const char* s = reinterpret_cast<const char*>(&m[b]);
		if (aa == "cout") {
			cout << s;
		} else if (aa == "cerr") {
			cerr << s;
		} else {
			err("Unsupported operator<< for %d('%s')\n", m[a], aa.c_str());
			exit(1);
		}
		return a;
	} else if (name == "operator<<(ostream,(*)(endl_t))") {
		int b = m[sp + 1];
		int a = m[sp + 2];
		log<3>("[DEBUG] args: %d, %d\n", a, b);
		string aa = get_data_symbol(a);
		if (aa == "cout") {
			cout << endl;
		} else if (aa == "cerr") {
			cerr << endl;
		} else {
			err("Unsupported operator<< for %d('%s')\n", m[a], aa.c_str());
			exit(1);
		}
		return a;
	} else if (name == "printf(const char*,...)") {
		int var_arg_count = m[sp + 1];
		int var_arg_start = sp + 1 + var_arg_count;
		const char* fmt = reinterpret_cast<const char*>(&m[m[var_arg_start + 1]]);
		int n = 0;
		for (int i = 0; *fmt; ++fmt) {
			if (*fmt == '%') {
				char c = *++fmt;
				if (c == 'd' || c == 'c') {
					if (i >= var_arg_count) { n += printf("<missing>"); }
					else { n += printf((c == 'd' ? "%d" : "%c"), m[var_arg_start - i]); }
					++i;
				} else if (c == 's' || c == 'p') {
					if (i >= var_arg_count) { n += printf("<missing>"); }
					else { n += printf((c == 's' ? "%s" : "%p"), reinterpret_cast<const char*>(&m[m[var_arg_start - i]])); }
					++i;
				} else {
					n += printf("%c", c);
				}
			} else {
				n += printf("%c", *fmt);
			}
		}
		return n;
	} else {
		err("Unsupported function '%s'\n", name.c_str());
		exit(1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rsi
leaq 0x80ed(%rip), %rdi      # 0x1c1ec
xorl %eax, %eax
callq 0x151ad
leaq 0x80fa(%rip), %rsi      # 0x1c207
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x14261
leaq 0x8136(%rip), %rsi      # 0x1c25a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x142d4
leaq 0x813f(%rip), %rsi      # 0x1c27a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x1434e
leaq 0x8148(%rip), %rsi      # 0x1c29a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x14480
movslq %ebx, %rax
movq 0xf0ec(%rip), %rcx      # 0x23258
movl 0x4(%rcx,%rax,4), %r12d
addl %r12d, %eax
incl %eax
movl %eax, -0x2c(%rbp)
cltq
movslq 0x4(%rcx,%rax,4), %rax
leaq (%rcx,%rax,4), %r15
leaq 0x70eb(%rip), %r14      # 0x1b276
xorl %ebx, %ebx
xorl %r13d, %r13d
movzbl (%r15), %eax
cmpl $0x25, %eax
je 0x141b3
testl %eax, %eax
je 0x1446f
movsbl %al, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3040
jmp 0x1424f
movsbl 0x1(%r15), %esi
incq %r15
leal -0x63(%rsi), %eax
cmpb $0x1, %al
ja 0x141f4
cmpl %r12d, %r13d
jge 0x1423e
cmpb $0x64, %sil
movq %r14, %rdi
leaq 0x7077(%rip), %rax      # 0x1b24c
cmoveq %rax, %rdi
movl -0x2c(%rbp), %eax
subl %r13d, %eax
cltq
movq 0xf070(%rip), %rcx      # 0x23258
movl (%rcx,%rax,4), %esi
xorl %eax, %eax
callq 0x3040
jmp 0x1424c
cmpb $0x73, %sil
je 0x14203
movzbl %sil, %eax
cmpl $0x70, %eax
jne 0x14259
cmpl %r12d, %r13d
jge 0x1423e
cmpb $0x73, %sil
leaq 0x80a9(%rip), %rdi      # 0x1c2bc
leaq 0x71dc(%rip), %rax      # 0x1b3f6
cmoveq %rax, %rdi
movl -0x2c(%rbp), %eax
subl %r13d, %eax
cltq
movq 0xf02b(%rip), %rcx      # 0x23258
movslq (%rcx,%rax,4), %rax
leaq (%rcx,%rax,4), %rsi
xorl %eax, %eax
callq 0x3040
jmp 0x1424c
leaq 0x806d(%rip), %rdi      # 0x1c2b2
xorl %eax, %eax
callq 0x3040
incl %r13d
addl %eax, %ebx
incq %r15
jmp 0x14190
movq %r14, %rdi
jmp 0x141a7
movq 0xeff0(%rip), %rax      # 0x23258
movslq %ebx, %rcx
movl 0x4(%rax,%rcx,4), %r14d
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x7fa4(%rip), %rdi      # 0x1c21f
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x151ad
movslq %ebx, %r15
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1407b
leaq 0x7c0b(%rip), %rsi      # 0x1beab
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
je 0x143ce
leaq 0x7c01(%rip), %rsi      # 0x1beb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x14493
movq 0xed21(%rip), %rdi      # 0x22ff0
jmp 0x143d5
movq 0xef7d(%rip), %rax      # 0x23258
movslq %ebx, %rcx
movslq 0x4(%rax,%rcx,4), %r14
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x7f31(%rip), %rdi      # 0x1c21f
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x151ad
movslq %ebx, %r15
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1407b
movq 0xef45(%rip), %r13      # 0x23258
leaq 0x7b91(%rip), %rsi      # 0x1beab
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
je 0x143df
leaq 0x7b87(%rip), %rsi      # 0x1beb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x144b2
movq 0xeca7(%rip), %r15      # 0x22ff0
jmp 0x143e6
movq 0xef03(%rip), %rax      # 0x23258
movslq %ebx, %rcx
movl 0x4(%rax,%rcx,4), %edx
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x7eb8(%rip), %rdi      # 0x1c21f
movl %ebx, %esi
xorl %eax, %eax
callq 0x151ad
movslq %ebx, %r14
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1407b
leaq 0x7b22(%rip), %rsi      # 0x1beab
movq %r15, %rdi
callq 0x30b0
testl %eax, %eax
je 0x14428
leaq 0x7b18(%rip), %rsi      # 0x1beb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x144d1
movq 0xec38(%rip), %r14      # 0x22ff0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31b0
jmp 0x14443
movq 0xebf3(%rip), %rdi      # 0x22fc8
movl %r14d, %esi
callq 0x3310
jmp 0x14456
movq 0xebe2(%rip), %r15      # 0x22fc8
testq %r13, %r13
je 0x1440e
leaq (,%r14,4), %r14
addq %r13, %r14
movq %r14, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3210
jmp 0x14456
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3300
jmp 0x14456
movq 0xeb99(%rip), %r14      # 0x22fc8
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1446f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31d0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
leaq 0x7e35(%rip), %rdi      # 0x1c2bf
xorl %eax, %eax
callq 0x1546f
jmp 0x144ee
movq 0xedbe(%rip), %rax      # 0x23258
movl (%rax,%r15,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x7d8c(%rip), %rdi      # 0x1c235
xorl %eax, %eax
callq 0x1546f
jmp 0x144ee
movq 0xed9f(%rip), %rax      # 0x23258
movl (%rax,%r15,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x7d6d(%rip), %rdi      # 0x1c235
xorl %eax, %eax
callq 0x1546f
jmp 0x144ee
movq 0xed80(%rip), %rax      # 0x23258
movl (%rax,%r14,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x7d4e(%rip), %rdi      # 0x1c235
xorl %eax, %eax
callq 0x1546f
movl $0x1, %edi
callq 0x3230
jmp 0x144fc
jmp 0x144fc
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14518
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3320