#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*/ strcmp(char *, char const *);
scalar_t__ strlen(char const *);
int strip_suffix(char *src, const char *suffix) {
  int have = (int)strlen(src);
  int want = (int)strlen(suffix);
  if (have > want) {
    have -= want;
    if (!strcmp(src + have, suffix)) {
      src[have] = '\0';
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<strip_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1199 <strip_suffix+0x79>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1194 <strip_suffix+0x74>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    11a0 <strip_suffix+0x80>
jmp    1199 <strip_suffix+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_suffix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    %eax,%ebp
jle    1164 <strip_suffix+0x44>
sub    %eax,%ebp
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1164 <strip_suffix+0x44>
movb   $0x0,(%rbx)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strip_suffix(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %7
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %2
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, %18
store i32 %20, i32* %6
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8*, i8** %5
%26 = call i32 @strcmp(i8* %24, i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %17
%29 = load i8*, i8** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
store i32 1, i32* %3
br label %35
33: ; preds = %17
br label %34
34: ; preds = %33, %2
store i32 0, i32* %3
br label %35
35: ; preds = %34, %28
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @strip_suffix(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = trunc i64 %5 to i32
%7 = icmp sgt i32 %4, %6
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = sub i64 %3, %5
%10 = shl i64 %9, 32
%11 = ashr exact i64 %10, 32
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(1) %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %8
store i8 0, i8* %12
br label %16
16: ; preds = %2, %8, %15
%17 = phi i32 [ 1, %15 ], [ 0, %8 ], [ 0, %2 ]
ret i32 %17
}