// File: spjmurray[P]nagios-plugin-check-scsi-smart/check_scsi_smart.cc
// Function: parse_thresholds(std::map<unsigned char, unsigned long, std::less<unsigned char>, std::allocator<std::pair<unsigned char const, unsigned long>>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool parse_thresholds(SmartThresholdMap& thresholds, const string in) {

  istringstream in_stream(in);
  vector<string> tokens;
  string token1, token2;

  // Split the input into key value pairs
  vector<string> key_value_pairs;
  while(getline(in_stream, token1, ',')) {
    tokens.push_back(token1);
  }

  // Split each key value pair
  for(vector<string>::iterator i = tokens.begin(); i != tokens.end(); i++) {

    istringstream tok_stream(*i);

    // Read the first token delimited by =
    getline(tok_stream, token1, ':');
    if(!tok_stream.good()) {
      return false;
    }

    // Read the second token, which shoud result in EOF
    getline(tok_stream, token2);
    if(!tok_stream.eof()) {
      return false;
    }

    // Parse the tokens and ensure they are integers
    char* p1;
    char* p2;

    unsigned long k = strtol(token1.c_str(), &p1, 10);
    unsigned long v = strtol(token2.c_str(), &p2, 10);

    if(*p1 || *p2) {
      return false;
    }

    thresholds[k] = v;

  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x198(%rbp), %rdi
movl $0x8, %edx
callq 0x4350
leaq -0x1b0(%rbp), %rdi
callq 0x5dc0
leaq -0x1d0(%rbp), %rdi
callq 0x42e0
leaq -0x1f0(%rbp), %rdi
callq 0x42e0
leaq -0x208(%rbp), %rdi
callq 0x5dc0
leaq -0x198(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movl $0x2c, %edx
callq 0x43c0
movq %rax, -0x3e8(%rbp)
jmp 0x5045
movq -0x3e8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x42b0
movb %al, -0x3e9(%rbp)
jmp 0x5063
movb -0x3e9(%rbp), %al
testb $0x1, %al
jne 0x506f
jmp 0x509d
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x5de0
jmp 0x5084
jmp 0x5024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x5321
leaq -0x1b0(%rbp), %rdi
callq 0x5e50
movq %rax, -0x220(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x5ec0
movq %rax, -0x228(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x5e80
testb $0x1, %al
jne 0x50df
jmp 0x52c9
leaq -0x220(%rbp), %rdi
callq 0x5ef0
movq %rax, %rsi
leaq -0x3a8(%rbp), %rdi
movl $0x8, %edx
callq 0x4350
jmp 0x5101
leaq -0x3a8(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movl $0x3a, %edx
callq 0x43c0
jmp 0x511b
movq -0x3a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x3a8(%rbp,%rax), %rdi
callq 0x4360
movb %al, -0x3ea(%rbp)
jmp 0x513b
movb -0x3ea(%rbp), %al
testb $0x1, %al
jne 0x517d
jmp 0x5147
movb $0x0, -0x1(%rbp)
movl $0x1, -0x3ac(%rbp)
jmp 0x5295
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x40f0
jmp 0x5321
leaq -0x3a8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x4060
jmp 0x5192
movq -0x3a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x3a8(%rbp,%rax), %rdi
callq 0x43b0
movb %al, -0x3eb(%rbp)
jmp 0x51b2
movb -0x3eb(%rbp), %al
testb $0x1, %al
jne 0x51d1
jmp 0x51be
movb $0x0, -0x1(%rbp)
movl $0x1, -0x3ac(%rbp)
jmp 0x5295
leaq -0x1d0(%rbp), %rdi
callq 0x40c0
movq %rax, %rdi
leaq -0x3b8(%rbp), %rsi
movl $0xa, %edx
callq 0x42f0
movq %rax, -0x3c8(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x40c0
movq %rax, %rdi
leaq -0x3c0(%rbp), %rsi
movl $0xa, %edx
callq 0x42f0
movq %rax, -0x3d0(%rbp)
movq -0x3b8(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x5237
movq -0x3c0(%rbp), %rax
cmpb $0x0, (%rax)
je 0x5247
movb $0x0, -0x1(%rbp)
movl $0x1, -0x3ac(%rbp)
jmp 0x5295
movq -0x3d0(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x10(%rbp), %rdi
movb -0x3c8(%rbp), %al
movb %al, -0x3d1(%rbp)
leaq -0x3d1(%rbp), %rsi
callq 0x5c40
movq %rax, -0x3f8(%rbp)
jmp 0x527a
movq -0x3f8(%rbp), %rax
movq -0x400(%rbp), %rcx
movq %rcx, (%rax)
movl $0x0, -0x3ac(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x40f0
movl -0x3ac(%rbp), %eax
testl %eax, %eax
jne 0x52d7
jmp 0x52ad
jmp 0x52af
leaq -0x220(%rbp), %rdi
xorl %esi, %esi
callq 0x5f10
movq %rax, -0x3e0(%rbp)
jmp 0x50b0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x3ac(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x5f50
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x1b0(%rbp), %rdi
callq 0x5f50
leaq -0x198(%rbp), %rdi
callq 0x40f0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
leaq -0x208(%rbp), %rdi
callq 0x5f50
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x1b0(%rbp), %rdi
callq 0x5f50
leaq -0x198(%rbp), %rdi
callq 0x40f0
movq -0x210(%rbp), %rdi
callq 0x4380
nopl (%rax)