// File: /workspace/github_cpp_makefile_star2_O2/ChanTsune[P]py_string/example.cpp
// Function: main
int main(int argc, char const *argv[])
{
  using namespace std;
  // string multiplication
  py::string multiplication = "hello world!";

  std::cout << multiplication * 2 << std::endl;
  // hello world!hello world!

  // Subscript operator
  py::string Subscript_operator = "0123456789";

  cout << Subscript_operator[0] << endl;

  cout << Subscript_operator[-1] << endl; // last element

  cout << Subscript_operator[-3] << endl; // third element from the back (7)

  // string slice
  py::string slice = "0123456789";

  cout << slice.slice(0, 20, 2) << endl;
  cout << slice.slice(0, 20, -2) << endl;
  cout << slice[{ 4, py::nullopt }] << endl;

  // string format
  py::string format = "{} is {} than {}";

  cout << format.format(3, "bigger", 1) << endl;

  cout << format.format(2, "smaller", 4) << endl;

  py::string format2 = "{0} is {1} as {0}";

  cout << format2.format(2, "same") << endl;

  // string replace

  py::string replace = "1+2-3";

  cout << replace.pyreplace("-", "=");
  // 1+2=3

  // string split
  py::string split = "12,3,4-2,2,3";
  std::deque<py::string> slist; // std::vector is also acceptable

  split.split(slist, ",");

  for (auto &&s : slist) {
    cout << s << endl;
  }
  // Check ASCII character string
  py::string ascii = "Hello World!";
  cout << std::boolalpha << ascii.isascii() << endl;

  py::string not_ascii = "ハローワールド！";
  cout << std::boolalpha << not_ascii.isascii() << endl;

  // translate
  py::string tstr = "text abc so cool.";
  auto table = py::string::maketrans("abcd", "ABCD", ".");
  std::unordered_map<char, py::string> _t;
  _t['.'] = "!!";
  _t['s'] = "";
  _t['o'] = "O";

  auto table2 = py::string::maketrans(_t);

  cout << tstr.translate(table) << endl;

  cout << tstr.translate(table2) << endl;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
leaq 0x12a13(%rip), %rsi     # 0x1715a
leaq -0x340(%rbp), %rbx
leaq -0x78(%rbp), %rdx
movq %rbx, %rdi
callq 0x4120
leaq -0x78(%rbp), %rdi
pushq $0x2
popq %rdx
movq %rbx, %rsi
callq 0x5102
movq 0x1e848(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq 0x129d6(%rip), %rsi     # 0x17167
leaq -0xb8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
movq -0xb8(%rbp), %rax
movsbl (%rax), %esi
movq 0x1e806(%rip), %rdi     # 0x22fb8
callq 0x43a0
movq %rax, %rdi
callq 0x4190
movq -0xb8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movsbl -0x1(%rax,%rcx), %esi
movq 0x1e7df(%rip), %rdi     # 0x22fb8
callq 0x43a0
movq %rax, %rdi
callq 0x4190
movq -0xb8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movsbl -0x3(%rax,%rcx), %esi
movq 0x1e7b8(%rip), %rdi     # 0x22fb8
callq 0x43a0
movq %rax, %rdi
callq 0x4190
leaq 0x12953(%rip), %rsi     # 0x17167
leaq -0xd8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
leaq -0x78(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movabsq $0x100000000, %rdx      # imm = 0x100000000
movabsq $0x100000014, %rcx      # imm = 0x100000014
movabsq $0x100000002, %r8       # imm = 0x100000002
callq 0x517a
movq 0x1e75f(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq -0x78(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movabsq $0x100000000, %rdx      # imm = 0x100000000
movabsq $0x100000014, %rcx      # imm = 0x100000014
movabsq $0x1fffffffe, %r8       # imm = 0x1FFFFFFFE
callq 0x517a
movq 0x1e710(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq -0x110(%rbp), %rdx
movl $0x4, (%rdx)
movb $0x1, 0x4(%rdx)
movb $0x0, 0xc(%rdx)
leaq -0x78(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
pushq $0x2
popq %rcx
callq 0x5260
movq 0x1e6c7(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq 0x12860(%rip), %rsi     # 0x17172
leaq -0x188(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
leaq 0x1285a(%rip), %rcx     # 0x17183
leaq -0x78(%rbp), %rdi
leaq -0x188(%rbp), %rsi
pushq $0x3
popq %rdx
pushq $0x1
popq %r8
callq 0x52ec
movq 0x1e671(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq 0x12822(%rip), %rcx     # 0x1718a
leaq -0x78(%rbp), %rdi
leaq -0x188(%rbp), %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
callq 0x52ec
movq 0x1e632(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq 0x127eb(%rip), %rsi     # 0x17192
leaq -0x320(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
leaq 0x127e6(%rip), %rcx     # 0x171a4
leaq -0x78(%rbp), %rdi
leaq -0x320(%rbp), %rsi
pushq $0x2
popq %rdx
callq 0x53f8
movq 0x1e5e0(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq 0x127b0(%rip), %rsi     # 0x171a9
leaq -0x300(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
leaq 0x1279f(%rip), %rsi     # 0x171af
leaq -0x2e0(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4120
leaq 0x12787(%rip), %rsi     # 0x171b1
leaq -0x2c0(%rbp), %rdi
leaq -0x148(%rbp), %rdx
callq 0x4120
leaq -0x78(%rbp), %rdi
leaq -0x300(%rbp), %rsi
leaq -0x2e0(%rbp), %rdx
leaq -0x2c0(%rbp), %rcx
pushq $-0x1
popq %r8
callq 0x54f8
movq 0x1e552(%rip), %rdi     # 0x22fb8
leaq -0x78(%rbp), %rsi
callq 0x42d0
leaq -0x78(%rbp), %rdi
callq 0x4170
leaq -0x2c0(%rbp), %rdi
callq 0x4170
leaq -0x2e0(%rbp), %rdi
callq 0x4170
leaq 0x1271c(%rip), %rsi     # 0x171b3
leaq -0x2a0(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4120
leaq -0x78(%rbp), %rdi
callq 0x58d4
leaq 0x12709(%rip), %rsi     # 0x171c0
leaq -0x280(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4120
leaq -0x2a0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x280(%rbp), %rdx
pushq $-0x1
popq %rcx
callq 0x55a2
leaq -0x280(%rbp), %rdi
callq 0x4170
movq -0x68(%rbp), %r14
movq -0x58(%rbp), %r13
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %r12
movq 0x1e4b1(%rip), %rbx     # 0x22fb8
cmpq %r12, %r14
je 0x4b39
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
addq $0x20, %r14
cmpq %r13, %r14
jne 0x4b07
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r13
jmp 0x4b07
leaq 0x12682(%rip), %rsi     # 0x171c2
leaq -0x260(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4120
movq (%rbx), %rax
movq -0x18(%rax), %rax
orl $0x1, 0x18(%rbx,%rax)
leaq -0x260(%rbp), %rdi
callq 0x56b2
movzbl %al, %esi
movq 0x1e443(%rip), %rbx     # 0x22fb8
movq %rbx, %rdi
callq 0x44f0
movq %rax, %rdi
callq 0x4190
leaq 0x12643(%rip), %rsi     # 0x171cf
leaq -0x240(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4120
movq (%rbx), %rax
movq -0x18(%rax), %rax
orl $0x1, 0x18(%rbx,%rax)
leaq -0x240(%rbp), %rdi
callq 0x56b2
movzbl %al, %esi
movq 0x1e3f7(%rip), %rdi     # 0x22fb8
callq 0x44f0
movq %rax, %rdi
callq 0x4190
leaq 0x12613(%rip), %rsi     # 0x171e8
leaq -0x168(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4120
leaq 0x1260b(%rip), %rsi     # 0x171fa
leaq -0x220(%rbp), %rdi
leaq -0x148(%rbp), %rdx
callq 0x4120
leaq 0x125f6(%rip), %rsi     # 0x171ff
leaq -0x200(%rbp), %rdi
leaq -0x1c0(%rbp), %rdx
callq 0x4120
leaq 0x1292f(%rip), %rsi     # 0x17552
leaq -0x1e0(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x4120
leaq -0x110(%rbp), %rdi
leaq -0x220(%rbp), %rsi
leaq -0x200(%rbp), %rdx
leaq -0x1e0(%rbp), %rcx
callq 0x56dc
leaq -0x1e0(%rbp), %rdi
callq 0x4170
leaq -0x200(%rbp), %rdi
callq 0x4170
leaq -0x220(%rbp), %rdi
callq 0x4170
leaq -0x118(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq -0x1c0(%rbp), %rsi
movb $0x2e, (%rsi)
leaq -0x148(%rbp), %rdi
callq 0x1692c
leaq 0x12547(%rip), %rsi     # 0x17204
movq %rax, %rdi
callq 0x4590
leaq -0x1c0(%rbp), %rsi
movb $0x73, (%rsi)
leaq -0x148(%rbp), %rdi
callq 0x1692c
leaq 0x12595(%rip), %rsi     # 0x17277
movq %rax, %rdi
callq 0x4590
leaq -0x1c0(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x148(%rbp), %rdi
callq 0x1692c
leaq 0x12aaa(%rip), %rsi     # 0x177b1
movq %rax, %rdi
callq 0x4590
leaq -0x378(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x5b06
leaq -0x1c0(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x16a12
leaq -0x378(%rbp), %rdi
callq 0x5ef4
leaq -0x98(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x57cc
movq 0x1e256(%rip), %rdi     # 0x22fb8
leaq -0x98(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x98(%rbp), %rdi
callq 0x4170
leaq -0x98(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x57cc
movq 0x1e215(%rip), %rdi     # 0x22fb8
leaq -0x98(%rbp), %rsi
callq 0x42d0
movq %rax, %rdi
callq 0x4190
leaq -0x98(%rbp), %rdi
callq 0x4170
leaq -0x1c0(%rbp), %rdi
callq 0x5ef4
leaq -0x148(%rbp), %rdi
callq 0x5ef4
leaq -0x110(%rbp), %rdi
callq 0x5ef4
leaq -0x168(%rbp), %rdi
callq 0x4170
leaq -0x240(%rbp), %rdi
callq 0x4170
leaq -0x260(%rbp), %rdi
callq 0x4170
leaq -0x78(%rbp), %rdi
callq 0x5854
leaq -0x2a0(%rbp), %rdi
callq 0x4170
leaq -0x300(%rbp), %rdi
callq 0x4170
leaq -0x320(%rbp), %rdi
callq 0x4170
leaq -0x188(%rbp), %rdi
callq 0x4170
leaq -0xd8(%rbp), %rdi
callq 0x4170
leaq -0xb8(%rbp), %rdi
callq 0x4170
leaq -0x340(%rbp), %rdi
callq 0x4170
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4e7e
movq %rax, %rbx
jmp 0x4f7f
movq %rax, %rbx
leaq -0x378(%rbp), %rdi
jmp 0x4f86
jmp 0x4f91
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x4170
jmp 0x4eae
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x4170
jmp 0x4ebf
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x4170
jmp 0x4fac
movq %rax, %rbx
jmp 0x4fac
jmp 0x4ffc
jmp 0x5001
jmp 0x500b
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
jmp 0x4fcb
jmp 0x500b
movq %rax, %rbx
jmp 0x5017
jmp 0x4f33
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x4170
jmp 0x4f16
movq %rax, %rbx
leaq -0x2c0(%rbp), %rdi
callq 0x4170
jmp 0x4f27
movq %rax, %rbx
leaq -0x2e0(%rbp), %rdi
jmp 0x501e
movq %rax, %rbx
jmp 0x5023
jmp 0x4f3d
movq %rax, %rbx
jmp 0x502f
jmp 0x4f49
jmp 0x4f49
movq %rax, %rbx
jmp 0x503b
jmp 0x4f57
jmp 0x4f57
jmp 0x4f57
movq %rax, %rbx
jmp 0x5047
jmp 0x5006
jmp 0x4f66
movq %rax, %rbx
jmp 0x505f
jmp 0x4f70
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x4170
leaq -0x1c0(%rbp), %rdi
callq 0x5ef4
jmp 0x4f94
jmp 0x4f91
jmp 0x4f91
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x5ef4
leaq -0x110(%rbp), %rdi
callq 0x5ef4
leaq -0x168(%rbp), %rdi
callq 0x4170
leaq -0x240(%rbp), %rdi
callq 0x4170
leaq -0x260(%rbp), %rdi
callq 0x4170
jmp 0x500e
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x502a
jmp 0x4fdd
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x5036
jmp 0x4fea
jmp 0x4fea
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x5042
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x505a
movq %rax, %rbx
jmp 0x4fb8
movq %rax, %rbx
jmp 0x4fc4
movq %rax, %rbx
jmp 0x5053
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x5854
leaq -0x2a0(%rbp), %rdi
callq 0x4170
leaq -0x300(%rbp), %rdi
callq 0x4170
leaq -0x320(%rbp), %rdi
callq 0x4170
leaq -0x188(%rbp), %rdi
callq 0x4170
leaq -0xd8(%rbp), %rdi
callq 0x4170
leaq -0xb8(%rbp), %rdi
callq 0x4170
leaq -0x340(%rbp), %rdi
callq 0x4170
movq %rbx, %rdi
callq 0x4540
nop