#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*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ zero_string(char *, int);
int strip_trailing_slash(const char *in_str, char *out_str, int out_len) {
  int status = 0;
  if (in_str == NULL) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 512,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/auxil.c");
      };
      status = -1;
      goto BYE;
    };
  }
  if (out_str == NULL) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 513,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/auxil.c");
      };
      status = -1;
      goto BYE;
    };
  }
  if (out_len <= 0) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 514,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/auxil.c");
      };
      status = -1;
      goto BYE;
    };
  }
  zero_string(out_str, out_len);
  int in_len = strlen(in_str);
  if (in_len >= out_len) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 518,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/auxil.c");
      };
      status = -1;
      goto BYE;
    };
  }
  strcpy(out_str, in_str);
  for (int i = in_len - 1; i >= 0; i--) {
    if (out_str[i] == '/') {
      out_str[i] = '\0';
    } else {
      break;
    }
  }
  if (strlen(out_str) == 0) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 528,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/auxil.c");
      };
      status = -1;
      goto BYE;
    };
  }
BYE:
  return status;
}


x86 assembly (clang, -O0):
<strip_trailing_slash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1192 <strip_trailing_slash+0x52>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
mov    $0x200,%edx
lea    0xe95(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x18(%rbp)
jmp    12f4 <strip_trailing_slash+0x1b4>
cmpq   $0x0,-0x10(%rbp)
jne    11ca <strip_trailing_slash+0x8a>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    $0x201,%edx
lea    0xe5d(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x18(%rbp)
jmp    12f4 <strip_trailing_slash+0x1b4>
cmpl   $0x0,-0x14(%rbp)
jg     1201 <strip_trailing_slash+0xc1>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    $0x202,%edx
lea    0xe26(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x18(%rbp)
jmp    12f4 <strip_trailing_slash+0x1b4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <zero_string@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1252 <strip_trailing_slash+0x112>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
mov    $0x206,%edx
lea    0xdd5(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x18(%rbp)
jmp    12f4 <strip_trailing_slash+0x1b4>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     12b0 <strip_trailing_slash+0x170>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1298 <strip_trailing_slash+0x158>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    129d <strip_trailing_slash+0x15d>
jmp    12b0 <strip_trailing_slash+0x170>
jmp    12a2 <strip_trailing_slash+0x162>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1268 <strip_trailing_slash+0x128>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jne    12ef <strip_trailing_slash+0x1af>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
mov    $0x210,%edx
lea    0xd38(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x18(%rbp)
jmp    12f4 <strip_trailing_slash+0x1b4>
jmp    12f4 <strip_trailing_slash+0x1b4>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_trailing_slash>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11ce <strip_trailing_slash+0x8e>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11d5 <strip_trailing_slash+0x95>
mov    %edx,%ebp
test   %edx,%edx
jle    11dc <strip_trailing_slash+0x9c>
mov    %rdi,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <zero_string@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    $0x206,%edx
cmp    %ebp,%eax
jge    11e1 <strip_trailing_slash+0xa1>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
test   %r15d,%r15d
jle    11b7 <strip_trailing_slash+0x77>
mov    %r15d,%eax
add    $0x1,%rax
xchg   %ax,%ax
lea    -0x2(%rax),%ecx
cmpb   $0x2f,(%rbx,%rcx,1)
jne    11b7 <strip_trailing_slash+0x77>
movb   $0x0,(%rbx,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     11a0 <strip_trailing_slash+0x60>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1202 <strip_trailing_slash+0xc2>
mov    $0x210,%edx
jmp    11e1 <strip_trailing_slash+0xa1>
mov    $0x200,%edx
jmp    11e1 <strip_trailing_slash+0xa1>
mov    $0x201,%edx
jmp    11e1 <strip_trailing_slash+0xa1>
mov    $0x202,%edx
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
lea    0xe1e(%rip),%rcx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/DEPRECATED_Q2/AUX/auxil.c\00"
define i32 @strip_trailing_slash(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 512, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %74
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 513, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %74
21: ; preds = %15
%22 = load i32, i32* %6
%23 = icmp sle i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 514, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %74
27: ; preds = %21
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = call i32 @zero_string(i8* %28, i32 %29)
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = load i32, i32* %6
%35 = icmp sge i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %27
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 518, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %74
39: ; preds = %27
%40 = load i8*, i8** %5
%41 = load i8*, i8** %4
%42 = call i32 @strcpy(i8* %40, i8* %41)
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 1
store i32 %44, i32* %9
br label %45
45: ; preds = %63, %39
%46 = load i32, i32* %9
%47 = icmp sge i32 %46, 0
br i1 %47, label %48, label %66
48: ; preds = %45
%49 = load i8*, i8** %5
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 47
br i1 %55, label %56, label %61
56: ; preds = %48
%57 = load i8*, i8** %5
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8 0, i8* %60
br label %62
61: ; preds = %48
br label %66
62: ; preds = %56
br label %63
63: ; preds = %62
%64 = load i32, i32* %9
%65 = add nsw i32 %64, -1
store i32 %65, i32* %9
br label %45
66: ; preds = %61, %45
%67 = load i8*, i8** %5
%68 = call i32 @strlen(i8* %67)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 528, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %74
73: ; preds = %66
br label %74
74: ; preds = %73, %70, %36, %24, %18, %12
%75 = load i32, i32* %7
ret i32 %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/DEPRECATED_Q2/AUX/auxil.c\00"
define i32 @strip_trailing_slash(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %30, label %5
5: ; preds = %3
%6 = icmp eq i8* %1, null
br i1 %6, label %30, label %7
7: ; preds = %5
%8 = icmp slt i32 %2, 1
br i1 %8, label %30, label %9
9: ; preds = %7
%10 = tail call i32 @zero_string(i8* %1, i32 %2)
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp slt i32 %11, %2
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = tail call i32 @strcpy(i8* %1, i8* %0)
%15 = icmp sgt i32 %11, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = zext i32 %11 to i64
br label %18
18: ; preds = %16, %25
%19 = phi i64 [ %17, %16 ], [ %20, %25 ]
%20 = add nsw i64 %19, -1
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 47
br i1 %24, label %25, label %27
25: ; preds = %18
store i8 0, i8* %22
%26 = icmp ugt i64 %19, 1
br i1 %26, label %18, label %27
27: ; preds = %25, %18, %13
%28 = tail call i32 @strlen(i8* %1)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27, %9, %7, %5, %3
%31 = phi i32 [ 512, %3 ], [ 513, %5 ], [ 514, %7 ], [ 518, %9 ], [ 528, %27 ]
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %31, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %30, %27
%35 = phi i32 [ 0, %27 ], [ -1, %30 ]
ret i32 %35
}