#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *,
                           float, long double);
int /*<<< orphan*/ printf(char *, char const *, char const *, long double);
int /*<<< orphan*/ stderr;
double strtod(char const *, char **);
float strtof(char const *, char **);
long double strtold(char const *, char **);
int _strtold(char const *progname, char const *str, long double expected) {
  int ret = 0;
  long double ld;
  double d;
  float f;
  char *p;
  printf("%s: Testing strtold(\"%s\", %Lf)\n", progname, str, expected);
  ld = strtold(str, &p);
  if (ld != expected || *p != '\0') {
    fprintf(stderr, "%s: %s: Obtained %Lf (expected: %Lf)\n", progname,
            "strtold", ld, expected);
    ret = 1;
  }
  printf("%s: Testing strtod(\"%s\", %Lf)\n", progname, str, expected);
  d = strtod(str, &p);
  if (d != (double)expected || *p != '\0') {
    fprintf(stderr, "%s: %s: Obtained %f (expected: %f)\n", progname, "strtod",
            d, expected);
    ret = 1;
  }
  printf("%s: Testing strtof(\"%s\", %Lf)\n", progname, str, expected);
  f = strtof(str, &p);
  if (f != (float)expected || *p != '\0') {
    fprintf(stderr, "%s: %s: Obtained %f (expected: %f)\n", progname, "strtof",
            f, expected);
    ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<_strtold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x10(%rbp)
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
fstpt  -0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1070 <strtold@plt>
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11c9 <_strtold+0x79>
jp     11c9 <_strtold+0x79>
jmp    11b9 <_strtold+0x69>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1203 <_strtold+0xb3>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
fldt   -0x40(%rbp)
fstps  -0x5c(%rbp)
movss  -0x5c(%rbp),%xmm0
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe30(%rip),%rsi
lea    0xe4f(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
fldt   -0x20(%rbp)
fstpl  -0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jne    1261 <_strtold+0x111>
jp     1261 <_strtold+0x111>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1299 <_strtold+0x149>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xde7(%rip),%rsi
lea    0xe04(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1050 <strtof@plt>
movss  %xmm0,-0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
fldt   -0x20(%rbp)
fstps  -0x6c(%rbp)
movss  -0x6c(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    12f6 <_strtold+0x1a6>
jp     12f6 <_strtold+0x1a6>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     132a <_strtold+0x1da>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
movss  -0x4c(%rbp),%xmm0
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xd56(%rip),%rsi
lea    0xd99(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strtold>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
fstpt  (%rsp)
lea    0xe8e(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strtold@plt>
fldt   0x24(%rsp)
fxch   %st(1)
fucomi %st(1),%st
jne    11a4 <_strtold+0x54>
jp     11a4 <_strtold+0x54>
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
je     12b9 <_strtold+0x169>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
fstps  0x34(%rsp)
movss  0x34(%rsp),%xmm0
fstpt  (%rsp)
lea    0xe5f(%rip),%rsi
lea    0xe7e(%rip),%rcx
mov    %r14,%rdx
call   1060 <fprintf@plt>
fldt   0x24(%rsp)
mov    $0x1,%ebp
fstpt  (%rsp)
lea    0xe6b(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
fldt   0x24(%rsp)
fstl   0x38(%rsp)
ucomisd 0x38(%rsp),%xmm0
jne    1217 <_strtold+0xc7>
jp     1217 <_strtold+0xc7>
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
je     1246 <_strtold+0xf6>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
cvtsd2ss %xmm0,%xmm0
fstpt  (%rsp)
lea    0xe3f(%rip),%rsi
lea    0xe5c(%rip),%rcx
mov    %r14,%rdx
call   1060 <fprintf@plt>
fldt   0x24(%rsp)
mov    $0x1,%ebp
fstpt  (%rsp)
lea    0xe48(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <strtof@plt>
fldt   0x24(%rsp)
fsts   0x30(%rsp)
ucomiss 0x30(%rsp),%xmm0
jne    1283 <_strtold+0x133>
jp     1283 <_strtold+0x133>
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
je     12ac <_strtold+0x15c>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
fstpt  (%rsp)
lea    0xdd7(%rip),%rsi
lea    0xe1a(%rip),%rcx
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%ebp
fldz
fstp   %st(0)
mov    %ebp,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
fstp   %st(0)
xor    %ebp,%ebp
jmp    11d9 <_strtold+0x89>

LLVM IR (-O0):
@.str = [32 x i8] c"%s: Testing strtold(\22%s\22, %Lf)\0A\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"%s: %s: Obtained %Lf (expected: %Lf)\0A\00"
@.str.2 = [8 x i8] c"strtold\00"
@.str.3 = [31 x i8] c"%s: Testing strtod(\22%s\22, %Lf)\0A\00"
@.str.4 = [36 x i8] c"%s: %s: Obtained %f (expected: %f)\0A\00"
@.str.5 = [7 x i8] c"strtod\00"
@.str.6 = [31 x i8] c"%s: Testing strtof(\22%s\22, %Lf)\0A\00"
@.str.7 = [7 x i8] c"strtof\00"
define i32 @_strtold(i8* %0, i8* %1, x86_fp80 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca x86_fp80
%7 = alloca i32
%8 = alloca x86_fp80
%9 = alloca double
%10 = alloca float
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store x86_fp80 %2, x86_fp80* %6
store i32 0, i32* %7
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = load x86_fp80, x86_fp80* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, x86_fp80 %14)
%16 = load i8*, i8** %5
%17 = call x86_fp80 @strtold(i8* %16, i8** %11)
store x86_fp80 %17, x86_fp80* %8
%18 = load x86_fp80, x86_fp80* %8
%19 = load x86_fp80, x86_fp80* %6
%20 = fcmp une x86_fp80 %18, %19
br i1 %20, label %26, label %21
21: ; preds = %3
%22 = load i8*, i8** %11
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %21, %3
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %4
%29 = load x86_fp80, x86_fp80* %8
%30 = fptrunc x86_fp80 %29 to float
%31 = load x86_fp80, x86_fp80* %6
%32 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), float %30, x86_fp80 %31)
store i32 1, i32* %7
br label %33
33: ; preds = %26, %21
%34 = load i8*, i8** %4
%35 = load i8*, i8** %5
%36 = load x86_fp80, x86_fp80* %6
%37 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %35, x86_fp80 %36)
%38 = load i8*, i8** %5
%39 = call double @strtod(i8* %38, i8** %11)
store double %39, double* %9
%40 = load double, double* %9
%41 = load x86_fp80, x86_fp80* %6
%42 = fptrunc x86_fp80 %41 to double
%43 = fcmp une double %40, %42
br i1 %43, label %49, label %44
44: ; preds = %33
%45 = load i8*, i8** %11
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %44, %33
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %4
%52 = load double, double* %9
%53 = fptrunc double %52 to float
%54 = load x86_fp80, x86_fp80* %6
%55 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), float %53, x86_fp80 %54)
store i32 1, i32* %7
br label %56
56: ; preds = %49, %44
%57 = load i8*, i8** %4
%58 = load i8*, i8** %5
%59 = load x86_fp80, x86_fp80* %6
%60 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %57, i8* %58, x86_fp80 %59)
%61 = load i8*, i8** %5
%62 = call float @strtof(i8* %61, i8** %11)
store float %62, float* %10
%63 = load float, float* %10
%64 = load x86_fp80, x86_fp80* %6
%65 = fptrunc x86_fp80 %64 to float
%66 = fcmp une float %63, %65
br i1 %66, label %72, label %67
67: ; preds = %56
%68 = load i8*, i8** %11
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %67, %56
%73 = load i32, i32* @stderr
%74 = load i8*, i8** %4
%75 = load float, float* %10
%76 = load x86_fp80, x86_fp80* %6
%77 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %74, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), float %75, x86_fp80 %76)
store i32 1, i32* %7
br label %78
78: ; preds = %72, %67
%79 = load i32, i32* %7
ret i32 %79
}

