// File: halfflat[P]tinyopt/test/googletest/googletest/src/gtest-port.cc
// Function: testing::internal::ParseInt32(testing::Message const&, char const*, int*)
bool ParseInt32(const Message& src_text, const char* str, int32_t* value) {
  // Parses the environment variable as a decimal integer.
  char* end = nullptr;
  const long long_value = strtol(str, &end, 10);  // NOLINT

  // Has strtol() consumed all characters in the string?
  if (*end != '\0') {
    // No - an invalid character was encountered.
    Message msg;
    msg << "WARNING: " << src_text
        << " is expected to be a 32-bit integer, but actually"
        << " has value \"" << str << "\".\n";
    printf("%s", msg.GetString().c_str());
    fflush(stdout);
    return false;
  }

  // Is the parsed value in the range of an int32_t?
  const auto result = static_cast<int32_t>(long_value);
  if (long_value == LONG_MAX || long_value == LONG_MIN ||
      // The parsed value overflows as a long.  (strtol() returns
      // LONG_MAX or LONG_MIN when the input overflows.)
      result != long_value
      // The parsed value overflows as an int32_t.
  ) {
    Message msg;
    msg << "WARNING: " << src_text
        << " is expected to be a 32-bit integer, but actually"
        << " has value " << str << ", which overflows.\n";
    printf("%s", msg.GetString().c_str());
    fflush(stdout);
    return false;
  }

  *value = result;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0xa, %edx
callq 0x10b90
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x7e0c8
leaq -0x38(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x84210
movq -0xa8(%rbp), %rdi
leaq 0x4fe6d(%rip), %rsi     # 0xcde20
callq 0xa4180
movq %rax, -0xa0(%rbp)
jmp 0x7dfc1
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xa41c0
movq %rax, -0xb0(%rbp)
jmp 0x7dfda
movq -0xb0(%rbp), %rdi
leaq 0x4fe42(%rip), %rsi     # 0xcde2a
callq 0xa4200
movq %rax, -0xb8(%rbp)
jmp 0x7dff6
movq -0xb8(%rbp), %rdi
leaq 0x4fe58(%rip), %rsi     # 0xcde5c
callq 0xa2d80
movq %rax, -0xc0(%rbp)
jmp 0x7e012
movq -0xc0(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xa2dc0
movq %rax, -0xc8(%rbp)
jmp 0x7e02b
movq -0xc8(%rbp), %rdi
leaq 0x4fe30(%rip), %rsi     # 0xcde69
callq 0xa4240
jmp 0x7e040
leaq -0x68(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x77710
jmp 0x7e04f
leaq -0x68(%rbp), %rdi
callq 0x102c0
movq %rax, %rsi
leaq 0x51421(%rip), %rdi     # 0xcf483
xorl %eax, %eax
callq 0x10090
jmp 0x7e06b
leaq -0x68(%rbp), %rdi
callq 0x10fc8
movq 0x98f05(%rip), %rax     # 0x116f80
movq (%rax), %rdi
callq 0x10930
jmp 0x7e085
movb $0x0, -0x1(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1d500
jmp 0x7e243
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7e0ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x10fc8
leaq -0x38(%rbp), %rdi
callq 0x1d500
jmp 0x7e251
movq -0x30(%rbp), %rax
movl %eax, -0x6c(%rbp)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, -0x30(%rbp)
je 0x7e0fd
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpq %rax, -0x30(%rbp)
je 0x7e0fd
movslq -0x6c(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x7e236
leaq -0x78(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x84210
movq -0xd8(%rbp), %rdi
leaq 0x4fd05(%rip), %rsi     # 0xcde20
callq 0xa4180
movq %rax, -0xd0(%rbp)
jmp 0x7e129
movq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xa41c0
movq %rax, -0xe0(%rbp)
jmp 0x7e142
movq -0xe0(%rbp), %rdi
leaq 0x4fcda(%rip), %rsi     # 0xcde2a
callq 0xa4200
movq %rax, -0xe8(%rbp)
jmp 0x7e15e
movq -0xe8(%rbp), %rdi
leaq 0x4fd01(%rip), %rsi     # 0xcde6d
callq 0xa4280
movq %rax, -0xf0(%rbp)
jmp 0x7e17a
movq -0xf0(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xa2dc0
movq %rax, -0xf8(%rbp)
jmp 0x7e193
movq -0xf8(%rbp), %rdi
leaq 0x4fcd8(%rip), %rsi     # 0xcde79
callq 0xa42c0
jmp 0x7e1a8
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x77710
jmp 0x7e1ba
leaq -0x98(%rbp), %rdi
callq 0x102c0
movq %rax, %rsi
leaq 0x512b3(%rip), %rdi     # 0xcf483
xorl %eax, %eax
callq 0x10090
jmp 0x7e1d9
leaq -0x98(%rbp), %rdi
callq 0x10fc8
movq 0x98d94(%rip), %rax     # 0x116f80
movq (%rax), %rdi
callq 0x10930
jmp 0x7e1f6
movb $0x0, -0x1(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x1d500
jmp 0x7e243
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7e22b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x10fc8
leaq -0x78(%rbp), %rdi
callq 0x1d500
jmp 0x7e251
movl -0x6c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x10e00
nopw (%rax,%rax)