#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 insertOrDeleteCost(char cPrev, char c, char cNext) {
  char classC = characterClass(cPrev, c);
  char classCprev;
  if (classC == 0) {
    return 1;
  }
  if (cPrev == c) {
    return 10;
  }
  if (classC == 1 && (cPrev == 'r' || cNext == 'r')) {
    return 20;
  }
  classCprev = characterClass(cPrev, cPrev);
  if (classC == classCprev) {
    if (classC == 1) {
      return 15;
    } else {
      return 50;
    }
  }
  return 100;
}


x86 assembly (clang, -O0):
<insertOrDeleteCost>:
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)
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1030 <characterClass@plt>
mov    %al,-0x8(%rbp)
movsbl -0x8(%rbp),%eax
cmp    $0x0,%eax
jne    1154 <insertOrDeleteCost+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <insertOrDeleteCost+0xe1>
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jne    1170 <insertOrDeleteCost+0x60>
movl   $0xa,-0x4(%rbp)
jmp    11f1 <insertOrDeleteCost+0xe1>
movsbl -0x8(%rbp),%eax
cmp    $0x1,%eax
jne    11a3 <insertOrDeleteCost+0x93>
movsbl -0x5(%rbp),%eax
cmp    $0x72,%eax
je     1197 <insertOrDeleteCost+0x87>
movsbl -0x7(%rbp),%eax
cmp    $0x72,%eax
jne    11a3 <insertOrDeleteCost+0x93>
movl   $0x14,-0x4(%rbp)
jmp    11f1 <insertOrDeleteCost+0xe1>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x5(%rbp),%esi
call   1030 <characterClass@plt>
mov    %al,-0x9(%rbp)
movsbl -0x8(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11ea <insertOrDeleteCost+0xda>
movsbl -0x8(%rbp),%eax
cmp    $0x1,%eax
jne    11de <insertOrDeleteCost+0xce>
movl   $0xf,-0x4(%rbp)
jmp    11f1 <insertOrDeleteCost+0xe1>
movl   $0x32,-0x4(%rbp)
jmp    11f1 <insertOrDeleteCost+0xe1>
movl   $0x64,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertOrDeleteCost>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <characterClass@plt>
test   %al,%al
je     116b <insertOrDeleteCost+0x5b>
mov    %eax,%r15d
mov    $0xa,%eax
cmp    %bpl,%bl
je     1170 <insertOrDeleteCost+0x60>
mov    $0x32,%ebp
cmp    $0x1,%r15b
jne    1154 <insertOrDeleteCost+0x44>
mov    $0x14,%eax
cmp    $0x72,%bl
je     1170 <insertOrDeleteCost+0x60>
mov    $0xf,%ebp
cmp    $0x72,%r14b
je     1170 <insertOrDeleteCost+0x60>
movsbl %bl,%edi
mov    %edi,%esi
call   1030 <characterClass@plt>
cmp    %al,%r15b
mov    $0x64,%eax
cmove  %ebp,%eax
jmp    1170 <insertOrDeleteCost+0x60>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @insertOrDeleteCost(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* %5
%11 = load i8, i8* %6
%12 = call signext i8 @characterClass(i8 signext %10, i8 signext %11)
store i8 %12, i8* %8
%13 = load i8, i8* %8
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 1, i32* %4
br label %53
17: ; preds = %3
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 10, i32* %4
br label %53
24: ; preds = %17
%25 = load i8, i8* %8
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i8, i8* %5
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 114
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8, i8* %7
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 114
br i1 %35, label %36, label %37
36: ; preds = %32, %28
store i32 20, i32* %4
br label %53
37: ; preds = %32, %24
%38 = load i8, i8* %5
%39 = load i8, i8* %5
%40 = call signext i8 @characterClass(i8 signext %38, i8 signext %39)
store i8 %40, i8* %9
%41 = load i8, i8* %8
%42 = sext i8 %41 to i32
%43 = load i8, i8* %9
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %42, %44
br i1 %45, label %46, label %52
46: ; preds = %37
%47 = load i8, i8* %8
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 15, i32* %4
br label %53
51: ; preds = %46
store i32 50, i32* %4
br label %53
52: ; preds = %37
store i32 100, i32* %4
br label %53
53: ; preds = %52, %51, %50, %36, %23, %16
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @insertOrDeleteCost(i8 signext %0, i8 signext %1, i8 signext %2) {
%4 = tail call signext i8 @characterClass(i8 signext %0, i8 signext %1)
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = icmp eq i8 %0, %1
br i1 %7, label %19, label %8
8: ; preds = %6
%9 = icmp eq i8 %4, 1
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = icmp eq i8 %0, 114
%12 = icmp eq i8 %2, 114
%13 = or i1 %11, %12
br i1 %13, label %19, label %14
14: ; preds = %10, %8
%15 = phi i32 [ 15, %10 ], [ 50, %8 ]
%16 = tail call signext i8 @characterClass(i8 signext %0, i8 signext %0)
%17 = icmp eq i8 %4, %16
%18 = select i1 %17, i32 %15, i32 100
br label %19
19: ; preds = %14, %10, %6, %3
%20 = phi i32 [ 1, %3 ], [ 10, %6 ], [ 20, %10 ], [ %18, %14 ]
ret i32 %20
}