#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 */
typedef scalar_t__ strcmp;

/* Variables and functions */
int EXIT_SUCCESS;
char *basename(char *);
int /*<<< orphan*/ puts(char *);
size_t strlen(char *);
int main(int argc, char **argv) {
  size_t m, n;
  char *s;
  if (((unsigned int)(argc - 2)) >= 2) {
  }
  s = basename(*++argv);
  if (*++argv) {
    n = strlen(*argv);
    m = strlen(s);
    if ((m > n) && ((strcmp)(s + m - n, *argv) == 0)) {
      s[m - n] = '\0';
    }
  }
  puts(s);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cmp    $0x2,%eax
jb     115a <main+0x2a>
jmp    115a <main+0x2a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     11e1 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11dc <main+0xac>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    $0x0,%rax
jne    11dc <main+0xac>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11e1 <main+0xb1>
mov    -0x28(%rbp),%rdi
call   1030 <puts@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <basename@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    0x2ea7(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 2
%11 = icmp uge i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %5
%16 = load i8*, i8** %15
%17 = call i8* @basename(i8* %16)
store i8* %17, i8** %8
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %49
22: ; preds = %13
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = call i64 @strlen(i8* %24)
store i64 %25, i64* %7
%26 = load i8*, i8** %8
%27 = call i64 @strlen(i8* %26)
store i64 %27, i64* %6
%28 = load i64, i64* %6
%29 = load i64, i64* %7
%30 = icmp ugt i64 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %22
%32 = load i8*, i8** %8
%33 = load i64, i64* %6
%34 = getelementptr inbounds i8, i8* %32, i64 %33
%35 = load i64, i64* %7
%36 = sub i64 0, %35
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = ptrtoint i8* %39 to i64
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %31
%43 = load i8*, i8** %8
%44 = load i64, i64* %6
%45 = load i64, i64* %7
%46 = sub i64 %44, %45
%47 = getelementptr inbounds i8, i8* %43, i64 %46
store i8 0, i8* %47
br label %48
48: ; preds = %42, %31, %22
br label %49
49: ; preds = %48, %13
%50 = load i8*, i8** %8
%51 = call i32 @puts(i8* %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i8* @basename(i8* %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
%7 = load i32, i32* @EXIT_SUCCESS
ret i32 %7
}