#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 */
struct membuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ put_format(struct membuffer *, char *, char const *,
                              char const *, unsigned int, char *, char const *);
void put_milli(struct membuffer *b, const char *pre, int value,
               const char *post) {
  int i;
  char buf[4];
  const char *sign = "";
  unsigned v;
  v = value;
  if (value < 0) {
    sign = "-";
    v = -value;
  }
  for (i = 2; i >= 0; i--) {
    buf[i] = (v % 10) + '0';
    v /= 10;
  }
  buf[3] = 0;
  if (buf[2] == '0') {
    buf[2] = 0;
    if (buf[1] == '0')
      buf[1] = 0;
  }
  put_format(b, "%s%s%u.%s%s", pre, sign, v, buf, post);
}


x86 assembly (clang, -O0):
<put_milli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1155 <put_milli+0x45>
lea    0xeb7(%rip),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x2,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     119c <put_milli+0x8c>
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x28(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <put_milli+0x4c>
movb   $0x0,-0x25(%rbp)
movsbl -0x26(%rbp),%eax
cmp    $0x30,%eax
jne    11c7 <put_milli+0xb7>
movb   $0x0,-0x26(%rbp)
movsbl -0x27(%rbp),%eax
cmp    $0x30,%eax
jne    11c2 <put_milli+0xb2>
movb   $0x0,-0x27(%rbp)
jmp    11c7 <put_milli+0xb7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
lea    -0x28(%rbp),%r9
mov    -0x20(%rbp),%rax
lea    0xe1c(%rip),%rsi
mov    %rax,(%rsp)
call   1030 <put_format@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_milli>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r9d
mov    %rsi,%rdx
mov    %r9d,%r8d
neg    %r8d
cmovs  %r9d,%r8d
mov    $0xcccccccd,%r10d
mov    %r8,%rbx
imul   %r10,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%r11d
mov    %r8d,%ebp
sub    %r11d,%ebp
or     $0x30,%bpl
mov    %bpl,0x16(%rsp)
mov    %rbx,%rsi
imul   %r10,%rsi
shr    $0x23,%rsi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%ebx
or     $0x30,%bl
mov    %bl,0x15(%rsp)
imul   $0x51eb851f,%r8,%rax
shr    $0x25,%rax
mov    %rax,%rsi
imul   %r10,%rsi
shr    $0x23,%rsi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%eax
or     $0x30,%al
mov    %al,0x14(%rsp)
movb   $0x0,0x17(%rsp)
cmp    $0x30,%bpl
jne    11a3 <put_milli+0x93>
movb   $0x0,0x16(%rsp)
cmp    $0x30,%bl
jne    11a3 <put_milli+0x93>
movb   $0x0,0x15(%rsp)
mov    %r8d,%eax
imul   $0x10624dd3,%rax,%r8
shr    $0x26,%r8
test   %r9d,%r9d
lea    0xe45(%rip),%rsi
lea    0xe3f(%rip),%rax
cmovs  %rsi,%rax
mov    %rcx,(%rsp)
lea    0xe31(%rip),%rsi
lea    0x14(%rsp),%r9
mov    %rax,%rcx
call   1030 <put_format@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.membuffer = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [12 x i8] c"%s%s%u.%s%s\00"
define void @put_milli(%struct.membuffer* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca %struct.membuffer*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [4 x i8]
%11 = alloca i8*
%12 = alloca i32
store %struct.membuffer* %0, %struct.membuffer** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %11
%13 = load i32, i32* %7
store i32 %13, i32* %12
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %11
%17 = load i32, i32* %7
%18 = sub nsw i32 0, %17
store i32 %18, i32* %12
br label %19
19: ; preds = %16, %4
store i32 2, i32* %9
br label %20
20: ; preds = %33, %19
%21 = load i32, i32* %9
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %20
%24 = load i32, i32* %12
%25 = urem i32 %24, 10
%26 = add i32 %25, 48
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 %29
store i8 %27, i8* %30
%31 = load i32, i32* %12
%32 = udiv i32 %31, 10
store i32 %32, i32* %12
br label %33
33: ; preds = %23
%34 = load i32, i32* %9
%35 = add nsw i32 %34, -1
store i32 %35, i32* %9
br label %20
36: ; preds = %20
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 3
store i8 0, i8* %37
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 2
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 48
br i1 %41, label %42, label %51
42: ; preds = %36
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 2
store i8 0, i8* %43
%44 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 48
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
store i8 0, i8* %49
br label %50
50: ; preds = %48, %42
br label %51
51: ; preds = %50, %36
%52 = load %struct.membuffer*, %struct.membuffer** %5
%53 = load i8*, i8** %6
%54 = load i8*, i8** %11
%55 = load i32, i32* %12
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%57 = load i8*, i8** %8
%58 = call i32 @put_format(%struct.membuffer* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* %54, i32 %55, i8* %56, i8* %57)
ret void
}

LLVM IR (-O2):
%struct.membuffer = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [12 x i8] c"%s%s%u.%s%s\00"
define void @put_milli(%struct.membuffer* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [4 x i8]
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%7 = icmp slt i32 %2, 0
%8 = sub nsw i32 0, %2
%9 = select i1 %7, i32 %8, i32 %2
%10 = urem i32 %9, 10
%11 = trunc i32 %10 to i8
%12 = or i8 %11, 48
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %12, i8* %13
%14 = udiv i32 %9, 10
%15 = urem i32 %14, 10
%16 = trunc i32 %15 to i8
%17 = or i8 %16, 48
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %17, i8* %18
%19 = udiv i32 %9, 100
%20 = urem i32 %19, 10
%21 = trunc i32 %20 to i8
%22 = or i8 %21, 48
store i8 %22, i8* %6
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 0, i8* %23
%24 = icmp eq i8 %12, 48
br i1 %24, label %25, label %28
25: ; preds = %4
store i8 0, i8* %13
%26 = icmp eq i8 %17, 48
br i1 %26, label %27, label %28
27: ; preds = %25
store i8 0, i8* %18
br label %28
28: ; preds = %25, %27, %4
%29 = udiv i32 %9, 1000
%30 = select i1 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%31 = call i32 @put_format(%struct.membuffer* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %30, i32 %29, i8* %6, i8* %3)
ret void
}