#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 */
long double get_digit(char const);
long double powl(int, unsigned int);
unsigned int strlen(char const *);
long double octfloattofloattintpart(const char *oct_str) {
  unsigned int c, i, pad;
  long double res;
  pad = 0;
  if (oct_str[0] == '-') {
    pad = 1;
  }
  res = 0.0;
  for (c = 0, i = strlen(oct_str) - 1; c < strlen(oct_str) - pad; c++, i--) {
    if (!c == 0) {
      res = res + (get_digit(oct_str[i]) * powl(8, c));
    } else {
      res = get_digit(oct_str[i]);
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<octfloattofloattintpart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    115a <octfloattofloattintpart+0x2a>
movl   $0x1,-0x14(%rbp)
fldz
fstpt  -0x30(%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,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jae    1212 <octfloattofloattintpart+0xe2>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    11e3 <octfloattofloattintpart+0xb3>
fldt   -0x30(%rbp)
fstpt  -0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1050 <get_digit@plt>
fstpt  -0x40(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x8,%edi
call   1030 <powl@plt>
fldt   -0x4c(%rbp)
fldt   -0x40(%rbp)
fmulp  %st,%st(2)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
jmp    11f6 <octfloattofloattintpart+0xc6>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1050 <get_digit@plt>
fstpt  -0x30(%rbp)
jmp    11fb <octfloattofloattintpart+0xcb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <octfloattofloattintpart+0x45>
fldt   -0x30(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<octfloattofloattintpart>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xor    %r15d,%r15d
cmpb   $0x2d,(%rdi)
sete   %r15b
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
fldz
fstpt  (%rsp)
cmp    %r15d,%eax
je     11d6 <octfloattofloattintpart+0xa6>
neg    %r15d
lea    -0x1(%rbx),%eax
movsbl (%r14,%rax,1),%edi
call   1050 <get_digit@plt>
fstpt  (%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
cmp    $0x2,%eax
jb     11d1 <octfloattofloattintpart+0xa1>
add    $0xfffffffe,%ebx
mov    $0x1,%ebp
fldt   (%rsp)
fstp   %st(0)
mov    %ebx,%eax
movsbl (%r14,%rax,1),%edi
call   1050 <get_digit@plt>
fstpt  0xc(%rsp)
mov    $0x8,%edi
mov    %ebp,%esi
call   1030 <powl@plt>
fldt   0xc(%rsp)
fmulp  %st,%st(1)
fldt   (%rsp)
faddp  %st,%st(1)
fstpt  (%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
add    $0xffffffff,%ebx
cmp    %eax,%ebp
jb     1190 <octfloattofloattintpart+0x60>
jmp    11d6 <octfloattofloattintpart+0xa6>
fldt   (%rsp)
fstp   %st(0)
fldt   (%rsp)
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @octfloattofloattintpart(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca x86_fp80
store i8* %0, i8** %2
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 1, i32* %5
br label %13
13: ; preds = %12, %1
store x86_fp80 0xK00000000000000000000, x86_fp80* %6
store i32 0, i32* %3
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = sub i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %49, %13
%18 = load i32, i32* %3
%19 = load i8*, i8** %2
%20 = call i32 @strlen(i8* %19)
%21 = load i32, i32* %5
%22 = sub i32 %20, %21
%23 = icmp ult i32 %18, %22
br i1 %23, label %24, label %54
24: ; preds = %17
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %24
%31 = load x86_fp80, x86_fp80* %6
%32 = load i8*, i8** %2
%33 = load i32, i32* %4
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = call x86_fp80 @get_digit(i8 signext %36)
%38 = load i32, i32* %3
%39 = call x86_fp80 @powl(i32 8, i32 %38)
%40 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %37, x86_fp80 %39, x86_fp80 %31)
store x86_fp80 %40, x86_fp80* %6
br label %48
41: ; preds = %24
%42 = load i8*, i8** %2
%43 = load i32, i32* %4
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = call x86_fp80 @get_digit(i8 signext %46)
store x86_fp80 %47, x86_fp80* %6
br label %48
48: ; preds = %41, %30
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add i32 %50, 1
store i32 %51, i32* %3
%52 = load i32, i32* %4
%53 = add i32 %52, -1
store i32 %53, i32* %4
br label %17
54: ; preds = %17
%55 = load x86_fp80, x86_fp80* %6
ret x86_fp80 %55
}

LLVM IR (-O2):
define x86_fp80 @octfloattofloattintpart(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 45
%4 = zext i1 %3 to i32
%5 = sext i1 %3 to i32
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, %4
br i1 %8, label %33, label %9
9: ; preds = %1
%10 = add i32 %6, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call x86_fp80 @get_digit(i8 signext %13)
%15 = tail call i32 @strlen(i8* %0)
%16 = add i32 %15, %5
%17 = icmp ugt i32 %16, 1
br i1 %17, label %18, label %33
18: ; preds = %9, %18
%19 = phi i32 [ %22, %18 ], [ %10, %9 ]
%20 = phi x86_fp80 [ %28, %18 ], [ %14, %9 ]
%21 = phi i32 [ %29, %18 ], [ 1, %9 ]
%22 = add i32 %19, -1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = tail call x86_fp80 @get_digit(i8 signext %25)
%27 = tail call x86_fp80 @powl(i32 8, i32 %21)
%28 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %26, x86_fp80 %27, x86_fp80 %20)
%29 = add nuw i32 %21, 1
%30 = tail call i32 @strlen(i8* %0)
%31 = add i32 %30, %5
%32 = icmp ult i32 %29, %31
br i1 %32, label %18, label %33
33: ; preds = %18, %9, %1
%34 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %14, %9 ], [ %28, %18 ]
ret x86_fp80 %34
}