#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 *const);
scalar_t__ strncmp(char *, char *, int);
void ensureFinalSlash(char *const aioString) {
  if (aioString && strlen(aioString)) {
    char *lastcar = aioString + strlen(aioString) - 1;
    if (strncmp(lastcar, "/", 1)) {
      strcat(lastcar, "/");
    }
  }
}


x86 assembly (clang, -O0):
<ensureFinalSlash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b2 <ensureFinalSlash+0x82>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
je     11b2 <ensureFinalSlash+0x82>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <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),%rdi
lea    0xe77(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11ad <ensureFinalSlash+0x7d>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1050 <strcat@plt>
jmp    11b2 <ensureFinalSlash+0x82>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ensureFinalSlash>:
push   %rbx
test   %rdi,%rdi
je     117c <ensureFinalSlash+0x4c>
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     117c <ensureFinalSlash+0x4c>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     117c <ensureFinalSlash+0x4c>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <strcat@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @ensureFinalSlash(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %24
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -1
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = load i8*, i8** %3
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %20, %10
br label %24
24: ; preds = %23, %6, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @ensureFinalSlash(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -1
%11 = tail call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %6, %13, %3, %1
ret void
}