#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 printFiles(char *, int /*<<< orphan*/, char *);
int printFilesPrefixMatch(char *, int /*<<< orphan*/, char *);
int printFilesWithPermisions(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc == 2) {
    if (strcmp("-m", argv[1]) == 0) {
      return printFilesWithPermisions(".", 0, "");
    }
  } else if (argc == 3) {
    return printFilesPrefixMatch(".", 0, argv[2]);
  } else if (argc == 1) {
    return printFiles(".", 0, "");
  } else {
    printf("usage ./<filename> <string> to match against\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11b0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe81(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ab <main+0x5b>
lea    0xe6e(%rip),%rdi
xor    %esi,%esi
lea    0xe94(%rip),%rdx
call   1060 <printFilesWithPermisions@plt>
mov    %eax,-0x4(%rbp)
jmp    121e <main+0xce>
jmp    1217 <main+0xc7>
cmpl   $0x3,-0x8(%rbp)
jne    11d8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe3a(%rip),%rdi
xor    %esi,%esi
call   1070 <printFilesPrefixMatch@plt>
mov    %eax,-0x4(%rbp)
jmp    121e <main+0xce>
cmpl   $0x1,-0x8(%rbp)
jne    11ff <main+0xaf>
lea    0xe1a(%rip),%rdi
xor    %esi,%esi
lea    0xe40(%rip),%rdx
call   1040 <printFiles@plt>
mov    %eax,-0x4(%rbp)
jmp    121e <main+0xce>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121e <main+0xce>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
je     117c <main+0x2c>
cmp    $0x3,%edi
je     1192 <main+0x42>
cmp    $0x2,%edi
jne    11a5 <main+0x55>
mov    0x8(%rsi),%rsi
lea    0xe95(%rip),%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11b8 <main+0x68>
pop    %rcx
ret
lea    0xe80(%rip),%rdi
lea    0xe7a(%rip),%rdx
xor    %esi,%esi
pop    %rax
jmp    1040 <printFiles@plt>
mov    0x10(%rsi),%rdx
lea    0xe66(%rip),%rdi
xor    %esi,%esi
pop    %rax
jmp    1070 <printFilesPrefixMatch@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
lea    0xe44(%rip),%rdi
lea    0xe3e(%rip),%rdx
xor    %esi,%esi
pop    %rax
jmp    1060 <printFilesWithPermisions@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-m\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [46 x i8] c"usage ./<filename> <string> to match against\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 @printFilesWithPermisions(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i32 %15, i32* %3
br label %33
16: ; preds = %8
br label %32
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @printFilesPrefixMatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %23)
store i32 %24, i32* %3
br label %33
25: ; preds = %17
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @printFiles(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i32 %29, i32* %3
br label %33
30: ; preds = %25
%31 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %33
32: ; preds = %16
store i32 0, i32* %3
br label %33
33: ; preds = %32, %30, %28, %20, %14
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"-m\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [1 x i8] zeroinitializer
@str = [45 x i8] c"usage ./<filename> <string> to match against\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %16 [
i32 2, label %3
i32 3, label %10
i32 1, label %14
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3
%9 = tail call i32 @printFilesWithPermisions(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @printFilesPrefixMatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %12)
br label %18
14: ; preds = %2
%15 = tail call i32 @printFiles(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %3, %16, %14, %10, %8
%19 = phi i32 [ %9, %8 ], [ %13, %10 ], [ %15, %14 ], [ -1, %16 ], [ 0, %3 ]
ret i32 %19
}