#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 *);
char *stb_strip_final_slash_regardless(char *t) {
  if (t[0]) {
    char *z = t + strlen(t) - 1;
    if (*z == '\\' || *z == '/')
      *z = 0;
    if (*z == '\\')
      *z = '/';
  }
  return t;
}


x86 assembly (clang, -O0):
<stb_strip_final_slash_regardless>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1191 <stb_strip_final_slash_regardless+0x81>
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
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     116e <stb_strip_final_slash_regardless+0x5e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1175 <stb_strip_final_slash_regardless+0x65>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    118c <stb_strip_final_slash_regardless+0x7c>
mov    -0x10(%rbp),%rax
movb   $0x2f,(%rax)
jmp    1191 <stb_strip_final_slash_regardless+0x81>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_strip_final_slash_regardless>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1136 <stb_strip_final_slash_regardless+0x26>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    -0x1(%rbx,%rax,1),%cl
cmp    $0x5c,%cl
je     1131 <stb_strip_final_slash_regardless+0x21>
cmp    $0x2f,%cl
jne    1136 <stb_strip_final_slash_regardless+0x26>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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