// File: /workspace/github_cpp_makefile_star2_O1/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 0x8e22(%rip), %rdi      # 0x1d1ec
xorl %eax, %eax
callq 0x1559d
leaq 0x8e2f(%rip), %rsi      # 0x1d207
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x1452c
leaq 0x8e6b(%rip), %rsi      # 0x1d25a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x1459f
leaq 0x8e74(%rip), %rsi      # 0x1d27a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
je 0x14619
leaq 0x8e7d(%rip), %rsi      # 0x1d29a
movq %r14, %rdi
callq 0x30b0
testl %eax, %eax
jne 0x1474b
movslq %ebx, %rax
movq 0xfe21(%rip), %rcx      # 0x24258
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 0x7e20(%rip), %r14      # 0x1c276
xorl %ebx, %ebx
xorl %r13d, %r13d
movzbl (%r15), %eax
cmpl $0x25, %eax
je 0x1447e
testl %eax, %eax
je 0x1473a
movsbl %al, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3040
jmp 0x1451a
movsbl 0x1(%r15), %esi
incq %r15
leal -0x63(%rsi), %eax
cmpb $0x1, %al
ja 0x144bf
cmpl %r12d, %r13d
jge 0x14509
cmpb $0x64, %sil
movq %r14, %rdi
leaq 0x7dac(%rip), %rax      # 0x1c24c
cmoveq %rax, %rdi
movl -0x2c(%rbp), %eax
subl %r13d, %eax
cltq
movq 0xfda5(%rip), %rcx      # 0x24258
movl (%rcx,%rax,4), %esi
xorl %eax, %eax
callq 0x3040
jmp 0x14517
cmpb $0x73, %sil
je 0x144ce
movzbl %sil, %eax
cmpl $0x70, %eax
jne 0x14524
cmpl %r12d, %r13d
jge 0x14509
cmpb $0x73, %sil
leaq 0x8dde(%rip), %rdi      # 0x1d2bc
leaq 0x7f11(%rip), %rax      # 0x1c3f6
cmoveq %rax, %rdi
movl -0x2c(%rbp), %eax
subl %r13d, %eax
cltq
movq 0xfd60(%rip), %rcx      # 0x24258
movslq (%rcx,%rax,4), %rax
leaq (%rcx,%rax,4), %rsi
xorl %eax, %eax
callq 0x3040
jmp 0x14517
leaq 0x8da2(%rip), %rdi      # 0x1d2b2
xorl %eax, %eax
callq 0x3040
incl %r13d
addl %eax, %ebx
incq %r15
jmp 0x1445b
movq %r14, %rdi
jmp 0x14472
movq 0xfd25(%rip), %rax      # 0x24258
movslq %ebx, %rcx
movl 0x4(%rax,%rcx,4), %r14d
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x8cd9(%rip), %rdi      # 0x1d21f
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1559d
movslq %ebx, %r15
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x142f4
leaq 0x8940(%rip), %rsi      # 0x1ceab
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
je 0x14699
leaq 0x8936(%rip), %rsi      # 0x1ceb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x1475e
movq 0xfa56(%rip), %rdi      # 0x23ff0
jmp 0x146a0
movq 0xfcb2(%rip), %rax      # 0x24258
movslq %ebx, %rcx
movslq 0x4(%rax,%rcx,4), %r14
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x8c66(%rip), %rdi      # 0x1d21f
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1559d
movslq %ebx, %r15
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x142f4
movq 0xfc7a(%rip), %r13      # 0x24258
leaq 0x88c6(%rip), %rsi      # 0x1ceab
movq %r12, %rdi
callq 0x30b0
testl %eax, %eax
je 0x146aa
leaq 0x88bc(%rip), %rsi      # 0x1ceb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x1477d
movq 0xf9dc(%rip), %r15      # 0x23ff0
jmp 0x146b1
movq 0xfc38(%rip), %rax      # 0x24258
movslq %ebx, %rcx
movl 0x4(%rax,%rcx,4), %edx
movl 0x8(%rax,%rcx,4), %ebx
leaq 0x8bed(%rip), %rdi      # 0x1d21f
movl %ebx, %esi
xorl %eax, %eax
callq 0x1559d
movslq %ebx, %r14
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x142f4
leaq 0x8857(%rip), %rsi      # 0x1ceab
movq %r15, %rdi
callq 0x30b0
testl %eax, %eax
je 0x146f3
leaq 0x884d(%rip), %rsi      # 0x1ceb8
leaq -0x50(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
jne 0x1479c
movq 0xf96d(%rip), %r14      # 0x23ff0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31b0
jmp 0x1470e
movq 0xf928(%rip), %rdi      # 0x23fc8
movl %r14d, %esi
callq 0x3310
jmp 0x14721
movq 0xf917(%rip), %r15      # 0x23fc8
testq %r13, %r13
je 0x146d9
leaq (,%r14,4), %r14
addq %r13, %r14
movq %r14, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3210
jmp 0x14721
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3300
jmp 0x14721
movq 0xf8ce(%rip), %r14      # 0x23fc8
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 0x1473a
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 0x8b6a(%rip), %rdi      # 0x1d2bf
xorl %eax, %eax
callq 0x1585f
jmp 0x147b9
movq 0xfaf3(%rip), %rax      # 0x24258
movl (%rax,%r15,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x8ac1(%rip), %rdi      # 0x1d235
xorl %eax, %eax
callq 0x1585f
jmp 0x147b9
movq 0xfad4(%rip), %rax      # 0x24258
movl (%rax,%r15,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x8aa2(%rip), %rdi      # 0x1d235
xorl %eax, %eax
callq 0x1585f
jmp 0x147b9
movq 0xfab5(%rip), %rax      # 0x24258
movl (%rax,%r14,4), %esi
movq -0x50(%rbp), %rdx
leaq 0x8a83(%rip), %rdi      # 0x1d235
xorl %eax, %eax
callq 0x1585f
movl $0x1, %edi
callq 0x3230
jmp 0x147c7
jmp 0x147c7
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x147e3
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3320