#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processFile(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int i;
  if (argc < 3)
    usage(argv[0]);
  if (strcmp(argv[1], "") == 0) {
    printf("Error: the pattern to find is empty.\n");
    return EXIT_FAILURE;
  }
  for (i = 2; i < argc; i++) {
    processFile(argv[1], argv[i], argc - 2 == 1);
  }
  return EXIT_SUCCESS;
}


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)
cmpl   $0x3,-0x8(%rbp)
jge    116c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a7 <main+0x67>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fe <main+0xbe>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f2 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edx
call   1040 <processFile@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <main+0x6e>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
cmp    $0x2,%edi
jg     115b <main+0x1b>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xebe(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ab <main+0x6b>
mov    0x2e61(%rip),%r15
cmp    $0x3,%r14d
jl     11be <main+0x7e>
sete   %al
movzbl %al,%r12d
mov    %r14d,%r14d
mov    $0x2,%ebp
nopl   0x0(%rax)
mov    0x8(%rbx),%rdi
mov    (%rbx,%rbp,8),%rsi
mov    %r12d,%edx
call   1040 <processFile@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1190 <main+0x50>
jmp    11be <main+0x7e>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e22(%rip),%r15
mov    (%r15),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [38 x i8] c"Error: the pattern to find is empty.\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
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
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @usage(i8* %12)
br label %14
14: ; preds = %9, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %47
23: ; preds = %14
store i32 2, i32* %6
br label %24
24: ; preds = %42, %23
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %45
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 2
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
%41 = call i32 @processFile(i8* %31, i8* %36, i32 %40)
br label %42
42: ; preds = %28
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %24
45: ; preds = %24
%46 = load i32, i32* @EXIT_SUCCESS
store i32 %46, i32* %3
br label %47
47: ; preds = %45, %20
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [37 x i8] c"Error: the pattern to find is empty.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %7
%13 = icmp sgt i32 %0, 2
br i1 %13, label %14, label %28
14: ; preds = %12
%15 = icmp eq i32 %0, 3
%16 = zext i1 %15 to i32
%17 = zext i32 %0 to i64
br label %20
18: ; preds = %7
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %28
20: ; preds = %14, %20
%21 = phi i64 [ 2, %14 ], [ %26, %20 ]
%22 = load i8*, i8** %8
%23 = getelementptr inbounds i8*, i8** %1, i64 %21
%24 = load i8*, i8** %23
%25 = tail call i32 @processFile(i8* %22, i8* %24, i32 %16)
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %28, label %20
28: ; preds = %20, %12, %18
%29 = phi i32* [ @EXIT_FAILURE, %18 ], [ @EXIT_SUCCESS, %12 ], [ @EXIT_SUCCESS, %20 ]
%30 = load i32, i32* %29
ret i32 %30
}