#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*/ ffpmsg(char *);
scalar_t__ snprintf(char *, int, char *, int, ...);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
int ffr2e(float fval, int decim, char *cval, int *status) {
  char *cptr;
  if (*status > 0)
    return (*status);
  cval[0] = '\0';
  if (decim < 0) {
    if (snprintf(cval, 71, "%.*G", -decim, fval) < 0) {
      ffpmsg("Error in ffr2e converting float to string");
      *status = 402;
    } else {
      if (!strchr(cval, '.') && strchr(cval, 'E')) {
        if (snprintf(cval, 71, "%.1E", fval) < 0) {
          ffpmsg("Error in ffr2e converting float to string");
          *status = 402;
        }
        return (*status);
      }
    }
  } else {
    if (snprintf(cval, 71, "%.*E", decim, fval) < 0) {
      ffpmsg("Error in ffr2e converting float to string");
      *status = 402;
    }
  }
  if (*status <= 0) {
    if ((cptr = strchr(cval, ',')))
      *cptr = '.';
    if (strchr(cval, 'N')) {
      ffpmsg("Error in ffr2e: float value is a NaN or INDEF");
      *status = 402;
    } else if (!strchr(cval, '.') && !strchr(cval, 'E') &&
               strlen(cval) < 71 - 1) {
      strcat(cval, ".");
    }
  }
  return (*status);
}


