#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 */
double DBL_MAX;
int /*<<< orphan*/ fail_test(int);
int /*<<< orphan*/ sprintf(char *, char *, double);
double str_real(char *, int *);
void test_real() {
  int error;
  double d0 = str_real("+12.34", &error);
  double d1 = 12.34;
  if (error || d0 != d1)
    fail_test(146);
  ;
  d0 = str_real("-12.34", &error);
  d1 = -12.34;
  if (error || d0 != d1)
    fail_test(151);
  ;
  d0 = str_real(".3", &error);
  d1 = .3;
  if (error || d0 != d1)
    fail_test(156);
  ;
  d0 = str_real("12345", &error);
  d1 = 12345;
  if (error || d0 != d1)
    fail_test(161);
  ;
  double d = str_real("", &error);
  if (!error)
    fail_test(165);
  ;
  d = str_real(".", &error);
  if (!error)
    fail_test(169);
  ;
  d = str_real("0.a", &error);
  if (!error)
    fail_test(173);
  ;
  d = str_real("32aa.cbd", &error);
  if (!error)
    fail_test(177);
  ;
  char dblmax[320];
  sprintf(dblmax, "%f", DBL_MAX);
  d = str_real(dblmax, &error);
  if (error || (d != DBL_MAX))
    fail_test(183);
  ;
}


