// File: /workspace/github_cpp_makefile_star2_O3/chen3feng[P]error-handling/result.cpp
// Function: main
int main() {
    auto r = GetIntFromFile("bad");
    if (r.Error()) {
        std::cout
            << "In " << r.Error().File() << ":" << r.Error().Line() << ":" << r.Error().Function()
            << " Code: " << r.Error().Code() << '\n';
    }
    std::cout << r.ValueOr(-1) << '\n';
    std::cout << GetIntFromFile("number").Value() << '\n';

    // 可以显式地忽略错误，如果不加这个，Result 定义上的 [[nodiscard]] 属性会导致编译器警告，提醒开发者。
    FlushAll().IgnoreError();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x16e6(%rip), %rsi      # 0x400f
leaq 0x16e2(%rip), %rdx      # 0x4012
leaq -0x40(%rbp), %rdi
callq 0x3136
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x25d9
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x295b
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2aa1
cmpl $0x0, 0x8(%rax)
je 0x2a96
movq 0x365f(%rip), %rbx      # 0x5fd8
leaq 0x16b6(%rip), %rsi      # 0x4036
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
movq 0x10(%rax), %r14
testq %r14, %r14
je 0x29b6
movq %r14, %rdi
callq 0x2080
movq 0x362f(%rip), %rdi      # 0x5fd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x2100
jmp 0x29cd
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2170
movq 0x3604(%rip), %rdi      # 0x5fd8
leaq 0x165f(%rip), %rsi      # 0x403a
movl $0x1, %edx
callq 0x2100
movq -0x50(%rbp), %rax
movl 0x18(%rax), %esi
movq 0x35e5(%rip), %rdi      # 0x5fd8
callq 0x2180
movq %rax, %rbx
leaq 0x1638(%rip), %rsi      # 0x403a
movl $0x1, %edx
movq %rax, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
movq 0x20(%rax), %r14
testq %r14, %r14
je 0x2a34
movq %r14, %rdi
callq 0x2080
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2100
jmp 0x2a4d
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2170
leaq 0x15e8(%rip), %rsi      # 0x403c
movl $0x7, %edx
movq %rbx, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2a6f
movl 0x8(%rax), %esi
jmp 0x2a71
xorl %esi, %esi
movq %rbx, %rdi
callq 0x2180
leaq -0x40(%rbp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2aa1
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpl $0x0, 0x8(%rax)
jne 0x2aa4
movl -0x58(%rbp), %esi
movq 0x352d(%rip), %rdi      # 0x5fd8
callq 0x2180
leaq -0x40(%rbp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2100
leaq -0x40(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x1532(%rip), %rsi      # 0x4004
leaq 0x1531(%rip), %rdx      # 0x400a
callq 0x3136
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x25d9
movl -0x70(%rbp), %esi
movq 0x34e3(%rip), %rdi      # 0x5fd8
callq 0x2180
leaq -0x19(%rbp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2100
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2b1c
callq 0x301e
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2b31
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2b3f
callq 0x301e
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2b83
jmp 0x2b9a
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2bab
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2bab
movq %rax, %rbx
jmp 0x2bab
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2b83
callq 0x301e
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2b9d
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2b9d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2bab
callq 0x301e
movq %rbx, %rdi
callq 0x2190
nop