#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*/ strcat(char *, char *);
int strlen(char *);
void any_suffix_change(char *name, char *suffix, char suffix_delimiter) {
  int j;
  j = strlen(name) - 1;
  while (j && name[j - 1] != suffix_delimiter)
    j--;
  if (j)
    name[j - 1] = '\0';
  strcat(name, suffix);
}


x86 assembly (clang, -O0):
<any_suffix_change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1170 <any_suffix_change+0x50>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1180 <any_suffix_change+0x60>
jmp    118e <any_suffix_change+0x6e>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <any_suffix_change+0x24>
cmpl   $0x0,-0x18(%rbp)
je     11a9 <any_suffix_change+0x89>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any_suffix_change>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rcx
add    $0xffffffffffffffff,%rcx
mov    $0x1,%edx
sub    %eax,%edx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %esi,%edx
je     116a <any_suffix_change+0x4a>
lea    -0x1(%rsi),%rdi
cmp    %bpl,-0x1(%rcx,%rsi,1)
mov    %rdi,%rsi
jne    1150 <any_suffix_change+0x30>
add    %rbx,%rax
movb   $0x0,-0x1(%rdi,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <strcat@plt>

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

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