#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 *);
int tools_str_ch_index_first(char *, char);
int tools_exp_handle_zero(char *exp) {
  int res = 0;
  int dot_index = tools_str_ch_index_first(exp, '.');
  int i = 0;
  int exp_len = strlen(exp);
  int last_num = 0;
  for (i = exp_len - 1; i > dot_index; i--) {
    if ('0' != exp[i]) {
      last_num = i;
      break;
    }
  }
  if (0 == last_num) {
    exp[dot_index] = '\0';
  } else {
    exp[i + 1] = '\0';
  }
  res = 1;
  return res;
}


x86 assembly (clang, -O0):
<tools_exp_handle_zero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <tools_str_ch_index_first@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11aa <tools_exp_handle_zero+0x8a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
je     1197 <tools_exp_handle_zero+0x77>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <tools_exp_handle_zero+0x8a>
jmp    119c <tools_exp_handle_zero+0x7c>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <tools_exp_handle_zero+0x47>
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jne    11c6 <tools_exp_handle_zero+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11d7 <tools_exp_handle_zero+0xb7>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tools_exp_handle_zero>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <tools_str_ch_index_first@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
movslq %ebp,%rcx
mov    %rsi,%rdi
shl    $0x20,%rdi
movabs $0x100000000,%rdx
add    %rdi,%rdx
add    $0xffffffffffffffff,%rsi
movabs $0xffffffff00000000,%rdi
ff ff ff
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rcx,%rsi
jle    1190 <tools_exp_handle_zero+0x70>
add    %rdi,%rdx
add    $0xffffffff,%eax
cmpb   $0x30,(%rbx,%rsi,1)
lea    -0x1(%rsi),%rsi
je     1170 <tools_exp_handle_zero+0x50>
test   %eax,%eax
je     1190 <tools_exp_handle_zero+0x70>
sar    $0x20,%rdx
mov    %rdx,%rcx
movb   $0x0,(%rbx,%rcx,1)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tools_exp_handle_zero(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%8 = load i8*, i8** %2
%9 = call i32 @tools_str_ch_index_first(i8* %8, i8 signext 46)
store i32 %9, i32* %4
store i32 0, i32* %5
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
store i32 0, i32* %7
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %5
br label %14
14: ; preds = %29, %1
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 48, %24
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = load i32, i32* %5
store i32 %27, i32* %7
br label %32
28: ; preds = %18
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, -1
store i32 %31, i32* %5
br label %14
32: ; preds = %26, %14
%33 = load i32, i32* %7
%34 = icmp eq i32 0, %33
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i8*, i8** %2
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
br label %46
40: ; preds = %32
%41 = load i8*, i8** %2
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 0, i8* %45
br label %46
46: ; preds = %40, %35
store i32 1, i32* %3
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @tools_exp_handle_zero(i8* %0) {
%2 = tail call i32 @tools_str_ch_index_first(i8* %0, i8 signext 46)
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
%5 = sext i32 %2 to i64
br label %6
6: ; preds = %10, %1
%7 = phi i64 [ %8, %10 ], [ %4, %1 ]
%8 = add nsw i64 %7, -1
%9 = icmp sgt i64 %8, %5
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %0, i64 %8
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 48
br i1 %13, label %6, label %14
14: ; preds = %10
%15 = trunc i64 %8 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = shl i64 %7, 32
%19 = ashr exact i64 %18, 32
br label %20
20: ; preds = %6, %14, %17
%21 = phi i64 [ %19, %17 ], [ %5, %14 ], [ %5, %6 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
ret i32 1
}