#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 costCalc(char *, char *, int);
int /*<<< orphan*/ getline1(char **, int *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char Sandro[] = "Sandro";
  int sandroLen = strlen(Sandro);
  char *code;
  int codeSize = 200;
  int codeLen, cost;
  int minCost = 60;
  code = (char *)malloc(codeSize * sizeof(char));
  getline1(&code, &codeSize, stdin);
  codeLen = strlen(code);
  for (int i = 0; i < codeLen - sandroLen; i++) {
    cost = costCalc(Sandro, &code[i], sandroLen);
    if (cost < minCost) {
      minCost = cost;
    }
  }
  printf("%d\n", minCost);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xe95(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe8d(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xb(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0xc8,-0x1c(%rbp)
movl   $0x3c,-0x28(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <getline1@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1222 <main+0xd2>
lea    -0xb(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
mov    -0x10(%rbp),%edx
call   1030 <costCalc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    120f <main+0xbf>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1214 <main+0xc4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d2 <main+0x82>
mov    -0x28(%rbp),%esi
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x6f7264,0xb(%rsp)
movl   $0x646e6153,0x8(%rsp)
64
lea    0x8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
movl   $0xc8,0x1c(%rsp)
mov    $0xc8,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
lea    0x1c(%rsp),%rsi
call   1060 <getline1@plt>
mov    0x10(%rsp),%rdi
call   1040 <strlen@plt>
sub    %r15d,%eax
test   %eax,%eax
jle    11f3 <main+0xa3>
mov    %eax,%r12d
mov    $0x3c,%ebp
xor    %ebx,%ebx
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rsi
add    %rbx,%rsi
mov    %r14,%rdi
mov    %r15d,%edx
call   1030 <costCalc@plt>
cmp    %ebp,%eax
cmovl  %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <main+0x80>
jmp    11f8 <main+0xa8>
mov    $0x3c,%ebp
lea    0xe08(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.Sandro = [7 x i8] c"Sandro\00"
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [7 x i8]* %2 to i8*
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %3
store i32 200, i32* %5
store i32 60, i32* %8
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %4
%19 = load i32, i32* @stdin
%20 = call i32 @getline1(i8** %4, i32* %5, i32 %19)
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %6
store i32 0, i32* %9
br label %23
23: ; preds = %43, %0
%24 = load i32, i32* %9
%25 = load i32, i32* %6
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
%28 = icmp slt i32 %24, %27
br i1 %28, label %29, label %46
29: ; preds = %23
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%31 = load i8*, i8** %4
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i32, i32* %3
%36 = call i32 @costCalc(i8* %30, i8* %34, i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = load i32, i32* %7
store i32 %41, i32* %8
br label %42
42: ; preds = %40, %29
br label %43
43: ; preds = %42
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %23
46: ; preds = %23
%47 = load i32, i32* %8
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
ret i32 0
}

LLVM IR (-O2):
@__const.main.Sandro = [7 x i8] c"Sandro\00"
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca i8*
%3 = alloca i32
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%5 = call i32 @strlen(i8* %4)
%6 = bitcast i8** %2 to i8*
%7 = bitcast i32* %3 to i8*
store i32 200, i32* %3
%8 = call i64 @malloc(i32 200)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %2
%10 = load i32, i32* @stdin
%11 = call i32 @getline1(i8** %2, i32* %3, i32 %10)
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
%14 = sub i32 %13, %5
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = zext i32 %14 to i64
br label %21
18: ; preds = %21, %0
%19 = phi i32 [ 60, %0 ], [ %28, %21 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
21: ; preds = %16, %21
%22 = phi i64 [ 0, %16 ], [ %29, %21 ]
%23 = phi i32 [ 60, %16 ], [ %28, %21 ]
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 %22
%26 = call i32 @costCalc(i8* %4, i8* %25, i32 %5)
%27 = icmp slt i32 %26, %23
%28 = select i1 %27, i32 %26, i32 %23
%29 = add nuw nsw i64 %22, 1
%30 = icmp eq i64 %29, %17
br i1 %30, label %18, label %21
}