The compiler creates the code block by block, each line of the source code can correspond to one or several blocks. In the case of optimized code, sometimes several blocks of source code can turn into one.
This basic block of code can be divided into the following logical blocks
; block #1
mov edi, offset _Z3strB5cxx11
call basic_string::length() ; // sorry I'm too lazzy to type the correct function name
mov cs:strLength, eax
; block #2
mov eax, cs:strLength
cmp eax, 3
jbe loc_4011C6 ; // below-or-equal, unsigned operation, so cs:strLength is of type size_t
First block stores result of basic_string::length() in the global variable. The second block is produced from "if" statement. So the source code looks like that:
size_t strLength; // global variable
...
void someFunc() {
...
strLength = str.length(); // block #1
if (strlength <= 3) { // block #2
// statements at the address 0x4011C6
}
// statements after jbe
...
}
Optimization flags -O1, -O2, -O3 will remove the extra move operation.
About your second question. First of all let's check the demangled name (I used https://demangler.com/). It's equal to the 'str[abi:cxx11]'. The ABI is stands for the application binary interface. It is necessary to link 2 or more binary modules. I don’t see the whole code, but by string object name I can guess you can't see it's value, cause it's external std::string. It's value should be analyzed in other module (other DLL or EXE file). So, it's not global variable only, but exported or imported value (in C++ with 'extern' keyword).