#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 ell_v {
  int dummy;
};

/* Variables and functions */
char *ell_format(char *, double);
struct ell_v *ell_string(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strchr(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
struct ell_v *ell_number(double n) {
  char *s;
  if (!(s = ell_format("%f", n)))
    return NULL;
  char *p = strchr(s, 0);
  while (--p > s && *p == '0')
    *p = 0;
  if (*p == '.')
    *p = 0;
  struct ell_v *v = ell_string(s, strlen(s));
  free(s);
  return v;
}


x86 assembly (clang, -O0):
<ell_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe97(%rip),%rdi
call   1060 <ell_format@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1189 <ell_number+0x39>
movq   $0x0,-0x8(%rbp)
jmp    1227 <ell_number+0xd7>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x29(%rbp)
jbe    11c3 <ell_number+0x73>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11d3 <ell_number+0x83>
jmp    11df <ell_number+0x8f>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1198 <ell_number+0x48>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11f6 <ell_number+0xa6>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1070 <ell_string@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ell_number>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1050 <ell_format@plt>
test   %rax,%rax
je     11b3 <ell_number+0x73>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jbe    1187 <ell_number+0x47>
nopl   0x0(%rax)
movzbl (%rax),%ecx
cmp    $0x30,%cl
jne    1189 <ell_number+0x49>
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
ja     1170 <ell_number+0x30>
mov    %rbx,%rax
mov    (%rax),%cl
cmp    $0x2e,%cl
jne    1191 <ell_number+0x51>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <ell_string@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
jmp    11b5 <ell_number+0x75>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ell_v = type { i32 }
@.str = [3 x i8] c"%f\00"
define %struct.ell_v* @ell_number(double %0) {
%2 = alloca %struct.ell_v*
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.ell_v*
store double %0, double* %3
%7 = load double, double* %3
%8 = call i8* @ell_format(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %7)
store i8* %8, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store %struct.ell_v* null, %struct.ell_v** %2
br label %43
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i8* @strchr(i8* %12, i32 0)
store i8* %13, i8** %5
br label %14
14: ; preds = %26, %11
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 -1
store i8* %16, i8** %5
%17 = load i8*, i8** %4
%18 = icmp ugt i8* %16, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 48
br label %24
24: ; preds = %19, %14
%25 = phi i1 [ false, %14 ], [ %23, %19 ]
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = load i8*, i8** %5
store i8 0, i8* %27
br label %14
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 46
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load i8*, i8** %5
store i8 0, i8* %34
br label %35
35: ; preds = %33, %28
%36 = load i8*, i8** %4
%37 = load i8*, i8** %4
%38 = call i32 @strlen(i8* %37)
%39 = call %struct.ell_v* @ell_string(i8* %36, i32 %38)
store %struct.ell_v* %39, %struct.ell_v** %6
%40 = load i8*, i8** %4
%41 = call i32 @free(i8* %40)
%42 = load %struct.ell_v*, %struct.ell_v** %6
store %struct.ell_v* %42, %struct.ell_v** %2
br label %43
43: ; preds = %35, %10
%44 = load %struct.ell_v*, %struct.ell_v** %2
ret %struct.ell_v* %44
}

LLVM IR (-O2):
%struct.ell_v = type { i32 }
@.str = [3 x i8] c"%f\00"
define %struct.ell_v* @ell_number(double %0) {
%2 = tail call i8* @ell_format(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %28, label %4
4: ; preds = %1
%5 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %2)
%6 = getelementptr i8, i8* %2, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = icmp ugt i8* %7, %2
br i1 %8, label %9, label %16
9: ; preds = %4, %13
%10 = phi i8* [ %14, %13 ], [ %7, %4 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 48
br i1 %12, label %13, label %19
13: ; preds = %9
store i8 0, i8* %10
%14 = getelementptr inbounds i8, i8* %10, i64 -1
%15 = icmp ugt i8* %14, %2
br i1 %15, label %9, label %16
16: ; preds = %13, %4
%17 = phi i8* [ %7, %4 ], [ %2, %13 ]
%18 = load i8, i8* %17
br label %19
19: ; preds = %9, %16
%20 = phi i8* [ %17, %16 ], [ %10, %9 ]
%21 = phi i8 [ %18, %16 ], [ %11, %9 ]
%22 = icmp eq i8 %21, 46
br i1 %22, label %23, label %24
23: ; preds = %19
store i8 0, i8* %20
br label %24
24: ; preds = %23, %19
%25 = tail call i32 @strlen(i8* %2)
%26 = tail call %struct.ell_v* @ell_string(i8* %2, i32 %25)
%27 = tail call i32 @free(i8* %2)
br label %28
28: ; preds = %1, %24
%29 = phi %struct.ell_v* [ %26, %24 ], [ null, %1 ]
ret %struct.ell_v* %29
}