#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 atoi(char *);
int findStrings(char *, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int usage();
int main(int argc, char *argv[]) {
  int temp_return;
  temp_return = 0;
  if (argc == 1) {
    temp_return = usage();
  } else if (argc == 2) {
    temp_return = findStrings(argv[1], 4);
  } else if ((argc % 2) == 1) {
    printf("Invalid number of arguments!\n");
  } else if (((strcmp(argv[1], "-n")) == 0) && (argc == 4)) {
    temp_return = findStrings(argv[3], atoi(argv[2]));
  }
  if (temp_return == 1) {
    printf("Bad file!\n");
  }
  return temp_return;
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1186 <main+0x36>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x14(%rbp)
jmp    122d <main+0xdd>
cmpl   $0x2,-0x8(%rbp)
jne    11aa <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x4,%esi
call   1030 <findStrings@plt>
mov    %eax,-0x14(%rbp)
jmp    1228 <main+0xd8>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11cf <main+0x7f>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
jmp    1223 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <main+0xce>
cmpl   $0x4,-0x8(%rbp)
jne    121e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1030 <findStrings@plt>
mov    %eax,-0x14(%rbp)
jmp    1223 <main+0xd3>
jmp    1228 <main+0xd8>
jmp    122d <main+0xdd>
cmpl   $0x1,-0x14(%rbp)
jne    1243 <main+0xf3>
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
je     116c <main+0x1c>
mov    %edi,%ebp
cmp    $0x1,%edi
jne    1177 <main+0x27>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11c8 <main+0x78>
mov    0x8(%r14),%rdi
mov    $0x4,%esi
jmp    11c3 <main+0x73>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
jne    1195 <main+0x45>
xor    %ebx,%ebx
lea    0xe7a(%rip),%rdi
jmp    11db <main+0x8b>
mov    0x8(%r14),%rdi
lea    0xe60(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebx,%ebx
cmp    $0x4,%ebp
jne    11e0 <main+0x90>
test   %rax,%rax
jne    11e0 <main+0x90>
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rbx
call   1070 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <findStrings@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
jne    11e0 <main+0x90>
mov    $0x1,%ebx
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Invalid number of arguments!\0A\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [11 x i8] c"Bad file!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
store i32 %10, i32* %6
br label %46
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @findStrings(i8* %17, i32 4)
store i32 %18, i32* %6
br label %45
19: ; preds = %11
%20 = load i32, i32* %4
%21 = srem i32 %20, 2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %44
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %25
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
%42 = call i32 @findStrings(i8* %37, i32 %41)
store i32 %42, i32* %6
br label %43
43: ; preds = %34, %31, %25
br label %44
44: ; preds = %43, %23
br label %45
45: ; preds = %44, %14
br label %46
46: ; preds = %45, %9
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"-n\00"
@str = [10 x i8] c"Bad file!\00"
@str.3 = [29 x i8] c"Invalid number of arguments!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %9 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32 (...) @usage()
br label %26
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @findStrings(i8* %7, i32 4)
br label %26
9: ; preds = %2
%10 = srem i32 %0, 2
%11 = icmp eq i32 %10, 1
br i1 %11, label %29, label %12
12: ; preds = %9
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = icmp eq i32 %0, 4
%18 = and i1 %17, %16
br i1 %18, label %19, label %33
19: ; preds = %12
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = tail call i32 @findStrings(i8* %21, i32 %24)
br label %26
26: ; preds = %5, %19, %3
%27 = phi i32 [ %4, %3 ], [ %8, %5 ], [ %25, %19 ]
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %26, %9
%30 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), %26 ]
%31 = phi i32 [ 0, %9 ], [ 1, %26 ]
%32 = tail call i32 @puts(i8* dereferenceable(1) %30)
br label %33
33: ; preds = %29, %12, %26
%34 = phi i32 [ %27, %26 ], [ 0, %12 ], [ %31, %29 ]
ret i32 %34
}