#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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *trim_index_zero(char *destination, char *attribute_name) {
  char *end_ptr;
  strcpy(destination, attribute_name);
  end_ptr = destination + strlen(destination) - 1;
  if (*end_ptr != '0')
    return destination;
  end_ptr--;
  if (*end_ptr == '_')
    *end_ptr = '\0';
  return destination;
}


x86 assembly (clang, -O0):
<trim_index_zero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     117f <trim_index_zero+0x5f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11aa <trim_index_zero+0x8a>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    11a2 <trim_index_zero+0x82>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_index_zero>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x30,-0x1(%rbx,%rax,1)
jne    1146 <trim_index_zero+0x26>
cmpb   $0x5f,-0x2(%rbx,%rax,1)
jne    1146 <trim_index_zero+0x26>
movb   $0x0,-0x2(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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