LLVM IR (-O2):
@.str = [32 x i8] c"%s: Testing strtold(\22%s\22, %Lf)\0A\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"%s: %s: Obtained %Lf (expected: %Lf)\0A\00"
@.str.2 = [8 x i8] c"strtold\00"
@.str.3 = [31 x i8] c"%s: Testing strtod(\22%s\22, %Lf)\0A\00"
@.str.4 = [36 x i8] c"%s: %s: Obtained %f (expected: %f)\0A\00"
@.str.5 = [7 x i8] c"strtod\00"
@.str.6 = [31 x i8] c"%s: Testing strtof(\22%s\22, %Lf)\0A\00"
@.str.7 = [7 x i8] c"strtof\00"
define i32 @_strtold(i8* %0, i8* %1, x86_fp80 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, x86_fp80 %2)
%7 = call x86_fp80 @strtold(i8* %1, i8** %4)
%8 = fcmp une x86_fp80 %7, %2
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9, %3
%14 = load i32, i32* @stderr
%15 = fptrunc x86_fp80 %7 to float
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), float %15, x86_fp80 %2)
br label %17
17: ; preds = %13, %9
%18 = phi i32 [ 1, %13 ], [ 0, %9 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %1, x86_fp80 %2)
%20 = call double @strtod(i8* %1, i8** %4)
%21 = fptrunc x86_fp80 %2 to double
%22 = fcmp une double %20, %21
br i1 %22, label %27, label %23
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23, %17
%28 = load i32, i32* @stderr
%29 = fptrunc double %20 to float
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), float %29, x86_fp80 %2)
br label %31
31: ; preds = %27, %23
%32 = phi i32 [ 1, %27 ], [ %18, %23 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %1, x86_fp80 %2)
%34 = call float @strtof(i8* %1, i8** %4)
%35 = fptrunc x86_fp80 %2 to float
%36 = fcmp une float %34, %35
br i1 %36, label %41, label %37
37: ; preds = %31
%38 = load i8*, i8** %4
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %37, %31
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), float %34, x86_fp80 %2)
br label %44
44: ; preds = %41, %37
%45 = phi i32 [ 1, %41 ], [ %32, %37 ]
ret i32 %45
}