#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 /*<<< orphan*/ int96_negate(unsigned char *);
long double int96_conv2longdouble(unsigned char *x) {
  long double f = 0.0;
  long double m = 1.0;
  int i, neg = 0;
  if (x[11] >= 0x80) {
    neg = 1;
    int96_negate(x);
  }
  for (i = 0; i < 12; i++) {
    f += (long double)x[i] * m;
    m *= 256.0;
  }
  return neg ? -f : f;
}


x86 assembly (clang, -O0):
<int96_conv2longdouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
fldz
fstpt  -0x20(%rbp)
fld1
fstpt  -0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0xb(%rax),%eax
cmp    $0x80,%eax
jl     1150 <int96_conv2longdouble+0x40>
movl   $0x1,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <int96_negate@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xc,-0x34(%rbp)
jge    119f <int96_conv2longdouble+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %ax,-0x3a(%rbp)
filds  -0x3a(%rbp)
fldt   -0x30(%rbp)
fldt   -0x20(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x30(%rbp)
flds   0xe74(%rip)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1157 <int96_conv2longdouble+0x47>
cmpl   $0x0,-0x38(%rbp)
je     11b6 <int96_conv2longdouble+0xa6>
fldt   -0x20(%rbp)
fchs
fstpt  -0x44(%rbp)
jmp    11bc <int96_conv2longdouble+0xac>
fldt   -0x20(%rbp)
fstpt  -0x44(%rbp)
fldt   -0x44(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int96_conv2longdouble>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    0xb(%rdi),%bpl
mov    %ebp,%eax
test   %bpl,%bpl
jns    112f <int96_conv2longdouble+0x1f>
mov    %rbx,%rdi
call   1030 <int96_negate@plt>
mov    0xb(%rbx),%al
test   %bpl,%bpl
movzbl (%rbx),%ecx
mov    %cx,0x14(%rsp)
movzbl 0x1(%rbx),%ecx
mov    %cx,(%rsp)
filds  (%rsp)
fmuls  0xeb5(%rip)
sets   %cl
fiadds 0x14(%rsp)
movzbl 0x2(%rbx),%edx
mov    %dx,0x2(%rsp)
filds  0x2(%rsp)
fmuls  0xe9f(%rip)
faddp  %st,%st(1)
movzbl 0x3(%rbx),%edx
mov    %dx,0x4(%rsp)
filds  0x4(%rsp)
fmuls  0xe8e(%rip)
faddp  %st,%st(1)
movzbl 0x4(%rbx),%edx
mov    %dx,0x6(%rsp)
filds  0x6(%rsp)
fmuls  0xe7d(%rip)
faddp  %st,%st(1)
movzbl 0x5(%rbx),%edx
mov    %dx,0x8(%rsp)
filds  0x8(%rsp)
fmuls  0xe6c(%rip)
faddp  %st,%st(1)
movzbl 0x6(%rbx),%edx
mov    %dx,0xa(%rsp)
filds  0xa(%rsp)
fmuls  0xe5b(%rip)
faddp  %st,%st(1)
movzbl 0x7(%rbx),%edx
mov    %dx,0xc(%rsp)
filds  0xc(%rsp)
fmuls  0xe4a(%rip)
faddp  %st,%st(1)
movzbl 0x8(%rbx),%edx
mov    %dx,0xe(%rsp)
filds  0xe(%rsp)
fmuls  0xe39(%rip)
faddp  %st,%st(1)
movzbl 0x9(%rbx),%edx
mov    %dx,0x10(%rsp)
filds  0x10(%rsp)
fmuls  0xe28(%rip)
faddp  %st,%st(1)
movzbl 0xa(%rbx),%edx
mov    %dx,0x12(%rsp)
filds  0x12(%rsp)
fmuls  0xe17(%rip)
faddp  %st,%st(1)
movzbl %al,%eax
mov    %ax,0x16(%rsp)
filds  0x16(%rsp)
fmuls  0xe07(%rip)
faddp  %st,%st(1)
fld    %st(0)
fchs
test   %cl,%cl
fxch   %st(1)
fcmovne %st(1),%st
fstp   %st(1)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @int96_conv2longdouble(i8* %0) {
%2 = alloca i8*
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
store i32 0, i32* %6
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 11
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = icmp sge i32 %10, 128
br i1 %11, label %12, label %15
12: ; preds = %1
store i32 1, i32* %6
%13 = load i8*, i8** %2
%14 = call i32 @int96_negate(i8* %13)
br label %15
15: ; preds = %12, %1
store i32 0, i32* %5
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 12
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = load i8*, i8** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = uitofp i8 %24 to x86_fp80
%26 = load x86_fp80, x86_fp80* %4
%27 = load x86_fp80, x86_fp80* %3
%28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %25, x86_fp80 %26, x86_fp80 %27)
store x86_fp80 %28, x86_fp80* %3
%29 = load x86_fp80, x86_fp80* %4
%30 = fmul x86_fp80 %29, 0xK40078000000000000000
store x86_fp80 %30, x86_fp80* %4
br label %31
31: ; preds = %19
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %16
34: ; preds = %16
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load x86_fp80, x86_fp80* %3
%39 = fneg x86_fp80 %38
br label %42
40: ; preds = %34
%41 = load x86_fp80, x86_fp80* %3
br label %42
42: ; preds = %40, %37
%43 = phi x86_fp80 [ %39, %37 ], [ %41, %40 ]
ret x86_fp80 %43
}

LLVM IR (-O2):
define x86_fp80 @int96_conv2longdouble(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 11
%3 = load i8, i8* %2
%4 = icmp slt i8 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @int96_negate(i8* %0)
%7 = load i8, i8* %2
br label %8
8: ; preds = %5, %1
%9 = phi i8 [ %7, %5 ], [ %3, %1 ]
%10 = load i8, i8* %0
%11 = uitofp i8 %10 to x86_fp80
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = uitofp i8 %13 to x86_fp80
%15 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 0xK40078000000000000000, x86_fp80 %11)
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = load i8, i8* %16
%18 = uitofp i8 %17 to x86_fp80
%19 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 0xK400F8000000000000000, x86_fp80 %15)
%20 = getelementptr inbounds i8, i8* %0, i64 3
%21 = load i8, i8* %20
%22 = uitofp i8 %21 to x86_fp80
%23 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 0xK40178000000000000000, x86_fp80 %19)
%24 = getelementptr inbounds i8, i8* %0, i64 4
%25 = load i8, i8* %24
%26 = uitofp i8 %25 to x86_fp80
%27 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %26, x86_fp80 0xK401F8000000000000000, x86_fp80 %23)
%28 = getelementptr inbounds i8, i8* %0, i64 5
%29 = load i8, i8* %28
%30 = uitofp i8 %29 to x86_fp80
%31 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %30, x86_fp80 0xK40278000000000000000, x86_fp80 %27)
%32 = getelementptr inbounds i8, i8* %0, i64 6
%33 = load i8, i8* %32
%34 = uitofp i8 %33 to x86_fp80
%35 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %34, x86_fp80 0xK402F8000000000000000, x86_fp80 %31)
%36 = getelementptr inbounds i8, i8* %0, i64 7
%37 = load i8, i8* %36
%38 = uitofp i8 %37 to x86_fp80
%39 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %38, x86_fp80 0xK40378000000000000000, x86_fp80 %35)
%40 = getelementptr inbounds i8, i8* %0, i64 8
%41 = load i8, i8* %40
%42 = uitofp i8 %41 to x86_fp80
%43 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %42, x86_fp80 0xK403F8000000000000000, x86_fp80 %39)
%44 = getelementptr inbounds i8, i8* %0, i64 9
%45 = load i8, i8* %44
%46 = uitofp i8 %45 to x86_fp80
%47 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %46, x86_fp80 0xK40478000000000000000, x86_fp80 %43)
%48 = getelementptr inbounds i8, i8* %0, i64 10
%49 = load i8, i8* %48
%50 = uitofp i8 %49 to x86_fp80
%51 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %50, x86_fp80 0xK404F8000000000000000, x86_fp80 %47)
%52 = uitofp i8 %9 to x86_fp80
%53 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %52, x86_fp80 0xK40578000000000000000, x86_fp80 %51)
%54 = fneg x86_fp80 %53
%55 = select i1 %4, x86_fp80 %54, x86_fp80 %53
ret x86_fp80 %55
}