#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 pow(long double, int);
scalar_t__ strlen(char *);
long double filename_num(char *filename) {
  unsigned int length = 0;
  long double total = 0;
  long double base = 31.0;
  length = (unsigned)strlen(filename);
  char *cur = filename + length - 1;
  int pos = 0;
  while (cur != filename - 1) {
    total += (int)*cur * pow(base, pos);
    --cur;
    ++pos;
  }
  return total;
}


x86 assembly (clang, -O0):
<filename_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
fldz
fstpt  -0x20(%rbp)
flds   0xec2(%rip)
fstpt  -0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
je     11c5 <filename_num+0xa5>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x44(%rbp)
fldt   -0x30(%rbp)
mov    -0x3c(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x40(%rbp)
fildl  -0x40(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1166 <filename_num+0x46>
fldt   -0x20(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filename_num>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0xffffffff,%ebx
fldz
and    %rax,%rbx
je     11fe <filename_num+0xde>
mov    %rax,%r14
fstp   %st(0)
and    $0x1,%r14d
fldz
xor    %r12d,%r12d
cmp    $0x1,%rbx
je     11cf <filename_num+0xaf>
fstp   %st(0)
fldz
xor    %r12d,%r12d
flds   0xe9b(%rip)
fstpt  0x34(%rsp)
nopl   0x0(%rax)
fstpt  0x1c(%rsp)
movsbl -0x1(%r15,%rbx,1),%ebp
fldt   0x34(%rsp)
fstpt  (%rsp)
mov    %r12d,%edi
call   1040 <pow@plt>
imul   %ebp,%eax
mov    %eax,0x2c(%rsp)
fldt   0x1c(%rsp)
fiaddl 0x2c(%rsp)
fstpt  0x1c(%rsp)
movsbl -0x2(%r15,%rbx,1),%ebp
add    $0xfffffffffffffffe,%rbx
lea    0x1(%r12),%edi
fldt   0x34(%rsp)
fstpt  (%rsp)
call   1040 <pow@plt>
imul   %ebp,%eax
mov    %eax,0x30(%rsp)
fldt   0x1c(%rsp)
fiaddl 0x30(%rsp)
add    $0x2,%r12d
cmp    %rbx,%r14
jne    1170 <filename_num+0x50>
test   %r14,%r14
je     11fe <filename_num+0xde>
movsbl -0x1(%rbx,%r15,1),%ebx
fstpt  0x1c(%rsp)
flds   0xe1c(%rip)
fstpt  (%rsp)
mov    %r12d,%edi
call   1040 <pow@plt>
fldt   0x1c(%rsp)
imul   %ebx,%eax
mov    %eax,0x28(%rsp)
fiaddl 0x28(%rsp)
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @filename_num(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
store x86_fp80 0xK4003F800000000000000, x86_fp80* %5
%8 = load i8*, i8** %2
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %3
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
store i8* %15, i8** %6
store i32 0, i32* %7
br label %16
16: ; preds = %21, %1
%17 = load i8*, i8** %6
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = icmp ne i8* %17, %19
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load x86_fp80, x86_fp80* %5
%26 = load i32, i32* %7
%27 = call i32 @pow(x86_fp80 %25, i32 %26)
%28 = mul nsw i32 %24, %27
%29 = sitofp i32 %28 to x86_fp80
%30 = load x86_fp80, x86_fp80* %4
%31 = fadd x86_fp80 %30, %29
store x86_fp80 %31, x86_fp80* %4
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %6
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %16
36: ; preds = %16
%37 = load x86_fp80, x86_fp80* %4
ret x86_fp80 %37
}

LLVM IR (-O2):
define x86_fp80 @filename_num(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = and i64 %2, 4294967295
%4 = icmp eq i64 %3, 0
br i1 %4, label %50, label %5
5: ; preds = %1
%6 = and i64 %2, 1
%7 = icmp eq i64 %3, 1
br i1 %7, label %35, label %8
8: ; preds = %5
%9 = sub nsw i64 %3, %6
br label %10
10: ; preds = %10, %8
%11 = phi i64 [ %3, %8 ], [ %24, %10 ]
%12 = phi i32 [ 0, %8 ], [ %32, %10 ]
%13 = phi x86_fp80 [ 0xK00000000000000000000, %8 ], [ %31, %10 ]
%14 = phi i64 [ 0, %8 ], [ %33, %10 ]
%15 = add nsw i64 %11, -1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = tail call i32 @pow(x86_fp80 0xK4003F800000000000000, i32 %12)
%20 = mul nsw i32 %19, %18
%21 = sitofp i32 %20 to x86_fp80
%22 = fadd x86_fp80 %13, %21
%23 = or i32 %12, 1
%24 = add nsw i64 %11, -2
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 @pow(x86_fp80 0xK4003F800000000000000, i32 %23)
%29 = mul nsw i32 %28, %27
%30 = sitofp i32 %29 to x86_fp80
%31 = fadd x86_fp80 %22, %30
%32 = add nuw nsw i32 %12, 2
%33 = add i64 %14, 2
%34 = icmp eq i64 %33, %9
br i1 %34, label %35, label %10
35: ; preds = %10, %5
%36 = phi x86_fp80 [ undef, %5 ], [ %31, %10 ]
%37 = phi i64 [ %3, %5 ], [ %24, %10 ]
%38 = phi i32 [ 0, %5 ], [ %32, %10 ]
%39 = phi x86_fp80 [ 0xK00000000000000000000, %5 ], [ %31, %10 ]
%40 = icmp eq i64 %6, 0
br i1 %40, label %50, label %41
41: ; preds = %35
%42 = add nsw i64 %37, -1
%43 = getelementptr inbounds i8, i8* %0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 @pow(x86_fp80 0xK4003F800000000000000, i32 %38)
%47 = mul nsw i32 %46, %45
%48 = sitofp i32 %47 to x86_fp80
%49 = fadd x86_fp80 %39, %48
br label %50
50: ; preds = %41, %35, %1
%51 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %36, %35 ], [ %49, %41 ]
ret x86_fp80 %51
}