#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int convertSingleCharacterToInt(char);
int /*<<< orphan*/ showBadNumeralPairMessage(char, char);
int getNextConvertableValue(char currentChar, char nextChar, int *index) {
  int firstConvertedTerm = convertSingleCharacterToInt(currentChar);
  if (nextChar != '\0') {
    int secondConvertedTerm = convertSingleCharacterToInt(nextChar);
    if (firstConvertedTerm == -1 || secondConvertedTerm == -1)
      return -1;
    if ((secondConvertedTerm / firstConvertedTerm >= 50) ||
        ((firstConvertedTerm == 5 || firstConvertedTerm == 50 ||
          firstConvertedTerm == 500) &&
         (secondConvertedTerm >= firstConvertedTerm))) {
      showBadNumeralPairMessage(currentChar, nextChar);
      return -2;
    }
    if (((5 * firstConvertedTerm) == secondConvertedTerm) ||
        ((10 * firstConvertedTerm) == secondConvertedTerm)) {
      *index += 1;
      return secondConvertedTerm - firstConvertedTerm;
    }
  }
  return firstConvertedTerm;
}


x86 assembly (clang, -O0):
<getNextConvertableValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    %rdx,-0x10(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <convertSingleCharacterToInt@plt>
mov    %eax,-0x14(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0x0,%eax
je     120d <getNextConvertableValue+0xed>
movsbl -0x6(%rbp),%edi
call   1030 <convertSingleCharacterToInt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1171 <getNextConvertableValue+0x51>
cmpl   $0xffffffff,-0x18(%rbp)
jne    117d <getNextConvertableValue+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1213 <getNextConvertableValue+0xf3>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x32,%eax
jge    11ba <getNextConvertableValue+0x9a>
cmpl   $0x5,-0x14(%rbp)
je     11ae <getNextConvertableValue+0x8e>
cmpl   $0x32,-0x14(%rbp)
je     11ae <getNextConvertableValue+0x8e>
cmpl   $0x1f4,-0x14(%rbp)
jne    11d5 <getNextConvertableValue+0xb5>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11d5 <getNextConvertableValue+0xb5>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1040 <showBadNumeralPairMessage@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1213 <getNextConvertableValue+0xf3>
imul   $0x5,-0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11ef <getNextConvertableValue+0xcf>
imul   $0xa,-0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1208 <getNextConvertableValue+0xe8>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1213 <getNextConvertableValue+0xf3>
jmp    120d <getNextConvertableValue+0xed>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextConvertableValue>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%r12d
call   1030 <convertSingleCharacterToInt@plt>
mov    %eax,%ebx
test   %bpl,%bpl
je     1196 <getNextConvertableValue+0x76>
movsbl %bpl,%r15d
mov    %r15d,%edi
call   1030 <convertSingleCharacterToInt@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0xffffffff,%ebx
je     11ab <getNextConvertableValue+0x8b>
cmp    $0xffffffff,%ecx
je     11ab <getNextConvertableValue+0x8b>
mov    %ecx,%eax
cltd
idiv   %ebx
cmp    $0x31,%eax
jg     119a <getNextConvertableValue+0x7a>
cmp    $0x5,%ebx
je     1175 <getNextConvertableValue+0x55>
cmp    $0x1f4,%ebx
je     1175 <getNextConvertableValue+0x55>
cmp    $0x32,%ebx
jne    1179 <getNextConvertableValue+0x59>
cmp    %ebx,%ecx
jge    119a <getNextConvertableValue+0x7a>
lea    (%rbx,%rbx,4),%eax
cmp    %ecx,%eax
je     118c <getNextConvertableValue+0x6c>
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%edx
mov    %ebx,%eax
cmp    %ecx,%edx
jne    11ab <getNextConvertableValue+0x8b>
addl   $0x1,(%r14)
sub    %ebx,%ecx
mov    %ecx,%eax
jmp    11ab <getNextConvertableValue+0x8b>
mov    %ebx,%eax
jmp    11ab <getNextConvertableValue+0x8b>
movsbl %r12b,%edi
mov    %r15d,%esi
call   1040 <showBadNumeralPairMessage@plt>
mov    $0xfffffffe,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getNextConvertableValue(i8 signext %0, i8 signext %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i8 %0, i8* %5
store i8 %1, i8* %6
store i32* %2, i32** %7
%10 = load i8, i8* %5
%11 = call i32 @convertSingleCharacterToInt(i8 signext %10)
store i32 %11, i32* %8
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %64
15: ; preds = %3
%16 = load i8, i8* %6
%17 = call i32 @convertSingleCharacterToInt(i8 signext %16)
store i32 %17, i32* %9
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %20, %15
store i32 -1, i32* %4
br label %66
24: ; preds = %20
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = sdiv i32 %25, %26
%28 = icmp sge i32 %27, 50
br i1 %28, label %42, label %29
29: ; preds = %24
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 5
br i1 %31, label %38, label %32
32: ; preds = %29
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 50
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 500
br i1 %37, label %38, label %46
38: ; preds = %35, %32, %29
%39 = load i32, i32* %9
%40 = load i32, i32* %8
%41 = icmp sge i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %38, %24
%43 = load i8, i8* %5
%44 = load i8, i8* %6
%45 = call i32 @showBadNumeralPairMessage(i8 signext %43, i8 signext %44)
store i32 -2, i32* %4
br label %66
46: ; preds = %38, %35
%47 = load i32, i32* %8
%48 = mul nsw i32 5, %47
%49 = load i32, i32* %9
%50 = icmp eq i32 %48, %49
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = load i32, i32* %8
%53 = mul nsw i32 10, %52
%54 = load i32, i32* %9
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %51, %46
%57 = load i32*, i32** %7
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
%60 = load i32, i32* %9
%61 = load i32, i32* %8
%62 = sub nsw i32 %60, %61
store i32 %62, i32* %4
br label %66
63: ; preds = %51
br label %64
64: ; preds = %63, %3
%65 = load i32, i32* %8
store i32 %65, i32* %4
br label %66
66: ; preds = %64, %56, %42, %23
%67 = load i32, i32* %4
ret i32 %67
}

LLVM IR (-O2):
define i32 @getNextConvertableValue(i8 signext %0, i8 signext %1, i32* nocapture %2) {
%4 = tail call i32 @convertSingleCharacterToInt(i8 signext %0)
%5 = icmp eq i8 %1, 0
br i1 %5, label %29, label %6
6: ; preds = %3
%7 = tail call i32 @convertSingleCharacterToInt(i8 signext %1)
%8 = icmp eq i32 %4, -1
%9 = icmp eq i32 %7, -1
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %29, label %11
11: ; preds = %6
%12 = sdiv i32 %7, %4
%13 = icmp sgt i32 %12, 49
br i1 %13, label %17, label %14
14: ; preds = %11
switch i32 %4, label %19 [
i32 500, label %15
i32 50, label %15
i32 5, label %15
]
15: ; preds = %14, %14, %14
%16 = icmp slt i32 %7, %4
br i1 %16, label %19, label %17
17: ; preds = %15, %11
%18 = tail call i32 @showBadNumeralPairMessage(i8 signext %0, i8 signext %1)
br label %29
19: ; preds = %14, %15
%20 = mul nsw i32 %4, 5
%21 = icmp eq i32 %20, %7
%22 = mul nsw i32 %4, 10
%23 = icmp eq i32 %22, %7
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
%28 = sub nsw i32 %7, %4
br label %29
29: ; preds = %6, %25, %17, %3, %19
%30 = phi i32 [ %4, %19 ], [ %4, %3 ], [ -1, %6 ], [ %28, %25 ], [ -2, %17 ]
ret i32 %30
}