#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*/ LC_ALL;
char *basename(char *);
int /*<<< orphan*/ err(int, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stripsuffix(char *, char *, size_t);
size_t strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *p, *suffix;
  size_t suffixlen;
  int aflag, ch;
  setlocale(LC_ALL, "");
  aflag = 0;
  suffix = NULL;
  suffixlen = 0;
  while ((ch = getopt(argc, argv, "as:")) != -1)
    switch (ch) {
    case 'a':
      aflag = 1;
      break;
    case 's':
      suffix = optarg;
      break;
    case '?':
    default:
      usage();
    }
  argc -= optind;
  argv += optind;
  if (argc < 1)
    usage();
  if (!*argv[0]) {
    printf("\n");
    exit(0);
  }
  if ((p = basename(argv[0])) == NULL)
    err(1, "%s", argv[0]);
  if ((suffix == NULL && !aflag) && argc == 2) {
    suffix = argv[1];
    argc--;
  }
  if (suffix != NULL)
    suffixlen = strlen(suffix);
  while (argc--) {
    if ((p = basename(*argv)) == NULL)
      err(1, "%s", argv[0]);
    stripsuffix(p, suffix, suffixlen);
    argv++;
    (void)printf("%s\n", p);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1080 <setlocale@plt>
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe20(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
je     1257 <main+0xc7>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x3f,%eax
je     1246 <main+0xb6>
jmp    1205 <main+0x75>
mov    -0x34(%rbp),%eax
sub    $0x61,%eax
je     1227 <main+0x97>
jmp    1216 <main+0x86>
mov    -0x34(%rbp),%eax
sub    $0x73,%eax
je     1233 <main+0xa3>
jmp    124b <main+0xbb>
movl   $0x1,-0x2c(%rbp)
jmp    1252 <main+0xc2>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1252 <main+0xc2>
jmp    124b <main+0xbb>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    11d2 <main+0x42>
mov    0x2d82(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1292 <main+0x102>
mov    $0x0,%al
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
jne    12b7 <main+0x127>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12e9 <main+0x159>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xd20(%rip),%rsi
call   1060 <err@plt>
cmpq   $0x0,-0x20(%rbp)
jne    131d <main+0x18d>
cmpl   $0x0,-0x2c(%rbp)
jne    131d <main+0x18d>
cmpl   $0x2,-0x8(%rbp)
jne    131d <main+0x18d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1335 <main+0x1a5>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
jmp    133a <main+0x1aa>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     13b4 <main+0x224>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1380 <main+0x1f0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xc89(%rip),%rsi
call   1060 <err@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <stripsuffix@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133a <main+0x1aa>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1090 <setlocale@plt>
lea    0xe33(%rip),%rbp
mov    0x2e24(%rip),%r12
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    11e0 <main+0x40>
mov    (%r12),%r14
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10b0 <getopt@plt>
cmp    $0x61,%eax
je     1206 <main+0x66>
cmp    $0x73,%eax
je     11dc <main+0x3c>
cmp    $0xffffffff,%eax
je     120e <main+0x6e>
xor    %eax,%eax
call   10a0 <usage@plt>
jmp    11e0 <main+0x40>
mov    $0x1,%r13d
jmp    11e0 <main+0x40>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rax
sub    %eax,%r15d
lea    (%rbx,%rax,8),%r12
test   %r15d,%r15d
jg     122b <main+0x8b>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    (%r12),%rdi
cmpb   $0x0,(%rdi)
jne    1245 <main+0xa5>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
call   1060 <basename@plt>
test   %rax,%rax
jne    1264 <main+0xc4>
mov    (%r12),%rdx
lea    0xdaa(%rip),%rsi
mov    $0x1,%edi
call   1070 <err@plt>
test   %r14,%r14
jne    127f <main+0xdf>
test   %r13d,%r13d
jne    127f <main+0xdf>
cmp    $0x2,%r15d
jne    127f <main+0xdf>
mov    0x8(%r12),%r14
mov    $0x1,%r15d
test   %r14,%r14
jne    128e <main+0xee>
xor    %r13d,%r13d
test   %r15d,%r15d
je     129e <main+0xfe>
jmp    12a5 <main+0x105>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
test   %r15d,%r15d
jne    12a5 <main+0x105>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    %r15d,%ebx
xor    %r15d,%r15d
jmp    12cf <main+0x12f>
nopl   (%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1080 <stripsuffix@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
add    $0x1,%r15
cmp    %r15d,%ebx
je     129e <main+0xfe>
mov    (%r12,%r15,8),%rdi
call   1060 <basename@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    12b0 <main+0x110>
mov    (%r12,%r15,8),%rdx
mov    $0x1,%edi
lea    0xd14(%rip),%rsi
call   1070 <err@plt>
jmp    12b0 <main+0x110>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"as:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @LC_ALL
%12 = call i32 @setlocale(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
store i8* null, i8** %7
store i64 0, i64* %8
br label %13
13: ; preds = %26, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %10
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = load i32, i32* %10
switch i32 %19, label %24 [
i32 97, label %20
i32 115, label %21
i32 63, label %23
]
20: ; preds = %18
store i32 1, i32* %9
br label %26
21: ; preds = %18
%22 = load i8*, i8** @optarg
store i8* %22, i8** %7
br label %26
23: ; preds = %18
br label %24
24: ; preds = %18, %23
%25 = call i32 (...) @usage()
br label %26
26: ; preds = %24, %21, %20
br label %13
27: ; preds = %13
%28 = load i64, i64* @optind
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = sub nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %4
%33 = load i64, i64* @optind
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 %33
store i8** %35, i8*** %5
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %27
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %38, %27
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %40
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = call i8* @basename(i8* %52)
store i8* %53, i8** %6
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %49
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %55, %49
%61 = load i8*, i8** %7
%62 = icmp eq i8* %61, null
br i1 %62, label %63, label %75
63: ; preds = %60
%64 = load i32, i32* %9
%65 = icmp ne i32 %64, 0
br i1 %65, label %75, label %66
66: ; preds = %63
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 2
br i1 %68, label %69, label %75
69: ; preds = %66
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
store i8* %72, i8** %7
%73 = load i32, i32* %4
%74 = add nsw i32 %73, -1
store i32 %74, i32* %4
br label %75
75: ; preds = %69, %66, %63, %60
%76 = load i8*, i8** %7
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i8*, i8** %7
%80 = call i64 @strlen(i8* %79)
store i64 %80, i64* %8
br label %81
81: ; preds = %78, %75
br label %82
82: ; preds = %96, %81
%83 = load i32, i32* %4
%84 = add nsw i32 %83, -1
store i32 %84, i32* %4
%85 = icmp ne i32 %83, 0
br i1 %85, label %86, label %105
86: ; preds = %82
%87 = load i8**, i8*** %5
%88 = load i8*, i8** %87
%89 = call i8* @basename(i8* %88)
store i8* %89, i8** %6
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %96
91: ; preds = %86
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 0
%94 = load i8*, i8** %93
%95 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %94)
br label %96
96: ; preds = %91, %86
%97 = load i8*, i8** %6
%98 = load i8*, i8** %7
%99 = load i64, i64* %8
%100 = call i32 @stripsuffix(i8* %97, i8* %98, i64 %99)
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i32 1
store i8** %102, i8*** %5
%103 = load i8*, i8** %6
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %103)
br label %82
105: ; preds = %82
%106 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"as:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %12, %2
%6 = phi i8* [ %13, %12 ], [ null, %2 ]
%7 = phi i32 [ %9, %12 ], [ 0, %2 ]
br label %8
8: ; preds = %10, %5
%9 = phi i32 [ %7, %5 ], [ 1, %10 ]
br label %10
10: ; preds = %8, %14
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
switch i32 %11, label %14 [
i32 -1, label %16
i32 97, label %8
i32 115, label %12
]
12: ; preds = %10
%13 = load i8*, i8** @optarg
br label %5
14: ; preds = %10
%15 = tail call i32 (...) @usage()
br label %10
16: ; preds = %10
%17 = load i64, i64* @optind
%18 = trunc i64 %17 to i32
%19 = sub i32 %0, %18
%20 = getelementptr inbounds i8*, i8** %1, i64 %17
%21 = icmp slt i32 %19, 1
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = tail call i32 (...) @usage()
br label %24
24: ; preds = %22, %16
%25 = load i8*, i8** %20
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @exit(i32 0)
unreachable
31: ; preds = %24
%32 = tail call i8* @basename(i8* %25)
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** %20
%36 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %31
%38 = icmp eq i8* %6, null
%39 = icmp eq i32 %9, 0
%40 = select i1 %38, i1 %39, i1 false
%41 = icmp eq i32 %19, 2
%42 = select i1 %40, i1 %41, i1 false
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = getelementptr inbounds i8*, i8** %20, i64 1
%45 = load i8*, i8** %44
br label %46
46: ; preds = %43, %37
%47 = phi i8* [ %45, %43 ], [ %6, %37 ]
%48 = phi i32 [ 1, %43 ], [ %19, %37 ]
%49 = icmp eq i8* %47, null
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = tail call i64 @strlen(i8* %47)
br label %52
52: ; preds = %50, %46
%53 = phi i64 [ %51, %50 ], [ 0, %46 ]
%54 = icmp eq i32 %48, 0
br i1 %54, label %70, label %55
55: ; preds = %52, %65
%56 = phi i32 [ %58, %65 ], [ %48, %52 ]
%57 = phi i8** [ %67, %65 ], [ %20, %52 ]
%58 = add nsw i32 %56, -1
%59 = load i8*, i8** %57
%60 = tail call i8* @basename(i8* %59)
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %55
%63 = load i8*, i8** %57
%64 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %62, %55
%66 = tail call i32 @stripsuffix(i8* %60, i8* %47, i64 %53)
%67 = getelementptr inbounds i8*, i8** %57, i64 1
%68 = tail call i32 @puts(i8* dereferenceable(1) %60)
%69 = icmp eq i32 %58, 0
br i1 %69, label %70, label %55
70: ; preds = %65, %52
%71 = tail call i32 @exit(i32 0)
unreachable
}