#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 int64_t;

/* Variables and functions */
int /*<<< orphan*/ write_str(char *);
void write_sfix9(int64_t v) {
  char s[20], *s1, *s2, c;
  int i;
  s1 = s;
  if (v < 0) {
    *s1++ = '-';
    v = -v;
  }
  s2 = s1;
  i = 9;
  while (--i >= 0) {
    *s2++ = (v % 10) + '0';
    v /= 10;
  }
  *s2++ = '.';
  do {
    *s2++ = (v % 10) + '0';
    v /= 10;
  } while (v > 0);
  *s2-- = 0;
  while (s2 > s1) {
    c = *s1;
    *s1 = *s2;
    *s2 = c;
    s1++;
    s2--;
  }
  write_str(s);
}


x86 assembly (clang, -O0):
<write_sfix9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1147 <write_sfix9+0x37>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x2d,(%rax)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x9,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jl     119c <write_sfix9+0x8c>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1156 <write_sfix9+0x46>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2e,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     11ae <write_sfix9+0x9e>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    1242 <write_sfix9+0x132>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x31(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x31(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11f9 <write_sfix9+0xe9>
lea    -0x20(%rbp),%rdi
call   1030 <write_str@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_sfix9>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
js     1123 <write_sfix9+0x13>
mov    %rsp,%r11
jmp    112e <write_sfix9+0x1e>
lea    0x1(%rsp),%r11
movb   $0x2d,(%rsp)
neg    %edi
mov    %edi,%r9d
mov    $0xcccccccd,%r8d
imul   $0x51eb851f,%r9,%r10
imul   $0x10624dd3,%r9,%r14
mov    $0xd1b71759,%r15d
imul   %r9,%r15
imul   $0x431bde83,%r9,%rsi
imul   $0x6b5fca6b,%r9,%rax
imul   $0x55e63b89,%r9,%rbx
imul   %r8,%r9
shr    $0x23,%r9
lea    (%r9,%r9,1),%ecx
lea    (%rcx,%rcx,4),%ebp
mov    %edi,%ecx
sub    %ebp,%ecx
mov    %r9,%rbp
imul   %r8,%rbp
shr    $0x23,%rbp
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
sub    %ebp,%r9d
or     $0x30,%r9b
mov    %r9b,0x1(%r11)
shr    $0x25,%r10
mov    %r10,%rbp
imul   %r8,%rbp
shr    $0x23,%rbp
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
sub    %ebp,%r10d
or     $0x30,%r10b
mov    %r10b,0x2(%r11)
shr    $0x26,%r14
mov    %r14,%rbp
imul   %r8,%rbp
shr    $0x23,%rbp
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
sub    %ebp,%r14d
or     $0x30,%r14b
mov    %r14b,0x3(%r11)
shr    $0x2d,%r15
mov    %r15,%rdx
imul   %r8,%rdx
or     $0x30,%cl
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%r15d
or     $0x30,%r15b
mov    %r15b,0x4(%r11)
mov    %edi,%edx
shr    $0x5,%edx
imul   $0xa7c5ac5,%rdx,%rbp
shr    $0x27,%rbp
imul   $0xcccd,%ebp,%edx
shr    $0x12,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ebp
lea    0x2(%r11),%rdx
or     $0x30,%bpl
mov    %bpl,0x5(%r11)
shr    $0x32,%rsi
imul   $0xcccd,%esi,%ebp
shr    $0x12,%ebp
and    $0xfffffffe,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
sub    %ebp,%esi
or     $0x30,%sil
mov    %sil,0x6(%r11)
shr    $0x36,%rax
movzbl %al,%esi
imul   $0xcd,%esi,%esi
shr    $0xa,%esi
and    $0xfffffffe,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%al
or     $0x30,%al
mov    %al,0x7(%r11)
shr    $0x39,%rbx
imul   $0xcd,%ebx,%eax
shr    $0xa,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%eax
sub    %al,%bl
or     $0x30,%bl
lea    0x9(%r11),%rax
mov    %bl,0x8(%r11)
shr    $0x9,%edi
imul   $0x44b83,%rdi,%rsi
shr    $0x27,%rsi
movb   $0x2e,0x9(%r11)
or     $0x30,%sil
movb   $0x0,0xb(%r11)
mov    %sil,(%r11)
mov    %cl,0xa(%r11)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rax),%ecx
movzbl -0x1(%rdx),%ebx
mov    %cl,-0x1(%rdx)
mov    %bl,(%rax)
add    $0xffffffffffffffff,%rax
lea    0x1(%rdx),%rcx
cmp    %rdx,%rax
mov    %rcx,%rdx
ja     12b0 <write_sfix9+0x1a0>
mov    %rsp,%rdi
call   1030 <write_str@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @write_sfix9(i32 %0) {
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %2
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
store i8* %8, i8** %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
store i8 45, i8* %12
%14 = load i32, i32* %2
%15 = sub nsw i32 0, %14
store i32 %15, i32* %2
br label %16
16: ; preds = %11, %1
%17 = load i8*, i8** %4
store i8* %17, i8** %5
store i32 9, i32* %7
br label %18
18: ; preds = %22, %16
%19 = load i32, i32* %7
%20 = add nsw i32 %19, -1
store i32 %20, i32* %7
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %2
%24 = srem i32 %23, 10
%25 = add nsw i32 %24, 48
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
store i8 %26, i8* %27
%29 = load i32, i32* %2
%30 = sdiv i32 %29, 10
store i32 %30, i32* %2
br label %18
31: ; preds = %18
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
store i8 46, i8* %32
br label %34
34: ; preds = %43, %31
%35 = load i32, i32* %2
%36 = srem i32 %35, 10
%37 = add nsw i32 %36, 48
%38 = trunc i32 %37 to i8
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
store i8 %38, i8* %39
%41 = load i32, i32* %2
%42 = sdiv i32 %41, 10
store i32 %42, i32* %2
br label %43
43: ; preds = %34
%44 = load i32, i32* %2
%45 = icmp sgt i32 %44, 0
br i1 %45, label %34, label %46
46: ; preds = %43
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i32 -1
store i8* %48, i8** %5
store i8 0, i8* %47
br label %49
49: ; preds = %53, %46
%50 = load i8*, i8** %5
%51 = load i8*, i8** %4
%52 = icmp ugt i8* %50, %51
br i1 %52, label %53, label %65
53: ; preds = %49
%54 = load i8*, i8** %4
%55 = load i8, i8* %54
store i8 %55, i8* %6
%56 = load i8*, i8** %5
%57 = load i8, i8* %56
%58 = load i8*, i8** %4
store i8 %57, i8* %58
%59 = load i8, i8* %6
%60 = load i8*, i8** %5
store i8 %59, i8* %60
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %4
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i32 -1
store i8* %64, i8** %5
br label %49
65: ; preds = %49
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%67 = call i32 @write_str(i8* %66)
ret void
}

LLVM IR (-O2):
define void @write_sfix9(i32 %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 1
store i8 45, i8* %3
%7 = sub nsw i32 0, %0
br label %8
8: ; preds = %5, %1
%9 = phi i8* [ %6, %5 ], [ %3, %1 ]
%10 = phi i32 [ %7, %5 ], [ %0, %1 ]
%11 = urem i32 %10, 10
%12 = trunc i32 %11 to i8
%13 = or i8 %12, 48
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %13, i8* %9
%15 = udiv i32 %10, 10
%16 = urem i32 %15, 10
%17 = trunc i32 %16 to i8
%18 = or i8 %17, 48
%19 = getelementptr inbounds i8, i8* %9, i64 2
store i8 %18, i8* %14
%20 = udiv i32 %10, 100
%21 = urem i32 %20, 10
%22 = trunc i32 %21 to i8
%23 = or i8 %22, 48
%24 = getelementptr inbounds i8, i8* %9, i64 3
store i8 %23, i8* %19
%25 = udiv i32 %10, 1000
%26 = urem i32 %25, 10
%27 = trunc i32 %26 to i8
%28 = or i8 %27, 48
%29 = getelementptr inbounds i8, i8* %9, i64 4
store i8 %28, i8* %24
%30 = udiv i32 %10, 10000
%31 = urem i32 %30, 10
%32 = trunc i32 %31 to i8
%33 = or i8 %32, 48
%34 = getelementptr inbounds i8, i8* %9, i64 5
store i8 %33, i8* %29
%35 = udiv i32 %10, 100000
%36 = trunc i32 %35 to i16
%37 = urem i16 %36, 10
%38 = trunc i16 %37 to i8
%39 = or i8 %38, 48
%40 = getelementptr inbounds i8, i8* %9, i64 6
store i8 %39, i8* %34
%41 = udiv i32 %10, 1000000
%42 = trunc i32 %41 to i16
%43 = urem i16 %42, 10
%44 = trunc i16 %43 to i8
%45 = or i8 %44, 48
%46 = getelementptr inbounds i8, i8* %9, i64 7
store i8 %45, i8* %40
%47 = udiv i32 %10, 10000000
%48 = trunc i32 %47 to i8
%49 = urem i8 %48, 10
%50 = or i8 %49, 48
%51 = getelementptr inbounds i8, i8* %9, i64 8
store i8 %50, i8* %46
%52 = udiv i32 %10, 100000000
%53 = trunc i32 %52 to i8
%54 = urem i8 %53, 10
%55 = or i8 %54, 48
%56 = getelementptr inbounds i8, i8* %9, i64 9
store i8 %55, i8* %51
%57 = udiv i32 %10, 1000000000
%58 = getelementptr inbounds i8, i8* %9, i64 10
store i8 46, i8* %56
%59 = trunc i32 %57 to i8
%60 = or i8 %59, 48
%61 = getelementptr inbounds i8, i8* %9, i64 11
store i8 %60, i8* %58
store i8 0, i8* %61
%62 = load i8, i8* %9
store i8 %60, i8* %9
store i8 %62, i8* %58
%63 = getelementptr inbounds i8, i8* %9, i64 1
%64 = getelementptr inbounds i8, i8* %9, i64 9
br label %65
65: ; preds = %8, %65
%66 = phi i8* [ %64, %8 ], [ %71, %65 ]
%67 = phi i8* [ %63, %8 ], [ %70, %65 ]
%68 = load i8, i8* %66
%69 = load i8, i8* %67
store i8 %68, i8* %67
store i8 %69, i8* %66
%70 = getelementptr inbounds i8, i8* %67, i64 1
%71 = getelementptr inbounds i8, i8* %66, i64 -1
%72 = icmp ugt i8* %71, %70
br i1 %72, label %65, label %73
73: ; preds = %65
%74 = call i32 @write_str(i8* %3)
ret void
}