#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 */
int strlen(char *);
void trim_zeros_after_decimal(char *src) {
  char *end = src + strlen(src) - 1;
  while (end != src) {
    if (*end == '0')
      *end = 0;
    else if (*end == '.') {
      *end = 0;
      break;
    } else
      break;
    end--;
  }
}


x86 assembly (clang, -O0):
<trim_zeros_after_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     119d <trim_zeros_after_decimal+0x8d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    116b <trim_zeros_after_decimal+0x5b>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    118c <trim_zeros_after_decimal+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1187 <trim_zeros_after_decimal+0x77>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    119d <trim_zeros_after_decimal+0x8d>
jmp    119d <trim_zeros_after_decimal+0x8d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1141 <trim_zeros_after_decimal+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_zeros_after_decimal>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rbx,%rcx
je     1143 <trim_zeros_after_decimal+0x33>
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax)
movzbl (%rbx,%rax,1),%ecx
cmp    $0x30,%cl
jne    1145 <trim_zeros_after_decimal+0x35>
movb   $0x0,(%rbx,%rax,1)
add    $0xffffffffffffffff,%rax
jne    1130 <trim_zeros_after_decimal+0x20>
pop    %rbx
ret
cmp    $0x2e,%cl
jne    1143 <trim_zeros_after_decimal+0x33>
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @trim_zeros_after_decimal(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -1
store i8* %9, i8** %3
br label %10
10: ; preds = %29, %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = icmp ne i8* %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 48
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i8*, i8** %3
store i8 0, i8* %20
br label %29
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 46
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i8*, i8** %3
store i8 0, i8* %27
br label %32
28: ; preds = %21
br label %32
29: ; preds = %19
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %3
br label %10
32: ; preds = %28, %26, %10
ret void
}

LLVM IR (-O2):
define void @trim_zeros_after_decimal(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = icmp eq i8* %5, %0
br i1 %6, label %14, label %7
7: ; preds = %1, %10
%8 = phi i8* [ %11, %10 ], [ %5, %1 ]
%9 = load i8, i8* %8
switch i8 %9, label %14 [
i8 48, label %10
i8 46, label %13
]
10: ; preds = %7
store i8 0, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 -1
%12 = icmp eq i8* %11, %0
br i1 %12, label %14, label %7
13: ; preds = %7
store i8 0, i8* %8
br label %14
14: ; preds = %10, %7, %1, %13
ret void
}