#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 */
char *basename(char *);
int /*<<< orphan*/ remove_suffix(char *, char *);
int /*<<< orphan*/ strip_trailing_slashes(char *);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  char *line;
  if (argc == 2 || argc == 3) {
    strip_trailing_slashes(argv[1]);
    line = basename(argv[1]);
    if (argc == 3)
      remove_suffix(line, argv[2]);
    write(1, line, strlen(line));
    write(1, "\n", 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jne    11e7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strip_trailing_slashes@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11b3 <main+0x63>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1070 <remove_suffix@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe20(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11ba <main+0x6a>
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1060 <strip_trailing_slashes@plt>
mov    0x8(%rbx),%rdi
call   1050 <basename@plt>
mov    %rax,%r14
cmp    $0x3,%ebp
jne    1189 <main+0x39>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1070 <remove_suffix@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe59(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
pop    %rbx
pop    %r14
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %35
12: ; preds = %9, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strip_trailing_slashes(i8* %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @basename(i8* %19)
store i8* %20, i8** %6
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %29
23: ; preds = %12
%24 = load i8*, i8** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @remove_suffix(i8* %24, i8* %27)
br label %29
29: ; preds = %23, %12
%30 = load i8*, i8** %6
%31 = load i8*, i8** %6
%32 = call i32 @strlen(i8* %31)
%33 = call i32 @write(i32 1, i8* %30, i32 %32)
%34 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %35
35: ; preds = %29, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = and i32 %0, -2
%4 = icmp eq i32 %3, 2
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = icmp eq i32 %0, 3
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strip_trailing_slashes(i8* %8)
%10 = load i8*, i8** %7
%11 = tail call i8* @basename(i8* %10)
br i1 %6, label %12, label %16
12: ; preds = %5
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @remove_suffix(i8* %11, i8* %14)
br label %16
16: ; preds = %12, %5
%17 = tail call i32 @strlen(i8* %11)
%18 = tail call i32 @write(i32 1, i8* %11, i32 %17)
%19 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %20
20: ; preds = %2, %16
ret i32 0
}