#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__ powl(int, unsigned int);
unsigned int strlen(char const *);
long double __binfloattofloatintpart(const char *buffer) {
  unsigned int c, i;
  long double res = 0.0;
  for (c = 0, i = strlen(buffer) - 1; c < strlen(buffer); c++, i--) {
    if (buffer[i] == '1') {
      res += (long long)powl(2, c);
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<__binfloattofloatintpart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
fldz
fstpt  -0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jae    11af <__binfloattofloatintpart+0x8f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    1193 <__binfloattofloatintpart+0x73>
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1030 <powl@plt>
mov    %rax,-0x28(%rbp)
fildll -0x28(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
jmp    1198 <__binfloattofloatintpart+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1147 <__binfloattofloatintpart+0x27>
fldt   -0x20(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__binfloattofloatintpart>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
fldz
fstpt  0xc(%rsp)
test   %eax,%eax
je     119c <__binfloattofloatintpart+0x7c>
add    $0xffffffff,%ebp
xor    %ebx,%ebx
fldz
fstpt  0xc(%rsp)
jmp    1172 <__binfloattofloatintpart+0x52>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%ebp
cmp    %eax,%ebx
jae    119c <__binfloattofloatintpart+0x7c>
mov    %ebp,%eax
cmpb   $0x31,(%r14,%rax,1)
jne    1160 <__binfloattofloatintpart+0x40>
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <powl@plt>
mov    %rax,0x18(%rsp)
fildll 0x18(%rsp)
fldt   0xc(%rsp)
faddp  %st,%st(1)
fstpt  0xc(%rsp)
jmp    1160 <__binfloattofloatintpart+0x40>
fldt   0xc(%rsp)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define x86_fp80 @__binfloattofloatintpart(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %1, %18
%6 = phi i32 [ %9, %18 ], [ %2, %1 ]
%7 = phi x86_fp80 [ %19, %18 ], [ 0xK00000000000000000000, %1 ]
%8 = phi i32 [ %20, %18 ], [ 0, %1 ]
%9 = add i32 %6, -1
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 49
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = tail call i64 @powl(i32 2, i32 %8)
%16 = sitofp i64 %15 to x86_fp80
%17 = fadd x86_fp80 %7, %16
br label %18
18: ; preds = %5, %14
%19 = phi x86_fp80 [ %17, %14 ], [ %7, %5 ]
%20 = add nuw i32 %8, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = icmp ult i32 %20, %21
br i1 %22, label %5, label %23
23: ; preds = %18, %1
%24 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %19, %18 ]
ret x86_fp80 %24
}