#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 classFrom == 'A' ? 25 : 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    122f <substituteCost+0x11f>
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    122f <substituteCost+0x11f>
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    11e8 <substituteCost+0xd8>
movsbl -0x8(%rbp),%edx
mov    $0x28,%eax
mov    $0x19,%ecx
cmp    $0x41,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    122f <substituteCost+0x11f>
movsbl -0x8(%rbp),%eax
cmp    $0x2,%eax
jl     1228 <substituteCost+0x118>
movsbl -0x8(%rbp),%eax
cmp    $0x9,%eax
jg     1228 <substituteCost+0x118>
movsbl -0x9(%rbp),%eax
cmp    $0x2,%eax
jl     1228 <substituteCost+0x118>
movsbl -0x9(%rbp),%eax
cmp    $0x9,%eax
jg     1228 <substituteCost+0x118>
movl   $0x4b,-0x4(%rbp)
jmp    122f <substituteCost+0x11f>
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     118a <substituteCost+0x7a>
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     118a <substituteCost+0x7a>
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>
cmp    %al,%r14b
jne    1168 <substituteCost+0x58>
cmp    $0x41,%r14b
mov    $0x19,%ecx
mov    $0x28,%eax
cmove  %ecx,%eax
jmp    118a <substituteCost+0x7a>
mov    %eax,%ecx
add    $0xfe,%r14b
cmp    $0xa,%al
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 %76
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 %76
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 %58
52: ; preds = %40
%53 = load i8, i8* %8
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 65
%56 = zext i1 %55 to i64
%57 = select i1 %55, i32 25, i32 40
store i32 %57, i32* %4
br label %76
58: ; preds = %40
%59 = load i8, i8* %8
%60 = sext i8 %59 to i32
%61 = icmp sge i32 %60, 2
br i1 %61, label %62, label %75
62: ; preds = %58
%63 = load i8, i8* %8
%64 = sext i8 %63 to i32
%65 = icmp sle i32 %64, 9
br i1 %65, label %66, label %75
66: ; preds = %62
%67 = load i8, i8* %9
%68 = sext i8 %67 to i32
%69 = icmp sge i32 %68, 2
br i1 %69, label %70, label %75
70: ; preds = %66
%71 = load i8, i8* %9
%72 = sext i8 %71 to i32
%73 = icmp sle i32 %72, 9
br i1 %73, label %74, label %75
74: ; preds = %70
store i32 75, i32* %4
br label %76
75: ; preds = %70, %66, %62, %58
store i32 100, i32* %4
br label %76
76: ; preds = %75, %74, %52, %39, %15
%77 = load i32, i32* %4
ret i32 %77
}

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 %27, 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 %27, 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 %16, label %19
16: ; preds = %12
%17 = icmp eq i8 %13, 65
%18 = select i1 %17, i32 25, i32 40
br label %27
19: ; preds = %12
%20 = add i8 %13, -2
%21 = icmp ult i8 %20, 8
%22 = icmp sgt i8 %14, 1
%23 = select i1 %21, i1 %22, i1 false
%24 = icmp slt i8 %14, 10
%25 = select i1 %23, i1 %24, i1 false
%26 = select i1 %25, i32 75, i32 100
br label %27
27: ; preds = %19, %8, %3, %16
%28 = phi i32 [ %18, %16 ], [ 0, %3 ], [ 0, %8 ], [ %26, %19 ]
ret i32 %28
}