#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 */
typedef int uint64_t;

/* Variables and functions */
double frexp(double, int *);
int sscanf(char *, char *, double *, int *);
int parse_float(char *cp, char **endp, int size, unsigned *flt) {
  double d;
  double frac;
  uint64_t ufrac;
  uint64_t onehalf;
  int i;
  int n;
  int sexp;
  unsigned uexp;
  unsigned sign = 0;
  i = sscanf(cp,
             "%lf"
             "%n",
             &d, &n);
  if (i == 0)
    return 0;
  ;
  ;
  cp += n;
  if (endp)
    *endp = cp;
  if (d == 0.0) {
    for (i = 0; i < size; i++) {
      flt[i] = 0;
    }
    return 1;
  }
  frac = frexp(d, &sexp);
  ;
  if (sexp < -127 || sexp > 127)
    return 0;
  uexp = sexp + 128;
  uexp &= 0xff;
  ;
  if (frac < 0) {
    sign = (1 << 15);
    frac = -frac;
  }
  ufrac = (uint64_t)(frac * 144115188075855872.0);
  ;
  ;
  onehalf = 1ULL << (16 * (4 - size));
  ufrac += onehalf;
  ;
  if ((ufrac >> 57) > 0) {
    if (uexp < 0xFF) {
      ufrac >>= 1;
      uexp++;
      ;
    } else {
      ufrac -= onehalf;
      ;
    }
  }
  ufrac >>= 1;
  flt[0] = (unsigned)(sign | (uexp << 7) | ((ufrac >> 48) & 0x7F));
  if (size > 1) {
    flt[1] = (unsigned)((ufrac >> 32) & 0xffff);
    if (size > 2) {
      flt[2] = (unsigned)((ufrac >> 16) & 0xffff);
      flt[3] = (unsigned)((ufrac >> 0) & 0xffff);
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    116f <parse_float+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    1375 <parse_float+0x255>
mov    -0x48(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1196 <parse_float+0x76>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ea <parse_float+0xca>
jp     11ea <parse_float+0xca>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11de <parse_float+0xbe>
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b5 <parse_float+0x95>
movl   $0x1,-0x4(%rbp)
jmp    1375 <parse_float+0x255>
movsd  -0x30(%rbp),%xmm0
lea    -0x4c(%rbp),%rdi
call   1030 <frexp@plt>
movsd  %xmm0,-0x38(%rbp)
cmpl   $0xffffff81,-0x4c(%rbp)
jl     1211 <parse_float+0xf1>
cmpl   $0x7f,-0x4c(%rbp)
jle    121d <parse_float+0xfd>
movl   $0x0,-0x4(%rbp)
jmp    1375 <parse_float+0x255>
mov    -0x4c(%rbp),%eax
add    $0x80,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1269 <parse_float+0x149>
movl   $0x8000,-0x54(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd8f(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
mov    $0x4,%eax
sub    -0x1c(%rbp),%eax
shl    $0x4,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x39,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jle    12e7 <parse_float+0x1c7>
cmpl   $0xff,-0x50(%rbp)
jae    12d7 <parse_float+0x1b7>
mov    -0x3c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12e2 <parse_float+0x1c2>
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
jmp    12e7 <parse_float+0x1c7>
mov    -0x3c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x50(%rbp),%ecx
shl    $0x7,%ecx
or     %ecx,%eax
mov    %eax,-0x58(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    -0x58(%rbp),%ecx
and    $0x7f,%eax
or     %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x1c(%rbp)
jle    136e <parse_float+0x24e>
mov    -0x3c(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xffff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x2,-0x1c(%rbp)
jle    1369 <parse_float+0x249>
mov    -0x3c(%rbp),%ecx
sar    $0x10,%ecx
and    $0xffff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x3c(%rbp),%ecx
sar    $0x0,%ecx
and    $0xffff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0xc(%rax)
jmp    136e <parse_float+0x24e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_float>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xec9(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1050 <sscanf@plt>
xor    %r15d,%r15d
test   %eax,%eax
je     1227 <parse_float+0xf7>
test   %rbp,%rbp
je     117a <parse_float+0x4a>
movslq 0x4(%rsp),%rax
add    %rax,%rbx
mov    %rbx,0x0(%rbp)
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ae <parse_float+0x7e>
jp     11ae <parse_float+0x7e>
mov    $0x1,%r15d
test   %r12d,%r12d
jle    1227 <parse_float+0xf7>
mov    %r12d,%edx
shl    $0x2,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
jmp    1227 <parse_float+0xf7>
mov    %rsp,%rdi
call   1040 <frexp@plt>
mov    (%rsp),%eax
add    $0xffffff80,%eax
cmp    $0xffffff01,%eax
jb     1227 <parse_float+0xf7>
mov    %r12d,%ecx
shl    $0x4,%cl
neg    %cl
mov    $0x1,%eax
shl    %cl,%rax
mov    $0x1,%r15d
cmp    $0x3,%r12d
jl     1227 <parse_float+0xf7>
movapd 0xe19(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
mulsd  0xe04(%rip),%xmm3
cvttsd2si %xmm3,%ecx
add    %ecx,%eax
mov    %eax,%ecx
shr    %ecx
sar    $0x11,%eax
movzwl %ax,%eax
mov    %eax,0x8(%r14)
movzwl %cx,%eax
mov    %eax,0xc(%r14)
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lf%n\00"
define i32 @parse_float(i8* %0, i8** %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32*
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 0, i32* %18
%19 = load i8*, i8** %6
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %10, i32* %15)
store i32 %20, i32* %14
%21 = load i32, i32* %14
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %4
store i32 0, i32* %5
br label %135
24: ; preds = %4
%25 = load i32, i32* %15
%26 = load i8*, i8** %6
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8* %28, i8** %6
%29 = load i8**, i8*** %7
%30 = icmp ne i8** %29, null
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i8*, i8** %6
%33 = load i8**, i8*** %7
store i8* %32, i8** %33
br label %34
34: ; preds = %31, %24
%35 = load double, double* %10
%36 = fcmp oeq double %35, 0.000000e+00
br i1 %36, label %37, label %51
37: ; preds = %34
store i32 0, i32* %14
br label %38
38: ; preds = %47, %37
%39 = load i32, i32* %14
%40 = load i32, i32* %8
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i32*, i32** %9
%44 = load i32, i32* %14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 0, i32* %46
br label %47
47: ; preds = %42
%48 = load i32, i32* %14
%49 = add nsw i32 %48, 1
store i32 %49, i32* %14
br label %38
50: ; preds = %38
store i32 1, i32* %5
br label %135
51: ; preds = %34
%52 = load double, double* %10
%53 = call double @frexp(double %52, i32* %16)
store double %53, double* %11
%54 = load i32, i32* %16
%55 = icmp slt i32 %54, -127
br i1 %55, label %59, label %56
56: ; preds = %51
%57 = load i32, i32* %16
%58 = icmp sgt i32 %57, 127
br i1 %58, label %59, label %60
59: ; preds = %56, %51
store i32 0, i32* %5
br label %135
60: ; preds = %56
%61 = load i32, i32* %16
%62 = add nsw i32 %61, 128
store i32 %62, i32* %17
%63 = load i32, i32* %17
%64 = and i32 %63, 255
store i32 %64, i32* %17
%65 = load double, double* %11
%66 = fcmp olt double %65, 0.000000e+00
br i1 %66, label %67, label %70
67: ; preds = %60
store i32 32768, i32* %18
%68 = load double, double* %11
%69 = fneg double %68
store double %69, double* %11
br label %70
70: ; preds = %67, %60
%71 = load double, double* %11
%72 = fmul double %71, 0x4380000000000000
%73 = fptosi double %72 to i32
store i32 %73, i32* %12
%74 = load i32, i32* %8
%75 = sub nsw i32 4, %74
%76 = mul nsw i32 16, %75
%77 = zext i32 %76 to i64
%78 = shl i64 1, %77
%79 = trunc i64 %78 to i32
store i32 %79, i32* %13
%80 = load i32, i32* %13
%81 = load i32, i32* %12
%82 = add nsw i32 %81, %80
store i32 %82, i32* %12
%83 = load i32, i32* %12
%84 = ashr i32 %83, 57
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %99
86: ; preds = %70
%87 = load i32, i32* %17
%88 = icmp ult i32 %87, 255
br i1 %88, label %89, label %94
89: ; preds = %86
%90 = load i32, i32* %12
%91 = ashr i32 %90, 1
store i32 %91, i32* %12
%92 = load i32, i32* %17
%93 = add i32 %92, 1
store i32 %93, i32* %17
br label %98
94: ; preds = %86
%95 = load i32, i32* %13
%96 = load i32, i32* %12
%97 = sub nsw i32 %96, %95
store i32 %97, i32* %12
br label %98
98: ; preds = %94, %89
br label %99
99: ; preds = %98, %70
%100 = load i32, i32* %12
%101 = ashr i32 %100, 1
store i32 %101, i32* %12
%102 = load i32, i32* %18
%103 = load i32, i32* %17
%104 = shl i32 %103, 7
%105 = or i32 %102, %104
%106 = load i32, i32* %12
%107 = ashr i32 %106, 48
%108 = and i32 %107, 127
%109 = or i32 %105, %108
%110 = load i32*, i32** %9
%111 = getelementptr inbounds i32, i32* %110, i64 0
store i32 %109, i32* %111
%112 = load i32, i32* %8
%113 = icmp sgt i32 %112, 1
br i1 %113, label %114, label %134
114: ; preds = %99
%115 = load i32, i32* %12
%116 = ashr i32 %115, 32
%117 = and i32 %116, 65535
%118 = load i32*, i32** %9
%119 = getelementptr inbounds i32, i32* %118, i64 1
store i32 %117, i32* %119
%120 = load i32, i32* %8
%121 = icmp sgt i32 %120, 2
br i1 %121, label %122, label %133
122: ; preds = %114
%123 = load i32, i32* %12
%124 = ashr i32 %123, 16
%125 = and i32 %124, 65535
%126 = load i32*, i32** %9
%127 = getelementptr inbounds i32, i32* %126, i64 2
store i32 %125, i32* %127
%128 = load i32, i32* %12
%129 = ashr i32 %128, 0
%130 = and i32 %129, 65535
%131 = load i32*, i32** %9
%132 = getelementptr inbounds i32, i32* %131, i64 3
store i32 %130, i32* %132
br label %133
133: ; preds = %122, %114
br label %134
134: ; preds = %133, %99
store i32 1, i32* %5
br label %135
135: ; preds = %134, %59, %50, %23
%136 = load i32, i32* %5
ret i32 %136
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lf%n\00"
define i32 @parse_float(i8* %0, i8** writeonly %1, i32 %2, i32* nocapture writeonly %3) {
%5 = bitcast i32* %3 to i8*
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = bitcast double* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = bitcast i32* %8 to i8*
%12 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %6, i32* %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %53, label %14
14: ; preds = %4
%15 = icmp eq i8** %1, null
br i1 %15, label %20, label %16
16: ; preds = %14
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8* %19, i8** %1
br label %20
20: ; preds = %16, %14
%21 = load double, double* %6
%22 = fcmp oeq double %21, 0.000000e+00
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = icmp sgt i32 %2, 0
br i1 %24, label %25, label %53
25: ; preds = %23
%26 = zext i32 %2 to i64
%27 = shl nuw nsw i64 %26, 2
br label %53
28: ; preds = %20
%29 = call double @frexp(double %21, i32* %8)
%30 = load i32, i32* %8
%31 = add i32 %30, -128
%32 = icmp ult i32 %31, -255
br i1 %32, label %53, label %33
33: ; preds = %28
%34 = fcmp olt double %29, 0.000000e+00
%35 = fneg double %29
%36 = select i1 %34, double %35, double %29
%37 = fmul double %36, 0x4380000000000000
%38 = fptosi double %37 to i32
%39 = mul i32 %2, -16
%40 = add i32 %39, 64
%41 = zext i32 %40 to i64
%42 = shl nuw i64 1, %41
%43 = trunc i64 %42 to i32
%44 = add nsw i32 %38, %43
%45 = icmp slt i32 %2, 3
br i1 %45, label %53, label %46
46: ; preds = %33
%47 = lshr i32 %44, 1
%48 = ashr i32 %44, 17
%49 = and i32 %48, 65535
%50 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %49, i32* %50
%51 = and i32 %47, 65535
%52 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %51, i32* %52
br label %53
53: ; preds = %25, %23, %33, %46, %28, %4
%54 = phi i32 [ 0, %4 ], [ 0, %28 ], [ 1, %46 ], [ 1, %33 ], [ 1, %23 ], [ 1, %25 ]
ret i32 %54
}