#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 */
scalar_t__ get_point(int /*<<< orphan*/);
size_t strlen(char *);
int /*<<< orphan*/ tolower(char);
int score(char *input) {
  int sum = 0;
  for (size_t i = 0; i < strlen(input); ++i)
    sum += get_point(tolower(input[i]));
  return sum;
}


x86 assembly (clang, -O0):
<score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    11a2 <score+0x72>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %eax,%edi
call   1050 <get_point@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114b <score+0x1b>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<score>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1197 <score+0x67>
mov    %rdi,%r14
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %eax,%edi
call   1050 <get_point@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     119a <score+0x6a>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %eax,%edi
call   1050 <get_point@plt>
add    %eax,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jb     1170 <score+0x40>
jmp    119a <score+0x6a>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @score(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %3
store i64 0, i64* %4
br label %5
5: ; preds = %21, %1
%6 = load i64, i64* %4
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = icmp ult i64 %6, %8
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i64, i64* %4
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @tolower(i8 signext %14)
%16 = call i64 @get_point(i32 %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %3
br label %21
21: ; preds = %10
%22 = load i64, i64* %4
%23 = add i64 %22, 1
store i64 %23, i64* %4
br label %5
24: ; preds = %5
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @score(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @tolower(i8 signext %2)
%6 = tail call i64 @get_point(i32 %5)
%7 = trunc i64 %6 to i32
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = icmp ugt i64 %8, 1
br i1 %9, label %12, label %10
10: ; preds = %12, %4, %1
%11 = phi i32 [ 0, %1 ], [ %7, %4 ], [ %20, %12 ]
ret i32 %11
12: ; preds = %4, %12
%13 = phi i64 [ %21, %12 ], [ 1, %4 ]
%14 = phi i32 [ %20, %12 ], [ %7, %4 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
%17 = tail call i32 @tolower(i8 signext %16)
%18 = tail call i64 @get_point(i32 %17)
%19 = trunc i64 %18 to i32
%20 = add i32 %14, %19
%21 = add nuw i64 %13, 1
%22 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%23 = icmp ult i64 %21, %22
br i1 %23, label %12, label %10
}