x86 assembly (clang, -O0):
<ffr2e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1183 <ffr2e+0x33>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1372 <ffr2e+0x222>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x0,-0xc(%rbp)
jge    1262 <ffr2e+0x112>
mov    -0x18(%rbp),%rdi
xor    %ecx,%ecx
sub    -0xc(%rbp),%ecx
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x47,%esi
lea    0xe4e(%rip),%rdx
mov    $0x1,%al
call   1060 <snprintf@plt>
cmp    $0x0,%rax
jge    11de <ffr2e+0x8e>
lea    0xe3b(%rip),%rdi
call   1040 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x192,(%rax)
jmp    125d <ffr2e+0x10d>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1258 <ffr2e+0x108>
mov    -0x18(%rbp),%rdi
mov    $0x45,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1258 <ffr2e+0x108>
mov    -0x18(%rbp),%rdi
cvttss2si -0x8(%rbp),%ecx
mov    $0x47,%esi
lea    0xe0c(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
cmp    $0x0,%rax
jge    124a <ffr2e+0xfa>
lea    0xdca(%rip),%rdi
call   1040 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x192,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1372 <ffr2e+0x222>
jmp    125d <ffr2e+0x10d>
jmp    12aa <ffr2e+0x15a>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%ecx
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x47,%esi
lea    0xdb6(%rip),%rdx
mov    $0x1,%al
call   1060 <snprintf@plt>
cmp    $0x0,%rax
jge    12a5 <ffr2e+0x155>
lea    0xd6f(%rip),%rdi
call   1040 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x192,(%rax)
jmp    12aa <ffr2e+0x15a>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1369 <ffr2e+0x219>
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12da <ffr2e+0x18a>
mov    -0x28(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x4e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     130d <ffr2e+0x1bd>
lea    0xd40(%rip),%rdi
call   1040 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x192,(%rax)
jmp    1364 <ffr2e+0x214>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    135f <ffr2e+0x20f>
mov    -0x18(%rbp),%rdi
mov    $0x45,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    135f <ffr2e+0x20f>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x46,%eax
jge    135f <ffr2e+0x20f>
mov    -0x18(%rbp),%rdi
lea    0xd0d(%rip),%rsi
call   1070 <strcat@plt>
jmp    1364 <ffr2e+0x214>
jmp    1369 <ffr2e+0x219>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffr2e>:
push   %r14
push   %rbx
push   %rax
mov    (%rdx),%eax
test   %eax,%eax
jg     1210 <ffr2e+0xc0>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ecx
movb   $0x0,(%rsi)
test   %edi,%edi
js     118e <ffr2e+0x3e>
cvtss2sd %xmm0,%xmm0
lea    0xebc(%rip),%rdx
mov    %r14,%rdi
mov    $0x47,%esi
mov    $0x1,%al
call   1060 <snprintf@plt>
test   %rax,%rax
jns    11c7 <ffr2e+0x77>
jmp    11fc <ffr2e+0xac>
neg    %ecx
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe5f(%rip),%rdx
mov    %r14,%rdi
mov    $0x47,%esi
mov    $0x1,%al
call   1060 <snprintf@plt>
test   %rax,%rax
js     11fc <ffr2e+0xac>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1218 <ffr2e+0xc8>
cmpl   $0x0,(%rbx)
jg     120e <ffr2e+0xbe>
mov    %r14,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e1 <ffr2e+0x91>
movb   $0x2e,(%rax)
mov    %r14,%rdi
mov    $0x4e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1264 <ffr2e+0x114>
lea    0xe3f(%rip),%rdi
jmp    1203 <ffr2e+0xb3>
lea    0xe02(%rip),%rdi
call   1040 <ffpmsg@plt>
movl   $0x192,(%rbx)
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    $0x45,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11c7 <ffr2e+0x77>
cvttss2si 0x4(%rsp),%ecx
lea    0xdf8(%rip),%rdx
mov    %r14,%rdi
mov    $0x47,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
test   %rax,%rax
jns    120e <ffr2e+0xbe>
lea    0xdb3(%rip),%rdi
call   1040 <ffpmsg@plt>
movl   $0x192,(%rbx)
mov    $0x192,%eax
jmp    1210 <ffr2e+0xc0>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    120e <ffr2e+0xbe>
mov    %r14,%rdi
mov    $0x45,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    120e <ffr2e+0xbe>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x45,%eax
jg     120e <ffr2e+0xbe>
lea    0xdc7(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
jmp    120e <ffr2e+0xbe>

LLVM IR (-O0):
@.str = [5 x i8] c"%.*G\00"
@.str.1 = [42 x i8] c"Error in ffr2e converting float to string\00"
@.str.2 = [5 x i8] c"%.1E\00"
@.str.3 = [5 x i8] c"%.*E\00"
@.str.4 = [46 x i8] c"Error in ffr2e: float value is a NaN or INDEF\00"
@.str.5 = [2 x i8] c".\00"
define i32 @ffr2e(float %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i8*
store float %0, float* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%11 = load i32*, i32** %9
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32*, i32** %9
%16 = load i32, i32* %15
store i32 %16, i32* %5
br label %103
17: ; preds = %4
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 0, i8* %19
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %55
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = load i32, i32* %7
%25 = sub nsw i32 0, %24
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %23, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %25, double %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32*, i32** %9
store i32 402, i32* %32
br label %54
33: ; preds = %22
%34 = load i8*, i8** %8
%35 = call i8* @strchr(i8* %34, i8 signext 46)
%36 = icmp ne i8* %35, null
br i1 %36, label %53, label %37
37: ; preds = %33
%38 = load i8*, i8** %8
%39 = call i8* @strchr(i8* %38, i8 signext 69)
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i8*, i8** %8
%43 = load float, float* %6
%44 = fptosi float %43 to i32
%45 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %42, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32*, i32** %9
store i32 402, i32* %49
br label %50
50: ; preds = %47, %41
%51 = load i32*, i32** %9
%52 = load i32, i32* %51
store i32 %52, i32* %5
br label %103
53: ; preds = %37, %33
br label %54
54: ; preds = %53, %30
br label %66
55: ; preds = %17
%56 = load i8*, i8** %8
%57 = load i32, i32* %7
%58 = load float, float* %6
%59 = fpext float %58 to double
%60 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %56, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %57, double %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %55
%63 = call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%64 = load i32*, i32** %9
store i32 402, i32* %64
br label %65
65: ; preds = %62, %55
br label %66
66: ; preds = %65, %54
%67 = load i32*, i32** %9
%68 = load i32, i32* %67
%69 = icmp sle i32 %68, 0
br i1 %69, label %70, label %100
70: ; preds = %66
%71 = load i8*, i8** %8
%72 = call i8* @strchr(i8* %71, i8 signext 44)
store i8* %72, i8** %10
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = load i8*, i8** %10
store i8 46, i8* %75
br label %76
76: ; preds = %74, %70
%77 = load i8*, i8** %8
%78 = call i8* @strchr(i8* %77, i8 signext 78)
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %83
80: ; preds = %76
%81 = call i32 @ffpmsg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%82 = load i32*, i32** %9
store i32 402, i32* %82
br label %99
83: ; preds = %76
%84 = load i8*, i8** %8
%85 = call i8* @strchr(i8* %84, i8 signext 46)
%86 = icmp ne i8* %85, null
br i1 %86, label %98, label %87
87: ; preds = %83
%88 = load i8*, i8** %8
%89 = call i8* @strchr(i8* %88, i8 signext 69)
%90 = icmp ne i8* %89, null
br i1 %90, label %98, label %91
91: ; preds = %87
%92 = load i8*, i8** %8
%93 = call i32 @strlen(i8* %92)
%94 = icmp slt i32 %93, 70
br i1 %94, label %95, label %98
95: ; preds = %91
%96 = load i8*, i8** %8
%97 = call i32 @strcat(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %98
98: ; preds = %95, %91, %87, %83
br label %99
99: ; preds = %98, %80
br label %100
100: ; preds = %99, %66
%101 = load i32*, i32** %9
%102 = load i32, i32* %101
store i32 %102, i32* %5
br label %103
103: ; preds = %100, %50, %14
%104 = load i32, i32* %5
ret i32 %104
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.*G\00"
@.str.1 = [42 x i8] c"Error in ffr2e converting float to string\00"
@.str.2 = [5 x i8] c"%.1E\00"
@.str.3 = [5 x i8] c"%.*E\00"
@.str.4 = [46 x i8] c"Error in ffr2e: float value is a NaN or INDEF\00"
@.str.5 = [2 x i8] c".\00"
define i32 @ffr2e(float %0, i32 %1, i8* %2, i32* nocapture %3) {
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 0
br i1 %6, label %61, label %7
7: ; preds = %4
store i8 0, i8* %2
%8 = icmp slt i32 %1, 0
br i1 %8, label %9, label %30
9: ; preds = %7
%10 = sub nsw i32 0, %1
%11 = fpext float %0 to double
%12 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10, double %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 402, i32* %3
br label %59
16: ; preds = %9
%17 = tail call i8* @strchr(i8* %2, i8 signext 46)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %36
19: ; preds = %16
%20 = tail call i8* @strchr(i8* %2, i8 signext 69)
%21 = icmp eq i8* %20, null
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = fptosi float %0 to i32
%24 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = load i32, i32* %3
br label %61
28: ; preds = %22
%29 = tail call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 402, i32* %3
br label %61
30: ; preds = %7
%31 = fpext float %0 to double
%32 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %1, double %31)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = tail call i32 @ffpmsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 402, i32* %3
br label %59
36: ; preds = %30, %19, %16
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 1
br i1 %38, label %39, label %59
39: ; preds = %36
%40 = tail call i8* @strchr(i8* %2, i8 signext 44)
%41 = icmp eq i8* %40, null
br i1 %41, label %43, label %42
42: ; preds = %39
store i8 46, i8* %40
br label %43
43: ; preds = %42, %39
%44 = tail call i8* @strchr(i8* %2, i8 signext 78)
%45 = icmp eq i8* %44, null
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 @ffpmsg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
store i32 402, i32* %3
br label %59
48: ; preds = %43
%49 = tail call i8* @strchr(i8* %2, i8 signext 46)
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = tail call i8* @strchr(i8* %2, i8 signext 69)
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = tail call i32 @strlen(i8* %2)
%56 = icmp slt i32 %55, 70
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %14, %34, %46, %57, %54, %51, %48, %36
%60 = load i32, i32* %3
br label %61
61: ; preds = %28, %26, %4, %59
%62 = phi i32 [ %60, %59 ], [ %5, %4 ], [ %27, %26 ], [ 402, %28 ]
ret i32 %62
}