// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/examples/compare.cc
// Function: main
int main()
{
    // instantiates int compare(const int&, const int&)
    cout << compare(1, 0) << endl;       // T is int

    // instantiates int compare(const vector<int>&, const vector<int>&)
    vector<int> vec1{1, 2, 3};
    vector<int> vec2{4, 5, 6};
    cout << compare(vec1, vec2) << endl; // T is vector<int>

    long l1, l2;
    int i1, i2;
    compare(i1, i2);      // instantiate compare(int, int)
    compare(l1, l2);      // instantiate compare(long, long)
	compare<int>(i1, l2); // uses compare(int, int)
	compare<long>(i1, l2);// uses compare(long, long)

    const char *cp1 = "hi", *cp2 = "world";
    compare(cp1, cp2);          // calls the specialization
    compare<string>(cp1, cp2);  // converts arguments to string

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movq 0x2d2c(%rip), %rdi      # 0x3fd8
movl $0x1, %esi
callq 0x1130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movabsq $0x200000001, %rax      # imm = 0x200000001
leaq -0x30(%rbp), %rbx
movq %rax, (%rbx)
movl $0x3, 0x8(%rbx)
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rcx
movl $0x3, %edx
movq %rbx, %rsi
callq 0x14ba
movabsq $0x500000004, %rax      # imm = 0x500000004
movq %rax, (%rbx)
movl $0x6, 0x8(%rbx)
leaq -0x48(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x80(%rbp), %rcx
movl $0x3, %edx
callq 0x14ba
leaq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x14ff
movq 0x2c8d(%rip), %rdi      # 0x3fd8
movl %eax, %esi
callq 0x1130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq 0x2c55(%rip), %rbx      # 0x3fd8
leaq 0xc83(%rip), %rsi       # 0x200d
movl $0x22, %edx
movq %rbx, %rdi
callq 0x1100
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq 0x2c23(%rip), %rdi      # 0x3fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
leaq 0xc3b(%rip), %rsi       # 0x2004
leaq -0x30(%rbp), %rdi
leaq -0xa(%rbp), %rdx
callq 0x1070
leaq 0xc2a(%rip), %rsi       # 0x2007
leaq -0x80(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x1070
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rbx
movq %rbx, %rsi
callq 0x15a2
movq (%rbx), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x1412
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x10f0
leaq -0x20(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x142b
movq -0x20(%rbp), %rsi
incq %rsi
callq 0x10f0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x1440
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1455
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x20(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1488
movq -0x20(%rbp), %rsi
incq %rsi
callq 0x10f0
jmp 0x1488
jmp 0x1485
movq %rax, %rbx
jmp 0x149d
jmp 0x1485
movq %rax, %rbx
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x149d
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x14b2
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1140