#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 */
unsigned int dircount(char *, int);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  unsigned int cnt = 0;
  int flags = 0, opt;
  char *progname = argv[0];
  while ((opt = getopt(argc, argv, "hqr")) != -1)
    switch (opt) {
    case 'q':
      flags |= (1 << 0);
      break;
    case 'r':
      flags |= (1 << 1);
      break;
    default:
      usage(progname);
    }
  argc -= optind;
  argv += optind;
  if (1 != argc)
    usage(progname);
  cnt = dircount(argv[0], flags);
  if ((1 << 1) & flags)
    printf("--------\nTotal\t%u\n", cnt);
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe83(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11dd <main+0x9d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x71,%eax
je     11b3 <main+0x73>
jmp    11a2 <main+0x62>
mov    -0x2c(%rbp),%eax
sub    $0x72,%eax
je     11c1 <main+0x81>
jmp    11cf <main+0x8f>
mov    -0x18(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d8 <main+0x98>
mov    -0x18(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    11d8 <main+0x98>
mov    -0x28(%rbp),%rdi
call   1040 <usage@plt>
jmp    116f <main+0x2f>
mov    0x2e04(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     121e <main+0xde>
mov    -0x28(%rbp),%rdi
call   1040 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%esi
call   1060 <dircount@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     124e <main+0x10e>
mov    -0x14(%rbp),%esi
lea    0xdbb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%r15
xor    %r14d,%r14d
lea    0xea6(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0xffffffff,%eax
je     1192 <main+0x52>
cmp    $0x72,%eax
je     1186 <main+0x46>
cmp    $0x71,%eax
je     118c <main+0x4c>
mov    %r15,%rdi
call   1040 <usage@plt>
jmp    1160 <main+0x20>
or     $0x2,%r14d
jmp    1160 <main+0x20>
or     $0x1,%r14d
jmp    1160 <main+0x20>
mov    0x2e4f(%rip),%rax
mov    (%rax),%r12
sub    %r12d,%ebp
cmp    $0x1,%ebp
je     11ac <main+0x6c>
mov    %r15,%rdi
call   1040 <usage@plt>
mov    (%rbx,%r12,8),%rdi
mov    %r14d,%esi
call   1060 <dircount@plt>
test   $0x2,%r14b
je     11cc <main+0x8c>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hqr\00"
@optind = global i64 0
@.str.1 = [19 x i8] c"--------\0ATotal\09%u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %9
br label %13
13: ; preds = %29, %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, i64 0, i64 0))
store i32 %16, i32* %8
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i32, i32* %8
switch i32 %19, label %26 [
i32 113, label %20
i32 114, label %23
]
20: ; preds = %18
%21 = load i32, i32* %7
%22 = or i32 %21, 1
store i32 %22, i32* %7
br label %29
23: ; preds = %18
%24 = load i32, i32* %7
%25 = or i32 %24, 2
store i32 %25, i32* %7
br label %29
26: ; preds = %18
%27 = load i8*, i8** %9
%28 = call i32 @usage(i8* %27)
br label %29
29: ; preds = %26, %23, %20
br label %13
30: ; preds = %13
%31 = load i64, i64* @optind
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %33, %31
%35 = trunc i64 %34 to i32
store i32 %35, i32* %4
%36 = load i64, i64* @optind
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 %36
store i8** %38, i8*** %5
%39 = load i32, i32* %4
%40 = icmp ne i32 1, %39
br i1 %40, label %41, label %44
41: ; preds = %30
%42 = load i8*, i8** %9
%43 = call i32 @usage(i8* %42)
br label %44
44: ; preds = %41, %30
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = load i32, i32* %7
%49 = call i32 @dircount(i8* %47, i32 %48)
store i32 %49, i32* %6
%50 = load i32, i32* %7
%51 = and i32 2, %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %44
%54 = load i32, i32* %6
%55 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %44
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"hqr\00"
@optind = global i64 0
@.str.1 = [19 x i8] c"--------\0ATotal\09%u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
br label %4
4: ; preds = %12, %2
%5 = phi i32 [ 0, %2 ], [ %13, %12 ]
br label %6
6: ; preds = %4, %14
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %14 [
i32 -1, label %16
i32 113, label %8
i32 114, label %10
]
8: ; preds = %6
%9 = or i32 %5, 1
br label %12
10: ; preds = %6
%11 = or i32 %5, 2
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ]
br label %4
14: ; preds = %6
%15 = tail call i32 @usage(i8* %3)
br label %6
16: ; preds = %6
%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 eq i32 %19, 1
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = tail call i32 @usage(i8* %3)
br label %24
24: ; preds = %22, %16
%25 = load i8*, i8** %20
%26 = tail call i32 @dircount(i8* %25, i32 %5)
%27 = and i32 %5, 2
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %24
%30 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %31
31: ; preds = %29, %24
ret i32 0
}