#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 ssize_t;
typedef int int64_t;

/* Variables and functions */
double fabs(double);
scalar_t__ isinf(double);
scalar_t__ isnan(double);
double modf(double, double *);
char por_encode_base30_digit(int);
int por_write_base30_integer(char *, size_t, int);
ssize_t por_write_double_to_buffer(char *string, size_t buffer_len,
                                   double value, long precision) {
  int offset = 0;
  if (isnan(value)) {
    string[offset++] = '*';
    string[offset++] = '.';
  } else if (isinf(value)) {
    if (value < 0.0) {
      string[offset++] = '-';
    }
    string[offset++] = '1';
    string[offset++] = '+';
    string[offset++] = 'T';
    string[offset++] = 'T';
    string[offset++] = '/';
  } else {
    long integers_printed = 0;
    double integer_part;
    double fraction = modf(fabs(value), &integer_part);
    int64_t integer = integer_part;
    int64_t exponent = 0;
    if (value < 0.0) {
      string[offset++] = '-';
    }
    if (integer == 0) {
      string[offset++] = '0';
    } else {
      while (fraction == 0 && integer != 0 && (integer % 30) == 0) {
        integer /= 30;
        exponent++;
      }
      integers_printed = por_write_base30_integer(&string[offset],
                                                  buffer_len - offset, integer);
      offset += integers_printed;
    }
    if (fraction) {
      string[offset++] = '.';
    }
    while (fraction && integers_printed < precision) {
      fraction = modf(fraction * 30, &integer_part);
      integer = integer_part;
      if (integer < 0) {
        return -1;
      } else {
        string[offset++] = por_encode_base30_digit(integer);
      }
      integers_printed++;
    }
    if (exponent) {
      string[offset++] = '+';
      offset += por_write_base30_integer(&string[offset], buffer_len - offset,
                                         exponent);
    }
    string[offset++] = '/';
  }
  string[offset] = '\0';
  return offset;
}


