#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 *q_internal(char *, char *, int);
char *s_cat2(char *, char *);
int /*<<< orphan*/ s_internal(char *, char *, char *, int);
int strlen(char *);
char *append_trail_slash(char *str) {
  char *ret;
  if (str[strlen(str) - 1] != "/"[0]) {
    ret = s_cat2(
        (q_internal(str,
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Rudolph-Miller/roswell/"
                    "refs/heads/master/src/util_string.c",
                    158)),
        (q_internal("/",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Rudolph-Miller/roswell/"
                    "refs/heads/master/src/util_string.c",
                    158)));
  } else {
    ret = (q_internal(str,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/Rudolph-Miller/"
                      "roswell/refs/heads/master/src/util_string.c",
                      160));
  }
  (s_internal(str, "str",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Rudolph-Miller/roswell/refs/heads/"
              "master/src/util_string.c",
              162));
  return ret;
}


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,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
movsbl 0xe8c(%rip),%ecx
cmp    %ecx,%eax
je     11c2 <append_trail_slash+0x82>
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x9e,%edx
call   1060 <q_internal@plt>
mov    %rax,-0x20(%rbp)
lea    0xe64(%rip),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x9e,%edx
call   1060 <q_internal@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
call   1050 <s_cat2@plt>
mov    %rax,-0x10(%rbp)
jmp    11db <append_trail_slash+0x9b>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0xa0,%edx
call   1060 <q_internal@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
lea    0xe15(%rip),%rdx
mov    $0xa2,%ecx
call   1030 <s_internal@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_trail_slash>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    116c <append_trail_slash+0x2c>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa0,%edx
call   1060 <q_internal@plt>
jmp    11a5 <append_trail_slash+0x65>
lea    0xe8f(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9e,%edx
call   1060 <q_internal@plt>
mov    %rax,%r15
lea    0xe73(%rip),%rdi
mov    %r14,%rsi
mov    $0x9e,%edx
call   1060 <q_internal@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <s_cat2@plt>
mov    %rax,%r14
lea    0xee8(%rip),%rsi
lea    0xe4c(%rip),%rdx
mov    %rbx,%rdi
mov    $0xa2,%ecx
call   1030 <s_internal@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Rudolph-Miller/roswell/refs/heads/master/src/util_string.c\00"
@.str.2 = [4 x i8] c"str\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 %12, label %8
8: ; preds = %1
%9 = tail call i8* @q_internal(i8* %0, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 158)
%10 = tail call i8* @q_internal(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 158)
%11 = tail call i8* @s_cat2(i8* %9, i8* %10)
br label %14
12: ; preds = %1
%13 = tail call i8* @q_internal(i8* %0, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 160)
br label %14
14: ; preds = %12, %8
%15 = phi i8* [ %11, %8 ], [ %13, %12 ]
%16 = tail call i32 @s_internal(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 162)
ret i8* %15
}