#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*/ printf(char *);
int /*<<< orphan*/ scan_dir(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  ;
  char keyword[512] = {0};
  char path[512] = {0};
  if (argc <= 1) {
    printf("Please set keyword\n");
    return -1;
  } else {
    strcpy(keyword, argv[1]);
  }
  if (argc <= 2) {
    strcpy(path, ".");
  } else {
    strcpy(path, argv[2]);
  }
  scan_dir(keyword, path, 0);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
cmpl   $0x1,-0x8(%rbp)
jg     11a1 <main+0x61>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <main+0xc7>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jg     11d7 <main+0x97>
lea    -0x410(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <main+0xab>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
lea    -0x410(%rbp),%rsi
xor    %edx,%edx
call   1040 <scan_dir@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsp,%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x200(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
cmp    $0x1,%ebp
jg     1189 <main+0x49>
lea    0xe85(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
jmp    11c6 <main+0x86>
mov    0x8(%rbx),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
cmp    $0x2,%ebp
jne    11a3 <main+0x63>
lea    0xe5f(%rip),%rsi
jmp    11a7 <main+0x67>
mov    0x10(%rbx),%rsi
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    %rbp,%rsi
xor    %edx,%edx
call   1040 <scan_dir@plt>
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [2 x i8] c".\00"
@str = [19 x i8] c"Please set keyword\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %22
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %5, i8* %12)
%14 = icmp eq i32 %0, 2
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
br label %18
18: ; preds = %10, %15
%19 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %10 ]
%20 = call i32 @strcpy(i8* %6, i8* %19)
%21 = call i32 @scan_dir(i8* %5, i8* %6, i32 0)
br label %22
22: ; preds = %18, %8
%23 = phi i32 [ -1, %8 ], [ 0, %18 ]
ret i32 %23
}