#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 */
double fabs(int /*<<< orphan*/);
int /*<<< orphan*/ modf(double, double *);
int /*<<< orphan*/ sprintf(char *, char *, double);
int strlen(char *);
const char *M_Ftrim(double f) {
  static char dig[9];
  int i;
  sprintf(dig, "%.6f", fabs(modf(f, &f)));
  for (i = strlen(dig) - 1; dig[i] == '0'; --i)
    ;
  if (dig[i] == '.')
    return "";
  else {
    dig[i + 1] = '\0';
    return &dig[1];
  }
}


x86 assembly (clang, -O0):
<M_Ftrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1040 <modf@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
lea    0x2ed8(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1060 <sprintf@plt>
lea    0x2ec5(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2eaf(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    11b2 <M_Ftrim+0x72>
jmp    11a4 <M_Ftrim+0x64>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <M_Ftrim+0x47>
movslq -0x14(%rbp),%rcx
lea    0x2e84(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11da <M_Ftrim+0x9a>
lea    0xe33(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <M_Ftrim+0xbd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e57(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e4c(%rip),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<M_Ftrim>:
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %rsp,%rdi
call   1040 <modf@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
lea    0x2ee2(%rip),%r14
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdx
lea    (%rdx,%r14,1),%rcx
add    $0xffffffffffffffff,%rcx
shl    $0x20,%rdx
movabs $0x100000000,%rax
add    %rdx,%rax
movabs $0xffffffff00000000,%rdx
ff ff ff
nopl   0x0(%rax)
add    %rdx,%rax
movzbl (%rcx),%ebx
add    $0xffffffffffffffff,%rcx
cmp    $0x30,%bl
je     11a0 <M_Ftrim+0x60>
cmp    $0x2e,%bl
jne    11bd <M_Ftrim+0x7d>
lea    0xe49(%rip),%rax
jmp    11cd <M_Ftrim+0x8d>
sar    $0x20,%rax
movb   $0x0,(%rax,%r14,1)
lea    0x2e75(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_Ftrim.dig = internal global [9 x i8] zeroinitializer
@.str = [5 x i8] c"%.6f\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @M_Ftrim(double %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = call i32 @modf(double %5, double* %3)
%7 = call double @fabs(i32 %6)
%8 = call i32 @sprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 0))
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %4
br label %11
11: ; preds = %19, %1
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 48
br i1 %17, label %18, label %22
18: ; preds = %11
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, -1
store i32 %21, i32* %4
br label %11
22: ; preds = %11
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 46
br i1 %28, label %29, label %30
29: ; preds = %22
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %35
30: ; preds = %22
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 %33
store i8 0, i8* %34
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 1), i8** %2
br label %35
35: ; preds = %30, %29
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@M_Ftrim.dig = internal global [9 x i8] zeroinitializer
@.str = [5 x i8] c"%.6f\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @M_Ftrim(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = call i32 @modf(double %0, double* %2)
%4 = tail call double @fabs(i32 %3)
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 0))
%7 = sext i32 %6 to i64
br label %8
8: ; preds = %8, %1
%9 = phi i64 [ %10, %8 ], [ %7, %1 ]
%10 = add i64 %9, -1
%11 = getelementptr inbounds [9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 48, label %8
i8 46, label %17
]
13: ; preds = %8
%14 = shl i64 %9, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds [9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %8, %13
%18 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @M_Ftrim.dig, i64 0, i64 1), %13 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %8 ]
ret i8* %18
}