#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 *ecvt(double, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  double d = 12.2223;
  int decpt, sign;
  char *rs = ecvt(d, 10, &decpt, &sign);
  if (rs) {
    printf("%s\n", rs);
    printf("%d\n", decpt);
    printf("%d\n", sign);
  }
  rs = ecvt(110.01, 5, &decpt, &sign);
  printf("%s\n", rs);
  printf("%d\n", decpt);
  printf("%d\n", sign);
  rs = ecvt(-1111.01, 5, &decpt, &sign);
  printf("%s\n", rs);
  printf("%d\n", decpt);
  printf("%d\n", sign);
  rs = ecvt(0.01, 5, &decpt, &sign);
  printf("%s\n", rs);
  printf("%d\n", decpt);
  printf("%d\n", sign);
  rs = ecvt(0.0, 2, &decpt, &sign);
  printf("%s\n", rs);
  printf("%d\n", decpt);
  printf("%d\n", sign);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0xa,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <ecvt@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1196 <main+0x76>
mov    -0x20(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xe7a(%rip),%xmm0
mov    $0x5,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <ecvt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xe20(%rip),%xmm0
mov    $0x5,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <ecvt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xdc6(%rip),%xmm0
mov    $0x5,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <ecvt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <ecvt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  0xebf(%rip),%xmm0
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    $0xa,%edi
call   1040 <ecvt@plt>
test   %rax,%rax
je     1185 <main+0x55>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
lea    0xeb3(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xe7b(%rip),%xmm0
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    $0x5,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <ecvt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xe36(%rip),%xmm0
mov    $0x5,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <ecvt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xe02(%rip),%xmm0
mov    $0x5,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <ecvt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <ecvt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store double 1.222230e+01, double* %2
%6 = load double, double* %2
%7 = call i8* @ecvt(double %6, i32 10, i32* %3, i32* %4)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %0
%11 = load i8*, i8** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %10, %0
%18 = call i8* @ecvt(double 1.100100e+02, i32 5, i32* %3, i32* %4)
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = call i8* @ecvt(double -1.111010e+03, i32 5, i32* %3, i32* %4)
store i8* %25, i8** %5
%26 = load i8*, i8** %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = call i8* @ecvt(double 1.000000e-02, i32 5, i32* %3, i32* %4)
store i8* %32, i8** %5
%33 = load i8*, i8** %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = call i8* @ecvt(double 0.000000e+00, i32 2, i32* %3, i32* %4)
store i8* %39, i8** %5
%40 = load i8*, i8** %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i8* @ecvt(double 1.222230e+01, i32 10, i32* %1, i32* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* %5)
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %7, %0
%14 = call i8* @ecvt(double 1.100100e+02, i32 5, i32* %1, i32* %2)
%15 = call i32 @puts(i8* dereferenceable(1) %14)
%16 = load i32, i32* %1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i8* @ecvt(double -1.111010e+03, i32 5, i32* %1, i32* %2)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
%22 = load i32, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i8* @ecvt(double 1.000000e-02, i32 5, i32* %1, i32* %2)
%27 = call i32 @puts(i8* dereferenceable(1) %26)
%28 = load i32, i32* %1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = call i8* @ecvt(double 0.000000e+00, i32 2, i32* %1, i32* %2)
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = load i32, i32* %1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
ret i32 0
}