#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 remove_string_last_decorations(char *str) {
  char *p;
  if (!str || !(*str))
    return;
  p = str + strlen(str);
  while (--p != str) {
    if (((*p) != ',') && ((*p) != ' ') && ((*p) != '\t'))
      return;
    (*p) = '\0';
  }
}


x86 assembly (clang, -O0):
<remove_string_last_decorations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1134 <remove_string_last_decorations+0x24>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1139 <remove_string_last_decorations+0x29>
jmp    11b1 <remove_string_last_decorations+0xa1>
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
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    -0x8(%rbp),%rax
je     11b1 <remove_string_last_decorations+0xa1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     11a5 <remove_string_last_decorations+0x95>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11a5 <remove_string_last_decorations+0x95>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11a5 <remove_string_last_decorations+0x95>
jmp    11b1 <remove_string_last_decorations+0xa1>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    115a <remove_string_last_decorations+0x4a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_string_last_decorations>:
push   %rbx
test   %rdi,%rdi
je     116a <remove_string_last_decorations+0x5a>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116a <remove_string_last_decorations+0x5a>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rbx,%rcx
je     116a <remove_string_last_decorations+0x5a>
add    $0xffffffffffffffff,%rax
movabs $0x100100000200,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx,%rax,1),%edx
cmp    $0x2c,%rdx
ja     116a <remove_string_last_decorations+0x5a>
bt     %rdx,%rcx
jae    116a <remove_string_last_decorations+0x5a>
movb   $0x0,(%rbx,%rax,1)
add    $0xffffffffffffffff,%rax
jne    1150 <remove_string_last_decorations+0x40>
pop    %rbx
ret

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

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