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


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     11a0 <append_trail_slash+0x70>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe85(%rip),%rdi
lea    0xe80(%rip),%rsi
mov    $0x9c,%edx
call   1050 <q_internal@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1040 <s_cat2@plt>
mov    %rax,-0x18(%rbp)
jmp    11a8 <append_trail_slash+0x78>
mov    -0x8(%rbp),%rax
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    1147 <append_trail_slash+0x17>
mov    %rbx,%rax
pop    %rbx
ret
lea    0xeb2(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x9c,%edx
call   1050 <q_internal@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <s_cat2@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/guicho271828/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 %18
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 @q_internal(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 156)
%17 = call i8* @s_cat2(i8* %15, i32 %16)
br label %20
18: ; preds = %1
%19 = load i8*, i8** %2
br label %20
20: ; preds = %18, %14
%21 = phi i8* [ %17, %14 ], [ %19, %18 ]
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/guicho271828/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 %11, label %8
8: ; preds = %1
%9 = tail call i32 @q_internal(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 156)
%10 = tail call i8* @s_cat2(i8* %0, i32 %9)
br label %11
11: ; preds = %1, %8
%12 = phi i8* [ %10, %8 ], [ %0, %1 ]
ret i8* %12
}