#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 strlen(char *);
int calculate_multiply(char arr[]) {
  char alph[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                   'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                   'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
  int res = 1;
  for (int i = 0; i < strlen(arr); i++) {
    for (int j = 0; j < 26; j++) {
      if (arr[i] == alph[j]) {
        res *= (j + 1);
        break;
      }
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<calculate_multiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed4(%rip),%ax
mov    %ax,-0x18(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jge    11d8 <calculate_multiply+0xc8>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x1a,-0x3c(%rbp)
jge    11c5 <calculate_multiply+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x3c(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11b2 <calculate_multiply+0xa2>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
imul   -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11c5 <calculate_multiply+0xb5>
jmp    11b7 <calculate_multiply+0xa7>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1179 <calculate_multiply+0x69>
jmp    11ca <calculate_multiply+0xba>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1156 <calculate_multiply+0x46>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_multiply>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    115b <calculate_multiply+0x4b>
mov    $0x1,%r14d
xor    %ebx,%ebx
mov    $0x1,%ebp
movzbl (%r15,%rbx,1),%eax
add    $0xbf,%al
movzbl %al,%eax
lea    0x1(%rax),%ecx
cmp    $0x1a,%al
cmovae %r14d,%ecx
imul   %ecx,%ebp
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1130 <calculate_multiply+0x20>
jmp    1160 <calculate_multiply+0x50>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.calculate_multiply.alph = [26 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
define i32 @calculate_multiply(i8* %0) {
%2 = alloca i8*
%3 = alloca [26 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = bitcast [26 x i8]* %3 to i8*
store i32 1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %40, %1
%9 = load i32, i32* %5
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %43
13: ; preds = %8
store i32 0, i32* %6
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 26
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = load i8*, i8** %2
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %23, %28
br i1 %29, label %30, label %35
30: ; preds = %17
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
%33 = load i32, i32* %4
%34 = mul nsw i32 %33, %32
store i32 %34, i32* %4
br label %39
35: ; preds = %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %14
39: ; preds = %30, %14
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %8
43: ; preds = %8
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
define i32 @calculate_multiply(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %1, %4
%5 = phi i64 [ %15, %4 ], [ 0, %1 ]
%6 = phi i32 [ %14, %4 ], [ 1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = add i8 %8, -65
%10 = icmp ult i8 %9, 26
%11 = zext i8 %9 to i32
%12 = add nuw nsw i32 %11, 1
%13 = select i1 %10, i32 %12, i32 1
%14 = mul nsw i32 %6, %13
%15 = add nuw nsw i64 %5, 1
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %4, label %19
19: ; preds = %4, %1
%20 = phi i32 [ 1, %1 ], [ %14, %4 ]
ret i32 %20
}