// File: /workspace/github_cpp_makefile_star2_O1/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 0x166b(%rip), %rsi      # 0x400f
leaq 0x1667(%rip), %rdx      # 0x4012
leaq -0x40(%rbp), %rdi
callq 0x31ca
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x263a
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x29d6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2b08
cmpl $0x0, 0x8(%rax)
je 0x2b08
movq 0x35e4(%rip), %rbx      # 0x5fd8
leaq 0x163b(%rip), %rsi      # 0x4036
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
movq 0x10(%rax), %r14
testq %r14, %r14
je 0x2a31
movq %r14, %rdi
callq 0x2080
movq 0x35b4(%rip), %rdi      # 0x5fd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x2100
jmp 0x2a48
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2170
movq 0x3589(%rip), %rdi      # 0x5fd8
leaq 0x15e4(%rip), %rsi      # 0x403a
movl $0x1, %edx
callq 0x2100
movq -0x50(%rbp), %rax
movl 0x18(%rax), %esi
movq 0x356a(%rip), %rdi      # 0x5fd8
callq 0x2180
movq %rax, %rbx
leaq 0x15bd(%rip), %rsi      # 0x403a
movl $0x1, %edx
movq %rax, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
movq 0x20(%rax), %r14
testq %r14, %r14
je 0x2aaf
movq %r14, %rdi
callq 0x2080
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2100
jmp 0x2ac8
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2170
leaq 0x156d(%rip), %rsi      # 0x403c
movl $0x7, %edx
movq %rbx, %rdi
callq 0x2100
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2aea
movl 0x8(%rax), %esi
jmp 0x2aec
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 0x2b1a
cmpl $0x0, 0x8(%rax)
sete %al
jmp 0x2b1c
movb $0x1, %al
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testb %al, %al
je 0x2b28
movl -0x58(%rbp), %esi
movq 0x34a9(%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 0x14ae(%rip), %rsi      # 0x4004
leaq 0x14ad(%rip), %rdx      # 0x400a
callq 0x31ca
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x263a
movl -0x70(%rbp), %esi
movq 0x345f(%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 0x2ba0
callq 0x30b2
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2bb5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2bc3
callq 0x30b2
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2c07
jmp 0x2c1e
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2c2f
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2c2f
movq %rax, %rbx
jmp 0x2c2f
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2c07
callq 0x30b2
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x2c21
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2c21
movq %rax, %rbx
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2c2f
callq 0x30b2
movq %rbx, %rdi
callq 0x2190
nop