#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 */
double getValue(char const);
int strlen(char const *);
double calculateLessThan1(const char *numb, unsigned char base) {
  const char *end;
  double result;
  for (end = numb + strlen(numb) - 1, result = 0.0; end >= numb; end--)
    result = (result + getValue(*end)) / base;
  return result;
}


x86 assembly (clang, -O0):
<calculateLessThan1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     11b1 <calculateLessThan1+0x91>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <getValue@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movzbl -0x9(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    115f <calculateLessThan1+0x3f>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateLessThan1>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rbp
add    $0xffffffffffffffff,%rbp
xorpd  %xmm0,%xmm0
cmp    %rbx,%rbp
jb     1187 <calculateLessThan1+0x67>
movzbl %r14b,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm1,%xmm1
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movsbl 0x0(%rbp),%edi
call   1040 <getValue@plt>
addsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
add    $0xffffffffffffffff,%rbp
movapd %xmm0,%xmm1
cmp    %rbx,%rbp
jae    1160 <calculateLessThan1+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @calculateLessThan1(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
%6 = alloca double
store i8* %0, i8** %3
store i8 %1, i8* %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -1
store i8* %12, i8** %5
store double 0.000000e+00, double* %6
br label %13
13: ; preds = %27, %2
%14 = load i8*, i8** %5
%15 = load i8*, i8** %3
%16 = icmp uge i8* %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load double, double* %6
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = call double @getValue(i8 signext %20)
%22 = fadd double %18, %21
%23 = load i8, i8* %4
%24 = zext i8 %23 to i32
%25 = sitofp i32 %24 to double
%26 = fdiv double %22, %25
store double %26, double* %6
br label %27
27: ; preds = %17
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %5
br label %13
30: ; preds = %13
%31 = load double, double* %6
ret double %31
}

LLVM IR (-O2):
define double @calculateLessThan1(i8* %0, i8 zeroext %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 -1
%7 = icmp ult i8* %6, %0
br i1 %7, label %19, label %8
8: ; preds = %2
%9 = uitofp i8 %1 to double
br label %10
10: ; preds = %8, %10
%11 = phi i8* [ %6, %8 ], [ %17, %10 ]
%12 = phi double [ 0.000000e+00, %8 ], [ %16, %10 ]
%13 = load i8, i8* %11
%14 = tail call double @getValue(i8 signext %13)
%15 = fadd double %12, %14
%16 = fdiv double %15, %9
%17 = getelementptr inbounds i8, i8* %11, i64 -1
%18 = icmp ult i8* %17, %0
br i1 %18, label %19, label %10
19: ; preds = %10, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %16, %10 ]
ret double %20
}