x86 assembly (clang, -O0):
<por_write_double_to_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     11b5 <por_write_double_to_buffer+0x65>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2a,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2e,(%rax,%rcx,1)
jmp    14c1 <por_write_double_to_buffer+0x371>
movsd  -0x20(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     1260 <por_write_double_to_buffer+0x110>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11ed <por_write_double_to_buffer+0x9d>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2d,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x31,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2b,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x54,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x54,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
jmp    14bc <por_write_double_to_buffer+0x36c>
movq   $0x0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movaps 0xd8c(%rip),%xmm1
pand   %xmm1,%xmm0
lea    -0x40(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x48(%rbp)
cvttsd2si -0x40(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12b9 <por_write_double_to_buffer+0x169>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2d,(%rax,%rcx,1)
cmpl   $0x0,-0x4c(%rbp)
jne    12de <por_write_double_to_buffer+0x18e>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    1381 <por_write_double_to_buffer+0x231>
jmp    12e3 <por_write_double_to_buffer+0x193>
movsd  -0x48(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x51(%rbp)
jne    1323 <por_write_double_to_buffer+0x1d3>
jp     1323 <por_write_double_to_buffer+0x1d3>
xor    %eax,%eax
cmpl   $0x0,-0x4c(%rbp)
mov    %al,-0x51(%rbp)
je     1323 <por_write_double_to_buffer+0x1d3>
mov    -0x4c(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1333 <por_write_double_to_buffer+0x1e3>
jmp    134f <por_write_double_to_buffer+0x1ff>
mov    -0x4c(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12e3 <por_write_double_to_buffer+0x193>
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
sub    %rax,%rsi
mov    -0x4c(%rbp),%edx
call   1060 <por_write_base30_integer@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    139e <por_write_double_to_buffer+0x24e>
jp     139e <por_write_double_to_buffer+0x24e>
jmp    13b4 <por_write_double_to_buffer+0x264>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2e,(%rax,%rcx,1)
jmp    13b9 <por_write_double_to_buffer+0x269>
movsd  -0x48(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x52(%rbp)
jne    13db <por_write_double_to_buffer+0x28b>
jp     13db <por_write_double_to_buffer+0x28b>
jmp    13e9 <por_write_double_to_buffer+0x299>
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
setl   %al
mov    %al,-0x52(%rbp)
mov    -0x52(%rbp),%al
test   $0x1,%al
jne    13f9 <por_write_double_to_buffer+0x2a9>
jmp    1462 <por_write_double_to_buffer+0x312>
movsd  0xc0f(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
lea    -0x40(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x48(%rbp)
cvttsd2si -0x40(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    1432 <por_write_double_to_buffer+0x2e2>
movl   $0xffffffff,-0x4(%rbp)
jmp    14d3 <por_write_double_to_buffer+0x383>
mov    -0x4c(%rbp),%edi
call   1050 <por_encode_base30_digit@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    13b9 <por_write_double_to_buffer+0x269>
cmpl   $0x0,-0x50(%rbp)
je     14a6 <por_write_double_to_buffer+0x356>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2b,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
sub    %rax,%rsi
mov    -0x50(%rbp),%edx
call   1060 <por_write_base30_integer@plt>
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
jmp    14c1 <por_write_double_to_buffer+0x371>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<por_write_double_to_buffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
movapd %xmm0,0x10(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     1188 <por_write_double_to_buffer+0x38>
movw   $0x2e2a,(%r12)
mov    $0x2,%ebp
jmp    1399 <por_write_double_to_buffer+0x249>
movapd 0x10(%rsp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
je     11cf <por_write_double_to_buffer+0x7f>
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
ucomisd 0x10(%rsp),%xmm0
jbe    11b0 <por_write_double_to_buffer+0x60>
movb   $0x2d,(%r12)
mov    $0x1,%ebp
mov    %ebp,%eax
movw   $0x2b31,(%r12,%rax,1)
movb   $0x54,0x2(%r12,%rax,1)
movw   $0x2f54,0x3(%r12,%rax,1)
2f
add    $0x5,%ebp
jmp    1399 <por_write_double_to_buffer+0x249>
movapd 0xe29(%rip),%xmm0
andpd  0x10(%rsp),%xmm0
lea    0x8(%rsp),%rdi
call   1030 <modf@plt>
cvttsd2si 0x8(%rsp),%edx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
ucomisd 0x10(%rsp),%xmm1
jbe    1205 <por_write_double_to_buffer+0xb5>
movb   $0x2d,(%r12)
mov    $0x1,%ebp
test   %edx,%edx
je     12cc <por_write_double_to_buffer+0x17c>
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movsd  %xmm0,(%rsp)
jne    12ae <por_write_double_to_buffer+0x15e>
jp     12ae <por_write_double_to_buffer+0x15e>
movslq %edx,%rax
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x4,%eax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x5,%ecx
mov    %eax,%esi
sub    %ecx,%esi
add    %eax,%esi
add    %edx,%esi
jne    12ae <por_write_double_to_buffer+0x15e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %edx,%rax
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0x4,%edx
add    %ecx,%edx
add    $0x1,%ebx
add    $0xffffffe2,%eax
cmp    $0xffffffc4,%eax
ja     12ae <por_write_double_to_buffer+0x15e>
movslq %edx,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0x4,%ecx
add    %esi,%ecx
mov    %ecx,%esi
shl    $0x5,%esi
mov    %ecx,%edi
sub    %esi,%edi
add    %ecx,%edi
add    %eax,%edi
je     1260 <por_write_double_to_buffer+0x110>
mov    %ebp,%eax
lea    (%r12,%rax,1),%rdi
mov    %r13,%rsi
sub    %rax,%rsi
call   1060 <por_write_base30_integer@plt>
movslq %eax,%r14
add    %r14d,%ebp
movsd  (%rsp),%xmm0
jmp    12db <por_write_double_to_buffer+0x18b>
mov    %ebp,%eax
add    $0x1,%ebp
movb   $0x30,(%r12,%rax,1)
xor    %r14d,%r14d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %r13,0x20(%rsp)
jne    12ec <por_write_double_to_buffer+0x19c>
jnp    1362 <por_write_double_to_buffer+0x212>
movslq %ebp,%rax
add    $0x1,%ebp
movb   $0x2e,(%r12,%rax,1)
cmp    %r15,%r14
jge    1362 <por_write_double_to_buffer+0x212>
movslq %ebp,%r13
add    %r12,%r13
add    $0x1,%r14
cs nopw 0x0(%rax,%rax,1)
mulsd  0xcf8(%rip),%xmm0
lea    0x8(%rsp),%rdi
call   1030 <modf@plt>
cvttsd2si 0x8(%rsp),%edi
test   %edi,%edi
js     13b2 <por_write_double_to_buffer+0x262>
movsd  %xmm0,(%rsp)
call   1050 <por_encode_base30_digit@plt>
movsd  (%rsp),%xmm0
mov    %al,0x0(%r13)
add    $0x1,%ebp
ucomisd 0xcca(%rip),%xmm0
jne    1352 <por_write_double_to_buffer+0x202>
jnp    1362 <por_write_double_to_buffer+0x212>
add    $0x1,%r13
lea    0x1(%r14),%rax
cmp    %r15,%r14
mov    %rax,%r14
jl     1310 <por_write_double_to_buffer+0x1c0>
test   %ebx,%ebx
je     138e <por_write_double_to_buffer+0x23e>
movslq %ebp,%rbp
lea    0x1(%rbp),%rax
movb   $0x2b,(%r12,%rbp,1)
lea    (%r12,%rbp,1),%rdi
add    $0x1,%rdi
mov    0x20(%rsp),%rsi
sub    %rax,%rsi
mov    %ebx,%edx
call   1060 <por_write_base30_integer@plt>
add    %eax,%ebp
add    $0x1,%ebp
movslq %ebp,%rax
add    $0x1,%ebp
movb   $0x2f,(%r12,%rax,1)
movslq %ebp,%rax
movb   $0x0,(%r12,%rax,1)
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%ebp
jmp    13a1 <por_write_double_to_buffer+0x251>

LLVM IR (-O0):
define i32 @por_write_double_to_buffer(i8* %0, i64 %1, double %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca double
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store double %2, double* %8
store i64 %3, i64* %9
store i32 0, i32* %10
%16 = load double, double* %8
%17 = call i64 @isnan(double %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = load i32, i32* %10
%22 = add nsw i32 %21, 1
store i32 %22, i32* %10
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8 42, i8* %24
%25 = load i8*, i8** %6
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
store i32 %27, i32* %10
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8 46, i8* %29
br label %194
30: ; preds = %4
%31 = load double, double* %8
%32 = call i64 @isinf(double %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %69
34: ; preds = %30
%35 = load double, double* %8
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i8*, i8** %6
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8 45, i8* %42
br label %43
43: ; preds = %37, %34
%44 = load i8*, i8** %6
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
store i32 %46, i32* %10
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
store i8 49, i8* %48
%49 = load i8*, i8** %6
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
store i8 43, i8* %53
%54 = load i8*, i8** %6
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8, i8* %54, i64 %57
store i8 84, i8* %58
%59 = load i8*, i8** %6
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8, i8* %59, i64 %62
store i8 84, i8* %63
%64 = load i8*, i8** %6
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
store i8 47, i8* %68
br label %193
69: ; preds = %30
store i64 0, i64* %11
%70 = load double, double* %8
%71 = call double @llvm.fabs.f64(double %70)
%72 = call double @modf(double %71, double* %12)
store double %72, double* %13
%73 = load double, double* %12
%74 = fptosi double %73 to i32
store i32 %74, i32* %14
store i32 0, i32* %15
%75 = load double, double* %8
%76 = fcmp olt double %75, 0.000000e+00
br i1 %76, label %77, label %83
77: ; preds = %69
%78 = load i8*, i8** %6
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
store i8 45, i8* %82
br label %83
83: ; preds = %77, %69
%84 = load i32, i32* %14
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %92
86: ; preds = %83
%87 = load i8*, i8** %6
%88 = load i32, i32* %10
%89 = add nsw i32 %88, 1
store i32 %89, i32* %10
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
store i8 48, i8* %91
br label %127
92: ; preds = %83
br label %93
93: ; preds = %105, %92
%94 = load double, double* %13
%95 = fcmp oeq double %94, 0.000000e+00
br i1 %95, label %96, label %103
96: ; preds = %93
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %96
%100 = load i32, i32* %14
%101 = srem i32 %100, 30
%102 = icmp eq i32 %101, 0
br label %103
103: ; preds = %99, %96, %93
%104 = phi i1 [ false, %96 ], [ false, %93 ], [ %102, %99 ]
br i1 %104, label %105, label %110
105: ; preds = %103
%106 = load i32, i32* %14
%107 = sdiv i32 %106, 30
store i32 %107, i32* %14
%108 = load i32, i32* %15
%109 = add nsw i32 %108, 1
store i32 %109, i32* %15
br label %93
110: ; preds = %103
%111 = load i8*, i8** %6
%112 = load i32, i32* %10
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
%115 = load i64, i64* %7
%116 = load i32, i32* %10
%117 = sext i32 %116 to i64
%118 = sub i64 %115, %117
%119 = load i32, i32* %14
%120 = call i32 @por_write_base30_integer(i8* %114, i64 %118, i32 %119)
%121 = sext i32 %120 to i64
store i64 %121, i64* %11
%122 = load i64, i64* %11
%123 = load i32, i32* %10
%124 = sext i32 %123 to i64
%125 = add nsw i64 %124, %122
%126 = trunc i64 %125 to i32
store i32 %126, i32* %10
br label %127
127: ; preds = %110, %86
%128 = load double, double* %13
%129 = fcmp une double %128, 0.000000e+00
br i1 %129, label %130, label %136
130: ; preds = %127
%131 = load i8*, i8** %6
%132 = load i32, i32* %10
%133 = add nsw i32 %132, 1
store i32 %133, i32* %10
%134 = sext i32 %132 to i64
%135 = getelementptr inbounds i8, i8* %131, i64 %134
store i8 46, i8* %135
br label %136
136: ; preds = %130, %127
br label %137
137: ; preds = %163, %136
%138 = load double, double* %13
%139 = fcmp une double %138, 0.000000e+00
br i1 %139, label %140, label %144
140: ; preds = %137
%141 = load i64, i64* %11
%142 = load i64, i64* %9
%143 = icmp slt i64 %141, %142
br label %144
144: ; preds = %140, %137
%145 = phi i1 [ false, %137 ], [ %143, %140 ]
br i1 %145, label %146, label %166
146: ; preds = %144
%147 = load double, double* %13
%148 = fmul double %147, 3.000000e+01
%149 = call double @modf(double %148, double* %12)
store double %149, double* %13
%150 = load double, double* %12
%151 = fptosi double %150 to i32
store i32 %151, i32* %14
%152 = load i32, i32* %14
%153 = icmp slt i32 %152, 0
br i1 %153, label %154, label %155
154: ; preds = %146
store i32 -1, i32* %5
br label %200
155: ; preds = %146
%156 = load i32, i32* %14
%157 = call signext i8 @por_encode_base30_digit(i32 %156)
%158 = load i8*, i8** %6
%159 = load i32, i32* %10
%160 = add nsw i32 %159, 1
store i32 %160, i32* %10
%161 = sext i32 %159 to i64
%162 = getelementptr inbounds i8, i8* %158, i64 %161
store i8 %157, i8* %162
br label %163
163: ; preds = %155
%164 = load i64, i64* %11
%165 = add nsw i64 %164, 1
store i64 %165, i64* %11
br label %137
166: ; preds = %144
%167 = load i32, i32* %15
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %187
169: ; preds = %166
%170 = load i8*, i8** %6
%171 = load i32, i32* %10
%172 = add nsw i32 %171, 1
store i32 %172, i32* %10
%173 = sext i32 %171 to i64
%174 = getelementptr inbounds i8, i8* %170, i64 %173
store i8 43, i8* %174
%175 = load i8*, i8** %6
%176 = load i32, i32* %10
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
%179 = load i64, i64* %7
%180 = load i32, i32* %10
%181 = sext i32 %180 to i64
%182 = sub i64 %179, %181
%183 = load i32, i32* %15
%184 = call i32 @por_write_base30_integer(i8* %178, i64 %182, i32 %183)
%185 = load i32, i32* %10
%186 = add nsw i32 %185, %184
store i32 %186, i32* %10
br label %187
187: ; preds = %169, %166
%188 = load i8*, i8** %6
%189 = load i32, i32* %10
%190 = add nsw i32 %189, 1
store i32 %190, i32* %10
%191 = sext i32 %189 to i64
%192 = getelementptr inbounds i8, i8* %188, i64 %191
store i8 47, i8* %192
br label %193
193: ; preds = %187, %43
br label %194
194: ; preds = %193, %19
%195 = load i8*, i8** %6
%196 = load i32, i32* %10
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds i8, i8* %195, i64 %197
store i8 0, i8* %198
%199 = load i32, i32* %10
store i32 %199, i32* %5
br label %200
200: ; preds = %194, %154
%201 = load i32, i32* %5
ret i32 %201
}

LLVM IR (-O2):
define i32 @por_write_double_to_buffer(i8* %0, i64 %1, double %2, i64 %3) {
%5 = alloca double
%6 = tail call i64 @isnan(double %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
store i8 42, i8* %0
%9 = getelementptr inbounds i8, i8* %0, i64 1
store i8 46, i8* %9
br label %121
10: ; preds = %4
%11 = tail call i64 @isinf(double %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %33, label %13
13: ; preds = %10
%14 = fcmp olt double %2, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %13
store i8 45, i8* %0
br label %16
16: ; preds = %15, %13
%17 = phi i32 [ 1, %15 ], [ 0, %13 ]
%18 = add nuw nsw i32 %17, 1
%19 = zext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 49, i8* %20
%21 = or i32 %17, 2
%22 = zext i32 %18 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
store i8 43, i8* %23
%24 = add nuw nsw i32 %17, 3
%25 = zext i32 %21 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
store i8 84, i8* %26
%27 = or i32 %17, 4
%28 = zext i32 %24 to i64
%29 = getelementptr inbounds i8, i8* %0, i64 %28
store i8 84, i8* %29
%30 = add nuw nsw i32 %17, 5
%31 = zext i32 %27 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
store i8 47, i8* %32
br label %121
33: ; preds = %10
%34 = bitcast double* %5 to i8*
%35 = tail call double @llvm.fabs.f64(double %2)
%36 = call double @modf(double %35, double* %5)
%37 = load double, double* %5
%38 = fptosi double %37 to i32
%39 = fcmp olt double %2, 0.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %33
store i8 45, i8* %0
br label %41
41: ; preds = %40, %33
%42 = phi i32 [ 1, %40 ], [ 0, %33 ]
%43 = icmp eq i32 %38, 0
br i1 %43, label %49, label %44
44: ; preds = %41
%45 = fcmp oeq double %36, 0.000000e+00
%46 = srem i32 %38, 30
%47 = icmp eq i32 %46, 0
%48 = select i1 %45, i1 %47, i1 false
br i1 %48, label %53, label %63
49: ; preds = %41
%50 = add nuw nsw i32 %42, 1
%51 = zext i32 %42 to i64
%52 = getelementptr inbounds i8, i8* %0, i64 %51
store i8 48, i8* %52
br label %72
53: ; preds = %44, %53
%54 = phi i32 [ %57, %53 ], [ 0, %44 ]
%55 = phi i32 [ %56, %53 ], [ %38, %44 ]
%56 = sdiv i32 %55, 30
%57 = add nuw nsw i32 %54, 1
%58 = add i32 %55, -30
%59 = icmp ult i32 %58, -59
%60 = srem i32 %56, 30
%61 = icmp eq i32 %60, 0
%62 = select i1 %59, i1 %61, i1 false
br i1 %62, label %53, label %63
63: ; preds = %53, %44
%64 = phi i32 [ %38, %44 ], [ %56, %53 ]
%65 = phi i32 [ 0, %44 ], [ %57, %53 ]
%66 = zext i32 %42 to i64
%67 = getelementptr inbounds i8, i8* %0, i64 %66
%68 = sub i64 %1, %66
%69 = tail call i32 @por_write_base30_integer(i8* %67, i64 %68, i32 %64)
%70 = sext i32 %69 to i64
%71 = add i32 %69, %42
br label %72
72: ; preds = %63, %49
%73 = phi i32 [ %50, %49 ], [ %71, %63 ]
%74 = phi i64 [ 0, %49 ], [ %70, %63 ]
%75 = phi i32 [ 0, %49 ], [ %65, %63 ]
%76 = fcmp une double %36, 0.000000e+00
br i1 %76, label %77, label %104
77: ; preds = %72
%78 = add nsw i32 %73, 1
%79 = sext i32 %73 to i64
%80 = getelementptr inbounds i8, i8* %0, i64 %79
store i8 46, i8* %80
%81 = icmp slt i64 %74, %3
br i1 %81, label %82, label %104
82: ; preds = %77
%83 = sext i32 %78 to i64
br label %84
84: ; preds = %82, %94
%85 = phi i64 [ %83, %82 ], [ %96, %94 ]
%86 = phi double [ %36, %82 ], [ %89, %94 ]
%87 = phi i64 [ %74, %82 ], [ %98, %94 ]
%88 = fmul double %86, 3.000000e+01
%89 = call double @modf(double %88, double* %5)
%90 = load double, double* %5
%91 = fptosi double %90 to i32
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %84
br label %125
94: ; preds = %84
%95 = tail call signext i8 @por_encode_base30_digit(i32 %91)
%96 = add i64 %85, 1
%97 = getelementptr inbounds i8, i8* %0, i64 %85
store i8 %95, i8* %97
%98 = add nsw i64 %87, 1
%99 = fcmp une double %89, 0.000000e+00
%100 = icmp slt i64 %98, %3
%101 = select i1 %99, i1 %100, i1 false
br i1 %101, label %84, label %102
102: ; preds = %94
%103 = trunc i64 %96 to i32
br label %104
104: ; preds = %72, %102, %77
%105 = phi i32 [ %78, %77 ], [ %103, %102 ], [ %73, %72 ]
%106 = icmp eq i32 %75, 0
br i1 %106, label %116, label %107
107: ; preds = %104
%108 = add nsw i32 %105, 1
%109 = sext i32 %105 to i64
%110 = getelementptr inbounds i8, i8* %0, i64 %109
store i8 43, i8* %110
%111 = sext i32 %108 to i64
%112 = getelementptr inbounds i8, i8* %0, i64 %111
%113 = sub i64 %1, %111
%114 = tail call i32 @por_write_base30_integer(i8* %112, i64 %113, i32 %75)
%115 = add nsw i32 %114, %108
br label %116
116: ; preds = %104, %107
%117 = phi i32 [ %115, %107 ], [ %105, %104 ]
%118 = add nsw i32 %117, 1
%119 = sext i32 %117 to i64
%120 = getelementptr inbounds i8, i8* %0, i64 %119
store i8 47, i8* %120
br label %121
121: ; preds = %116, %16, %8
%122 = phi i32 [ 2, %8 ], [ %30, %16 ], [ %118, %116 ]
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %0, i64 %123
store i8 0, i8* %124
br label %125
125: ; preds = %93, %121
%126 = phi i32 [ %122, %121 ], [ -1, %93 ]
ret i32 %126
}