#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 */
char characterClass(char, char);
int substituteCost(char cPrev, char cFrom, char cTo) {
  char classFrom, classTo;
  if (cFrom == cTo) {
    return 0;
  }
  if (cFrom == (cTo ^ 0x20) &&
      ((cTo >= 'A' && cTo <= 'Z') || (cTo >= 'a' && cTo <= 'z'))) {
    return 0;
  }
  classFrom = characterClass(cPrev, cFrom);
  classTo = characterClass(cPrev, cTo);
  if (classFrom == classTo) {
    return 40;
  }
  if (classFrom >= 2 && classFrom <= 9 && classTo >= 2 && classTo <= 9) {
    return 75;
  }
  return 100;
}


x86 assembly (clang, -O0):
<substituteCost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %dil,%dl
mov    %dl,-0x5(%rbp)
mov    %cl,-0x6(%rbp)
mov    %al,-0x7(%rbp)
movsbl -0x6(%rbp),%eax
movsbl -0x7(%rbp),%ecx
cmp    %ecx,%eax
jne    1145 <substituteCost+0x35>
movl   $0x0,-0x4(%rbp)
jmp    121f <substituteCost+0x10f>
movsbl -0x6(%rbp),%eax
movsbl -0x7(%rbp),%ecx
xor    $0x20,%ecx
cmp    %ecx,%eax
jne    1198 <substituteCost+0x88>
movsbl -0x7(%rbp),%eax
cmp    $0x41,%eax
jl     1172 <substituteCost+0x62>
movsbl -0x7(%rbp),%eax
cmp    $0x5a,%eax
jle    118c <substituteCost+0x7c>
movsbl -0x7(%rbp),%eax
cmp    $0x61,%eax
jl     1198 <substituteCost+0x88>
movsbl -0x7(%rbp),%eax
cmp    $0x7a,%eax
jg     1198 <substituteCost+0x88>
movl   $0x0,-0x4(%rbp)
jmp    121f <substituteCost+0x10f>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1030 <characterClass@plt>
mov    %al,-0x8(%rbp)
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x7(%rbp),%esi
call   1030 <characterClass@plt>
mov    %al,-0x9(%rbp)
movsbl -0x8(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11d8 <substituteCost+0xc8>
movl   $0x28,-0x4(%rbp)
jmp    121f <substituteCost+0x10f>
movsbl -0x8(%rbp),%eax
cmp    $0x2,%eax
jl     1218 <substituteCost+0x108>
movsbl -0x8(%rbp),%eax
cmp    $0x9,%eax
jg     1218 <substituteCost+0x108>
movsbl -0x9(%rbp),%eax
cmp    $0x2,%eax
jl     1218 <substituteCost+0x108>
movsbl -0x9(%rbp),%eax
cmp    $0x9,%eax
jg     1218 <substituteCost+0x108>
movl   $0x4b,-0x4(%rbp)
jmp    121f <substituteCost+0x10f>
movl   $0x64,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substituteCost>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
xor    %eax,%eax
cmp    %bl,%sil
je     117d <substituteCost+0x6d>
mov    %ebx,%ecx
xor    $0x20,%cl
cmp    %sil,%cl
jne    1134 <substituteCost+0x24>
mov    %ebx,%ecx
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x1a,%cl
jb     117d <substituteCost+0x6d>
movsbl %dil,%ebp
movsbl %sil,%esi
mov    %ebp,%edi
call   1030 <characterClass@plt>
mov    %eax,%r14d
movsbl %bl,%esi
mov    %ebp,%edi
call   1030 <characterClass@plt>
mov    %eax,%ecx
mov    $0x28,%eax
cmp    %cl,%r14b
je     117d <substituteCost+0x6d>
add    $0xfe,%r14b
cmp    $0xa,%cl
mov    $0x4b,%eax
mov    $0x64,%edx
cmovge %edx,%eax
cmp    $0x2,%cl
cmovl  %edx,%eax
cmp    $0x8,%r14b
cmovae %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @substituteCost(i8 signext %0, i8 signext %1, i8 signext %2) {
%4 = icmp eq i8 %1, %2
br i1 %4, label %24, label %5
5: ; preds = %3
%6 = xor i8 %2, 32
%7 = icmp eq i8 %6, %1
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = and i8 %2, -33
%10 = add i8 %9, -65
%11 = icmp ult i8 %10, 26
br i1 %11, label %24, label %12
12: ; preds = %8, %5
%13 = tail call signext i8 @characterClass(i8 signext %0, i8 signext %1)
%14 = tail call signext i8 @characterClass(i8 signext %0, i8 signext %2)
%15 = icmp eq i8 %13, %14
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = add i8 %13, -2
%18 = icmp ult i8 %17, 8
%19 = icmp sgt i8 %14, 1
%20 = select i1 %18, i1 %19, i1 false
%21 = icmp slt i8 %14, 10
%22 = select i1 %20, i1 %21, i1 false
%23 = select i1 %22, i32 75, i32 100
br label %24
24: ; preds = %16, %12, %8, %3
%25 = phi i32 [ 0, %3 ], [ 0, %8 ], [ 40, %12 ], [ %23, %16 ]
ret i32 %25
}