x86 assembly (clang, -O0):
<test_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
lea    0xede(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1182 <test_real+0x52>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1182 <test_real+0x52>
jp     1182 <test_real+0x52>
jmp    118c <test_real+0x5c>
mov    $0x92,%edi
call   1040 <fail_test@plt>
lea    0xe94(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11d3 <test_real+0xa3>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11d3 <test_real+0xa3>
jp     11d3 <test_real+0xa3>
jmp    11dd <test_real+0xad>
mov    $0x97,%edi
call   1040 <fail_test@plt>
lea    0xe4a(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe16(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1224 <test_real+0xf4>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1224 <test_real+0xf4>
jp     1224 <test_real+0xf4>
jmp    122e <test_real+0xfe>
mov    $0x9c,%edi
call   1040 <fail_test@plt>
lea    0xdfc(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xdcd(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1275 <test_real+0x145>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1275 <test_real+0x145>
jp     1275 <test_real+0x145>
jmp    127f <test_real+0x14f>
mov    $0xa1,%edi
call   1040 <fail_test@plt>
lea    0xdb2(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12a8 <test_real+0x178>
mov    $0xa5,%edi
call   1040 <fail_test@plt>
lea    0xd88(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12d1 <test_real+0x1a1>
mov    $0xa9,%edi
call   1040 <fail_test@plt>
lea    0xd61(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12fa <test_real+0x1ca>
mov    $0xad,%edi
call   1040 <fail_test@plt>
lea    0xd3c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1323 <test_real+0x1f3>
mov    $0xb1,%edi
call   1040 <fail_test@plt>
lea    -0x160(%rbp),%rdi
mov    0x2caf(%rip),%rax
movsd  (%rax),%xmm0
lea    0xd0a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x160(%rbp),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <str_real@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1381 <test_real+0x251>
movsd  -0x20(%rbp),%xmm0
mov    0x2c74(%rip),%rax
ucomisd (%rax),%xmm0
jne    1381 <test_real+0x251>
jp     1381 <test_real+0x251>
jmp    138b <test_real+0x25b>
mov    $0xb7,%edi
call   1040 <fail_test@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_real>:
push   %r14
push   %rbx
sub    $0x158,%rsp
lea    0xedf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    115e <test_real+0x2e>
ucomisd 0xea6(%rip),%xmm0
jne    115e <test_real+0x2e>
jnp    1168 <test_real+0x38>
mov    $0x92,%edi
call   1040 <fail_test@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    118c <test_real+0x5c>
ucomisd 0xe80(%rip),%xmm0
jne    118c <test_real+0x5c>
jnp    1196 <test_real+0x66>
mov    $0x97,%edi
call   1040 <fail_test@plt>
lea    0xe91(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    11ba <test_real+0x8a>
ucomisd 0xe5a(%rip),%xmm0
jne    11ba <test_real+0x8a>
jnp    11c4 <test_real+0x94>
mov    $0x9c,%edi
call   1040 <fail_test@plt>
lea    0xe66(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    11e8 <test_real+0xb8>
ucomisd 0xe34(%rip),%xmm0
jne    11e8 <test_real+0xb8>
jnp    11f2 <test_real+0xc2>
mov    $0xa1,%edi
call   1040 <fail_test@plt>
lea    0xe3f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    1214 <test_real+0xe4>
mov    $0xa5,%edi
call   1040 <fail_test@plt>
lea    0xe1c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    1236 <test_real+0x106>
mov    $0xa9,%edi
call   1040 <fail_test@plt>
lea    0xdfc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    1258 <test_real+0x128>
mov    $0xad,%edi
call   1040 <fail_test@plt>
lea    0xdde(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    127a <test_real+0x14a>
mov    $0xb1,%edi
call   1040 <fail_test@plt>
mov    0x2d5f(%rip),%r14
movsd  (%r14),%xmm0
lea    0xdb9(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <str_real@plt>
cmpl   $0x0,0xc(%rsp)
jne    12b7 <test_real+0x187>
ucomisd (%r14),%xmm0
jne    12b7 <test_real+0x187>
jnp    12c1 <test_real+0x191>
mov    $0xb7,%edi
call   1040 <fail_test@plt>
add    $0x158,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"+12.34\00"
@.str.1 = [7 x i8] c"-12.34\00"
@.str.2 = [3 x i8] c".3\00"
@.str.3 = [6 x i8] c"12345\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c".\00"
@.str.6 = [4 x i8] c"0.a\00"
@.str.7 = [9 x i8] c"32aa.cbd\00"
@.str.8 = [3 x i8] c"%f\00"
@DBL_MAX = global double 0.000000e+00
define void @test_real() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [320 x i8]
%6 = call double @str_real(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1)
store double %6, double* %2
store double 1.234000e+01, double* %3
%7 = load i32, i32* %1
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = load double, double* %2
%11 = load double, double* %3
%12 = fcmp une double %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9, %0
%14 = call i32 @fail_test(i32 146)
br label %15
15: ; preds = %13, %9
%16 = call double @str_real(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store double %16, double* %2
store double -1.234000e+01, double* %3
%17 = load i32, i32* %1
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fcmp une double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19, %15
%24 = call i32 @fail_test(i32 151)
br label %25
25: ; preds = %23, %19
%26 = call double @str_real(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store double %26, double* %2
store double 3.000000e-01, double* %3
%27 = load i32, i32* %1
%28 = icmp ne i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load double, double* %2
%31 = load double, double* %3
%32 = fcmp une double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29, %25
%34 = call i32 @fail_test(i32 156)
br label %35
35: ; preds = %33, %29
%36 = call double @str_real(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1)
store double %36, double* %2
store double 1.234500e+04, double* %3
%37 = load i32, i32* %1
%38 = icmp ne i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load double, double* %2
%41 = load double, double* %3
%42 = fcmp une double %40, %41
br i1 %42, label %43, label %45
43: ; preds = %39, %35
%44 = call i32 @fail_test(i32 161)
br label %45
45: ; preds = %43, %39
%46 = call double @str_real(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32* %1)
store double %46, double* %4
%47 = load i32, i32* %1
%48 = icmp ne i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %45
%50 = call i32 @fail_test(i32 165)
br label %51
51: ; preds = %49, %45
%52 = call double @str_real(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32* %1)
store double %52, double* %4
%53 = load i32, i32* %1
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %51
%56 = call i32 @fail_test(i32 169)
br label %57
57: ; preds = %55, %51
%58 = call double @str_real(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %1)
store double %58, double* %4
%59 = load i32, i32* %1
%60 = icmp ne i32 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %57
%62 = call i32 @fail_test(i32 173)
br label %63
63: ; preds = %61, %57
%64 = call double @str_real(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32* %1)
store double %64, double* %4
%65 = load i32, i32* %1
%66 = icmp ne i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %63
%68 = call i32 @fail_test(i32 177)
br label %69
69: ; preds = %67, %63
%70 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%71 = load double, double* @DBL_MAX
%72 = call i32 @sprintf(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), double %71)
%73 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%74 = call double @str_real(i8* %73, i32* %1)
store double %74, double* %4
%75 = load i32, i32* %1
%76 = icmp ne i32 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %69
%78 = load double, double* %4
%79 = load double, double* @DBL_MAX
%80 = fcmp une double %78, %79
br i1 %80, label %81, label %83
81: ; preds = %77, %69
%82 = call i32 @fail_test(i32 183)
br label %83
83: ; preds = %81, %77
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"+12.34\00"
@.str.1 = [7 x i8] c"-12.34\00"
@.str.2 = [3 x i8] c".3\00"
@.str.3 = [6 x i8] c"12345\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c".\00"
@.str.6 = [4 x i8] c"0.a\00"
@.str.7 = [9 x i8] c"32aa.cbd\00"
@.str.8 = [3 x i8] c"%f\00"
@DBL_MAX = global double 0.000000e+00
define void @test_real() {
%1 = alloca i32
%2 = alloca [320 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call double @str_real(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
%7 = fcmp une double %4, 1.234000e+01
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @fail_test(i32 146)
br label %11
11: ; preds = %0, %9
%12 = call double @str_real(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 0
%15 = fcmp une double %12, -1.234000e+01
%16 = select i1 %14, i1 true, i1 %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @fail_test(i32 151)
br label %19
19: ; preds = %11, %17
%20 = call double @str_real(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
%22 = icmp ne i32 %21, 0
%23 = fcmp une double %20, 3.000000e-01
%24 = select i1 %22, i1 true, i1 %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @fail_test(i32 156)
br label %27
27: ; preds = %19, %25
%28 = call double @str_real(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%29 = load i32, i32* %1
%30 = icmp ne i32 %29, 0
%31 = fcmp une double %28, 1.234500e+04
%32 = select i1 %30, i1 true, i1 %31
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 @fail_test(i32 161)
br label %35
35: ; preds = %27, %33
%36 = call double @str_real(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @fail_test(i32 165)
br label %41
41: ; preds = %39, %35
%42 = call double @str_real(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%43 = load i32, i32* %1
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @fail_test(i32 169)
br label %47
47: ; preds = %45, %41
%48 = call double @str_real(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%49 = load i32, i32* %1
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 @fail_test(i32 173)
br label %53
53: ; preds = %51, %47
%54 = call double @str_real(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%55 = load i32, i32* %1
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 @fail_test(i32 177)
br label %59
59: ; preds = %57, %53
%60 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 0
%61 = load double, double* @DBL_MAX
%62 = call i32 @sprintf(i8* %60, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), double %61)
%63 = call double @str_real(i8* %60, i32* %1)
%64 = load i32, i32* %1
%65 = icmp ne i32 %64, 0
%66 = load double, double* @DBL_MAX
%67 = fcmp une double %63, %66
%68 = select i1 %65, i1 true, i1 %67
br i1 %68, label %69, label %71
69: ; preds = %59
%70 = call i32 @fail_test(i32 183)
br label %71
71: ; preds = %59, %69
ret void
}