#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 *dirname(char *);
int /*<<< orphan*/ err(int, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *p;
  int ch;
  while ((ch = getopt(argc, argv, "")) != -1)
    switch (ch) {
    case '?':
    default:
      usage();
    }
  argc -= optind;
  argv += optind;
  if (argc < 1)
    usage();
  while (argc--) {
    if ((p = dirname(*argv)) == NULL)
      err(1, "%s", *argv);
    argv++;
    (void)printf("%s\n", p);
  }
  exit(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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11b7 <main+0x57>
mov    -0x1c(%rbp),%eax
sub    $0x3f,%eax
jne    11ab <main+0x4b>
jmp    11a6 <main+0x46>
jmp    11ab <main+0x4b>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1176 <main+0x16>
mov    0x2e2a(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2e16(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    11f2 <main+0x92>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    11f7 <main+0x97>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     125e <main+0xfe>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <dirname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    123d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xdc8(%rip),%rsi
call   1050 <err@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xdaf(%rip),%rdi
call   1030 <printf@plt>
jmp    11f7 <main+0x97>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
lea    0xe8f(%rip),%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     11a9 <main+0x49>
lea    0xe7e(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x30>
mov    0x2e38(%rip),%rax
mov    (%rax),%rbx
mov    %ebp,%r14d
sub    %ebx,%r14d
test   %r14d,%r14d
jg     11d1 <main+0x71>
xor    %eax,%eax
call   1060 <usage@plt>
test   %r14d,%r14d
jne    11d1 <main+0x71>
xor    %edi,%edi
call   1080 <exit@plt>
mov    %ebp,%r13d
lea    0xe25(%rip),%r14
lea    0xe21(%rip),%r15
jmp    1204 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r13d
je     11ca <main+0x6a>
mov    (%r12,%rbx,8),%rdi
call   1040 <dirname@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11f0 <main+0x90>
mov    (%r12,%rbx,8),%rdx
mov    $0x1,%edi
mov    %r14,%rsi
call   1050 <err@plt>
jmp    11f0 <main+0x90>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@optind = global i64 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i32, i32* %7
switch i32 %14, label %16 [
i32 63, label %15
]
15: ; preds = %13
br label %16
16: ; preds = %13, %15
%17 = call i32 (...) @usage()
br label %18
18: ; preds = %16
br label %8
19: ; preds = %8
%20 = load i64, i64* @optind
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = sub nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %4
%25 = load i64, i64* @optind
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 %25
store i8** %27, i8*** %5
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %19
br label %33
33: ; preds = %46, %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
%36 = icmp ne i32 %34, 0
br i1 %36, label %37, label %51
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = call i8* @dirname(i8* %39)
store i8* %40, i8** %6
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i8**, i8*** %5
%44 = load i8*, i8** %43
%45 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %42, %37
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i32 1
store i8** %48, i8*** %5
%49 = load i8*, i8** %6
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %49)
br label %33
51: ; preds = %33
%52 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@optind = global i64 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %9, label %5
5: ; preds = %2, %5
%6 = tail call i32 (...) @usage()
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %5
9: ; preds = %5, %2
%10 = load i64, i64* @optind
%11 = trunc i64 %10 to i32
%12 = sub i32 %0, %11
%13 = getelementptr inbounds i8*, i8** %1, i64 %10
%14 = icmp slt i32 %12, 1
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = tail call i32 (...) @usage()
%17 = icmp eq i32 %12, 0
br i1 %17, label %33, label %18
18: ; preds = %9, %15
br label %19
19: ; preds = %18, %29
%20 = phi i32 [ %22, %29 ], [ %12, %18 ]
%21 = phi i8** [ %30, %29 ], [ %13, %18 ]
%22 = add nsw i32 %20, -1
%23 = load i8*, i8** %21
%24 = tail call i8* @dirname(i8* %23)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i8*, i8** %21
%28 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %19
%30 = getelementptr inbounds i8*, i8** %21, i64 1
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%32 = icmp eq i32 %22, 0
br i1 %32, label %33, label %19
33: ; preds = %29, %15
%34 = tail call i32 @exit(i32 0)
unreachable
}