#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 */
scalar_t__ compress(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ search(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int rc = 0;
  char *exec = NULL, *action = NULL, *input = NULL;
  char *filename = NULL, *outputname = NULL;
  exec = argv[0];
  if (argc < 2) {
    usage(exec);
    rc = 1;
    goto cleanup;
  }
  action = argv[1];
  if (strcmp(action, "-h") == 0 || strcmp(action, "--help") == 0) {
    usage(exec);
    rc = 1;
    goto cleanup;
  } else if (strcmp(action, "-s") == 0 || strcmp(action, "--search") == 0) {
    if (argc < 4) {
      usage(exec);
      rc = 1;
      goto cleanup;
    }
    filename = argv[2];
    input = argv[3];
    if (search(filename, input) != 0) {
      rc = 1;
      goto cleanup;
    }
  } else if (strcmp(action, "-c") == 0 || strcmp(action, "--compress") == 0) {
    if (argc < 3) {
      usage(exec);
      rc = 1;
      goto cleanup;
    }
    filename = argv[2];
    outputname = argv[3];
    if (compress(filename, outputname) != 0) {
      rc = 1;
      goto cleanup;
    }
  } else {
    printf("Invalid action %s\n", action);
    rc = 1;
    goto cleanup;
  }
cleanup:
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bf <main+0x6f>
mov    -0x20(%rbp),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11ff <main+0xaf>
mov    -0x28(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1214 <main+0xc4>
mov    -0x20(%rbp),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
mov    -0x28(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1248 <main+0xf8>
mov    -0x28(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12a7 <main+0x157>
cmpl   $0x4,-0x8(%rbp)
jge    1267 <main+0x117>
mov    -0x20(%rbp),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <search@plt>
cmp    $0x0,%rax
je     12a2 <main+0x152>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
jmp    135b <main+0x20b>
mov    -0x28(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12db <main+0x18b>
mov    -0x28(%rbp),%rdi
lea    0xd4d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    133a <main+0x1ea>
cmpl   $0x3,-0x8(%rbp)
jge    12fa <main+0x1aa>
mov    -0x20(%rbp),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <compress@plt>
cmp    $0x0,%rax
je     1335 <main+0x1e5>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
jmp    1356 <main+0x206>
mov    -0x28(%rbp),%rsi
lea    0xcdf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    1365 <main+0x215>
jmp    135b <main+0x20b>
jmp    1360 <main+0x210>
jmp    1365 <main+0x215>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%r14
cmp    $0x1,%edi
jle    1212 <main+0xc2>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%r15
lea    0xe8d(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1212 <main+0xc2>
lea    0xe78(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1212 <main+0xc2>
lea    0xe6b(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11f9 <main+0xa9>
lea    0xe5a(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11f9 <main+0xa9>
lea    0xe4f(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     120d <main+0xbd>
lea    0xe3e(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     120d <main+0xbd>
lea    0xe35(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
jmp    121a <main+0xca>
cmp    $0x3,%ebp
jbe    1212 <main+0xc2>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <search@plt>
jmp    1237 <main+0xe7>
cmp    $0x2,%ebp
ja     122a <main+0xda>
mov    %r14,%rdi
call   1070 <usage@plt>
mov    $0x1,%al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1030 <compress@plt>
test   %rax,%rax
setne  %al
jmp    121c <main+0xcc>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [9 x i8] c"--search\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [11 x i8] c"--compress\00"
@.str.6 = [19 x i8] c"Invalid action %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
store i8* %14, i8** %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %7
%19 = call i32 @usage(i8* %18)
store i32 1, i32* %6
br label %94
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %20
%28 = load i8*, i8** %8
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27, %20
%32 = load i8*, i8** %7
%33 = call i32 @usage(i8* %32)
store i32 1, i32* %6
br label %94
34: ; preds = %27
%35 = load i8*, i8** %8
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %8
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %61
42: ; preds = %38, %34
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 4
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i8*, i8** %7
%47 = call i32 @usage(i8* %46)
store i32 1, i32* %6
br label %94
48: ; preds = %42
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
store i8* %51, i8** %10
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 3
%54 = load i8*, i8** %53
store i8* %54, i8** %9
%55 = load i8*, i8** %10
%56 = load i8*, i8** %9
%57 = call i64 @search(i8* %55, i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %48
store i32 1, i32* %6
br label %94
60: ; preds = %48
br label %92
61: ; preds = %38
%62 = load i8*, i8** %8
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = load i8*, i8** %8
%67 = call i64 @strcmp(i8* %66, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %88
69: ; preds = %65, %61
%70 = load i32, i32* %4
%71 = icmp slt i32 %70, 3
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i8*, i8** %7
%74 = call i32 @usage(i8* %73)
store i32 1, i32* %6
br label %94
75: ; preds = %69
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 2
%78 = load i8*, i8** %77
store i8* %78, i8** %10
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 3
%81 = load i8*, i8** %80
store i8* %81, i8** %11
%82 = load i8*, i8** %10
%83 = load i8*, i8** %11
%84 = call i64 @compress(i8* %82, i8* %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %75
store i32 1, i32* %6
br label %94
87: ; preds = %75
br label %91
88: ; preds = %65
%89 = load i8*, i8** %8
%90 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %89)
store i32 1, i32* %6
br label %94
91: ; preds = %87
br label %92
92: ; preds = %91, %60
br label %93
93: ; preds = %92
br label %94
94: ; preds = %93, %88, %86, %72, %59, %45, %31, %17
%95 = load i32, i32* %6
ret i32 %95
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [9 x i8] c"--search\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [11 x i8] c"--compress\00"
@.str.6 = [19 x i8] c"Invalid action %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @usage(i8* %3)
br label %53
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %7
%16 = tail call i32 @usage(i8* %3)
br label %53
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %20, %17
%24 = icmp ult i32 %0, 4
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @usage(i8* %3)
br label %53
27: ; preds = %23
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i64 @search(i8* %29, i8* %31)
%33 = icmp ne i64 %32, 0
br label %53
34: ; preds = %20
%35 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %37, %34
%41 = icmp ult i32 %0, 3
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = tail call i32 @usage(i8* %3)
br label %53
44: ; preds = %40
%45 = getelementptr inbounds i8*, i8** %1, i64 2
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8*, i8** %1, i64 3
%48 = load i8*, i8** %47
%49 = tail call i64 @compress(i8* %46, i8* %48)
%50 = icmp ne i64 %49, 0
br label %53
51: ; preds = %37
%52 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %9)
br label %53
53: ; preds = %44, %27, %51, %42, %25, %15, %5
%54 = phi i1 [ true, %5 ], [ true, %15 ], [ true, %25 ], [ true, %42 ], [ true, %51 ], [ %33, %27 ], [ %50, %44 ]
%55 = zext i1 %54 to i32
ret i32 %55
}