#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 scalar_t__ uint8_t;
typedef int uint16_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ ui8ToA(int, char *, int);
char *s8p8ToA(int16_t number, char *buffer) {
  char tmp[3];
  if (number < 0) {
    buffer[0] = '-';
    number = -number;
  } else
    buffer[0] = '+';
  ui8ToA((number / 256), tmp, 3);
  buffer[1] = tmp[0];
  buffer[2] = tmp[1];
  buffer[3] = tmp[2];
  buffer[4] = '.';
  ui8ToA((((uint16_t)((uint8_t)(number)) * 100) / 256), tmp, 2);
  buffer[5] = tmp[0];
  buffer[6] = tmp[1];
  buffer[7] = 0;
  return buffer;
}


x86 assembly (clang, -O0):
<s8p8ToA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    113d <s8p8ToA+0x2d>
mov    -0x10(%rbp),%rax
movb   $0x2d,(%rax)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1144 <s8p8ToA+0x34>
mov    -0x10(%rbp),%rax
movb   $0x2b,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
lea    -0x13(%rbp),%rsi
mov    $0x3,%edx
call   1030 <ui8ToA@plt>
mov    -0x13(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x12(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x10(%rbp),%rax
movb   $0x2e,0x4(%rax)
movslq -0x4(%rbp),%rax
imul   $0x64,%eax,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
lea    -0x13(%rbp),%rsi
mov    $0x2,%edx
call   1030 <ui8ToA@plt>
mov    -0x13(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x12(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x7(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s8p8ToA>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
js     1126 <s8p8ToA+0x16>
movb   $0x2b,(%rbx)
jmp    112b <s8p8ToA+0x1b>
movb   $0x2d,(%rbx)
neg    %ebp
mov    %ebp,%edi
shr    $0x8,%edi
lea    0xd(%rsp),%r14
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <ui8ToA@plt>
mov    0xd(%rsp),%al
mov    %al,0x1(%rbx)
mov    0xe(%rsp),%al
mov    %al,0x2(%rbx)
mov    0xf(%rsp),%al
mov    %al,0x3(%rbx)
movb   $0x2e,0x4(%rbx)
imul   $0x64,%ebp,%eax
lea    0xff(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x8,%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <ui8ToA@plt>
mov    0xd(%rsp),%al
mov    %al,0x5(%rbx)
mov    0xe(%rsp),%al
mov    %al,0x6(%rbx)
movb   $0x0,0x7(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @s8p8ToA(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [3 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 45, i8* %10
%11 = load i32, i32* %3
%12 = sub nsw i32 0, %11
store i32 %12, i32* %3
br label %16
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 43, i8* %15
br label %16
16: ; preds = %13, %8
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 256
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%20 = call i32 @ui8ToA(i32 %18, i8* %19, i32 3)
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 %22, i8* %24
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%26 = load i8, i8* %25
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%30 = load i8, i8* %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 3
store i8 %30, i8* %32
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 4
store i8 46, i8* %34
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = trunc i64 %36 to i32
%38 = mul nsw i32 %37, 100
%39 = sdiv i32 %38, 256
%40 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%41 = call i32 @ui8ToA(i32 %39, i8* %40, i32 2)
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%43 = load i8, i8* %42
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 5
store i8 %43, i8* %45
%46 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%47 = load i8, i8* %46
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 6
store i8 %47, i8* %49
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 7
store i8 0, i8* %51
%52 = load i8*, i8** %4
ret i8* %52
}

LLVM IR (-O2):
define i8* @s8p8ToA(i32 %0, i8* returned writeonly %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %2
store i8 45, i8* %1
%7 = sub nsw i32 0, %0
br label %9
8: ; preds = %2
store i8 43, i8* %1
br label %9
9: ; preds = %8, %6
%10 = phi i32 [ %7, %6 ], [ %0, %8 ]
%11 = lshr i32 %10, 8
%12 = call i32 @ui8ToA(i32 %11, i8* %4, i32 3)
%13 = load i8, i8* %4
%14 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %13, i8* %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %16, i8* %17
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %19, i8* %20
%21 = getelementptr inbounds i8, i8* %1, i64 4
store i8 46, i8* %21
%22 = mul nsw i32 %10, 100
%23 = sdiv i32 %22, 256
%24 = call i32 @ui8ToA(i32 %23, i8* %4, i32 2)
%25 = load i8, i8* %4
%26 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %25, i8* %26
%27 = load i8, i8* %15
%28 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %27, i8* %28
%29 = getelementptr inbounds i8, i8* %1, i64 7
store i8 0, i8* %29
ret i8* %1
}