#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 */
char *cat2(char *, char *);
char *q_internal(char *, char *, int);
int strlen(char *);
char *append_trail_slash(char *str) {
  return str[strlen(str) - 1] != "/"[0]
             ? cat2(str, "/")
             : (q_internal(
                   str,
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/roswell/roswell/refs/"
                   "heads/master/src/util-string.c",
                   154));
}


x86 assembly (clang, -O0):
<append_trail_slash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
movsbl 0xe9c(%rip),%ecx
cmp    %ecx,%eax
je     1185 <append_trail_slash+0x55>
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <cat2@plt>
mov    %rax,-0x18(%rbp)
jmp    119e <append_trail_slash+0x6e>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x9a,%edx
call   1050 <q_internal@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_trail_slash>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    1157 <append_trail_slash+0x27>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9a,%edx
pop    %rbx
jmp    1050 <q_internal@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <cat2@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/roswell/roswell/refs/heads/master/src/util-string.c\00"
define i8* @append_trail_slash(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sub nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %3, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i8* @cat2(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %20
17: ; preds = %1
%18 = load i8*, i8** %2
%19 = call i8* @q_internal(i8* %18, i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i32 154)
br label %20
20: ; preds = %17, %14
%21 = phi i8* [ %16, %14 ], [ %19, %17 ]
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/roswell/roswell/refs/heads/master/src/util-string.c\00"
define i8* @append_trail_slash(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 47
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i8* @cat2(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = tail call i8* @q_internal(i8* %0, i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i32 154)
br label %12
12: ; preds = %10, %8
%13 = phi i8* [ %9, %8 ], [ %11, %10 ]
ret i8* %13
}