#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 */
char *calloc(int, int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
double remainder(double, double);
int /*<<< orphan*/ stderr;
char *cmio_re2c(const double x, const double xmin, const double xmax) {
  double z = 0.0;
  char *mio_out = calloc(8, sizeof(char));
  if (mio_out == NULL) {
    fputs("Unable to allocate mio_out buffer\n", stderr);
    return NULL;
  }
  memset(mio_out, ' ', sizeof(char) * 8);
  const double y = (x - xmin) / (xmax - xmin);
  if (y >= 1) {
    for (int j = 0; j < 8; j++) {
      mio_out[j] = (char)255;
    }
  } else if (y > 0) {
    z = y;
    for (int j = 0; j < 8; j++) {
      z = remainder(z, 1.0) * 224.0;
      mio_out[j] = (char)((int)z + 32);
    }
  }
  return mio_out;
}


x86 assembly (clang, -O0):
<cmio_re2c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x8,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    119f <cmio_re2c+0x5f>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe83(%rip),%rdi
call   1030 <fputs@plt>
movq   $0x0,-0x8(%rbp)
jmp    129b <cmio_re2c+0x15b>
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe24(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1216 <cmio_re2c+0xd6>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    1211 <cmio_re2c+0xd1>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ed <cmio_re2c+0xad>
jmp    1293 <cmio_re2c+0x153>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    128e <cmio_re2c+0x14e>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jge    1289 <cmio_re2c+0x149>
movsd  -0x28(%rbp),%xmm0
movsd  0xdb0(%rip),%xmm1
call   1060 <remainder@plt>
movsd  0xdab(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%eax
add    $0x20,%eax
mov    %al,%dl
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1239 <cmio_re2c+0xf9>
jmp    128e <cmio_re2c+0x14e>
jmp    1293 <cmio_re2c+0x153>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmio_re2c>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    $0x8,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12af <cmio_re2c+0x16f>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
ucomisd 0xe56(%rip),%xmm0
jae    12c6 <cmio_re2c+0x186>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12cd <cmio_re2c+0x18d>
movsd  0xe3a(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xe35(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,(%rbx)
movsd  0xe1d(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xe18(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x1(%rbx)
movsd  0xdff(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xdfa(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x2(%rbx)
movsd  0xde1(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xddc(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x3(%rbx)
movsd  0xdc3(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xdbe(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x4(%rbx)
movsd  0xda5(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xda0(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x5(%rbx)
movsd  0xd87(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xd82(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x6(%rbx)
movsd  0xd69(%rip),%xmm1
call   1060 <remainder@plt>
mulsd  0xd64(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%al
mov    %al,0x7(%rbx)
jmp    12cd <cmio_re2c+0x18d>
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
lea    0xd51(%rip),%rdi
call   1030 <fputs@plt>
jmp    12cd <cmio_re2c+0x18d>
movq   $0xffffffffffffffff,(%rbx)
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Unable to allocate mio_out buffer\0A\00"
@stderr = global i32 0
define i8* @cmio_re2c(double %0, double %1, double %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double 0.000000e+00, double* %8
%13 = call i8* @calloc(i32 8, i32 1)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = call i32 @fputs(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %17)
store i8* null, i8** %4
br label %71
19: ; preds = %3
%20 = load i8*, i8** %9
%21 = call i32 @memset(i8* %20, i8 signext 32, i32 8)
%22 = load double, double* %5
%23 = load double, double* %6
%24 = fsub double %22, %23
%25 = load double, double* %7
%26 = load double, double* %6
%27 = fsub double %25, %26
%28 = fdiv double %24, %27
store double %28, double* %10
%29 = load double, double* %10
%30 = fcmp oge double %29, 1.000000e+00
br i1 %30, label %31, label %44
31: ; preds = %19
store i32 0, i32* %11
br label %32
32: ; preds = %40, %31
%33 = load i32, i32* %11
%34 = icmp slt i32 %33, 8
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i8*, i8** %9
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 -1, i8* %39
br label %40
40: ; preds = %35
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %32
43: ; preds = %32
br label %69
44: ; preds = %19
%45 = load double, double* %10
%46 = fcmp ogt double %45, 0.000000e+00
br i1 %46, label %47, label %68
47: ; preds = %44
%48 = load double, double* %10
store double %48, double* %8
store i32 0, i32* %12
br label %49
49: ; preds = %64, %47
%50 = load i32, i32* %12
%51 = icmp slt i32 %50, 8
br i1 %51, label %52, label %67
52: ; preds = %49
%53 = load double, double* %8
%54 = call double @remainder(double %53, double 1.000000e+00)
%55 = fmul double %54, 2.240000e+02
store double %55, double* %8
%56 = load double, double* %8
%57 = fptosi double %56 to i32
%58 = add nsw i32 %57, 32
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %9
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 %59, i8* %63
br label %64
64: ; preds = %52
%65 = load i32, i32* %12
%66 = add nsw i32 %65, 1
store i32 %66, i32* %12
br label %49
67: ; preds = %49
br label %68
68: ; preds = %67, %44
br label %69
69: ; preds = %68, %43
%70 = load i8*, i8** %9
store i8* %70, i8** %4
br label %71
71: ; preds = %69, %16
%72 = load i8*, i8** %4
ret i8* %72
}

LLVM IR (-O2):
@.str = [35 x i8] c"Unable to allocate mio_out buffer\0A\00"
@stderr = global i32 0
define i8* @cmio_re2c(double %0, double %1, double %2) {
%4 = tail call dereferenceable_or_null(8) i8* @calloc(i32 8, i32 1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %67
9: ; preds = %3
%10 = tail call i32 @memset(i8* %4, i8 signext 32, i32 8)
%11 = fsub double %0, %1
%12 = fsub double %2, %1
%13 = fdiv double %11, %12
%14 = fcmp ult double %13, 1.000000e+00
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = bitcast i8* %4 to i64*
store i64 -1, i64* %16
br label %67
17: ; preds = %9
%18 = fcmp ogt double %13, 0.000000e+00
br i1 %18, label %19, label %67
19: ; preds = %17
%20 = tail call double @remainder(double %13, double 1.000000e+00)
%21 = fmul double %20, 2.240000e+02
%22 = fptosi double %21 to i32
%23 = trunc i32 %22 to i8
%24 = add i8 %23, 32
store i8 %24, i8* %4
%25 = tail call double @remainder(double %21, double 1.000000e+00)
%26 = fmul double %25, 2.240000e+02
%27 = fptosi double %26 to i32
%28 = trunc i32 %27 to i8
%29 = add i8 %28, 32
%30 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %29, i8* %30
%31 = tail call double @remainder(double %26, double 1.000000e+00)
%32 = fmul double %31, 2.240000e+02
%33 = fptosi double %32 to i32
%34 = trunc i32 %33 to i8
%35 = add i8 %34, 32
%36 = getelementptr inbounds i8, i8* %4, i64 2
store i8 %35, i8* %36
%37 = tail call double @remainder(double %32, double 1.000000e+00)
%38 = fmul double %37, 2.240000e+02
%39 = fptosi double %38 to i32
%40 = trunc i32 %39 to i8
%41 = add i8 %40, 32
%42 = getelementptr inbounds i8, i8* %4, i64 3
store i8 %41, i8* %42
%43 = tail call double @remainder(double %38, double 1.000000e+00)
%44 = fmul double %43, 2.240000e+02
%45 = fptosi double %44 to i32
%46 = trunc i32 %45 to i8
%47 = add i8 %46, 32
%48 = getelementptr inbounds i8, i8* %4, i64 4
store i8 %47, i8* %48
%49 = tail call double @remainder(double %44, double 1.000000e+00)
%50 = fmul double %49, 2.240000e+02
%51 = fptosi double %50 to i32
%52 = trunc i32 %51 to i8
%53 = add i8 %52, 32
%54 = getelementptr inbounds i8, i8* %4, i64 5
store i8 %53, i8* %54
%55 = tail call double @remainder(double %50, double 1.000000e+00)
%56 = fmul double %55, 2.240000e+02
%57 = fptosi double %56 to i32
%58 = trunc i32 %57 to i8
%59 = add i8 %58, 32
%60 = getelementptr inbounds i8, i8* %4, i64 6
store i8 %59, i8* %60
%61 = tail call double @remainder(double %56, double 1.000000e+00)
%62 = fmul double %61, 2.240000e+02
%63 = fptosi double %62 to i32
%64 = trunc i32 %63 to i8
%65 = add i8 %64, 32
%66 = getelementptr inbounds i8, i8* %4, i64 7
store i8 %65, i8* %66
br label %67
67: ; preds = %15, %19, %17, %6
ret i8* %4
}