#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ analyze(int /*<<< orphan*/, int);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ read_images(int /*<<< orphan*/ *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ test_images(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    exit(1);
  }
  int load = 0;
  int save = 0;
  if (strncmp(argv[1], "-l", 2) == 0) {
    load = 1;
  } else if (strncmp(argv[1], "-s", 2) == 0) {
    save = 1;
  }
  if (save) {
    FILE *fp_source = fopen(argv[2], "rb");
    assert(fp_source != NULL);
    analyze(read_images(fp_source), 32);
    fclose(fp_source);
  } else if (load) {
    FILE *fp_test = fopen(argv[2], "rb");
    assert(fp_test != NULL);
    test_images(fp_test);
    fclose(fp_test);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11aa <main+0x2a>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe39(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11e7 <main+0x67>
movl   $0x1,-0x14(%rbp)
jmp    1216 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1211 <main+0x91>
movl   $0x1,-0x18(%rbp)
jmp    1216 <main+0x96>
cmpl   $0x0,-0x18(%rbp)
je     126d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd7(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1050 <read_images@plt>
mov    %eax,%edi
mov    $0x20,%esi
call   1060 <analyze@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12b8 <main+0x138>
cmpl   $0x0,-0x14(%rbp)
je     12b3 <main+0x133>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd80(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <test_images@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12b8 <main+0x138>
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jne    1234 <main+0xb4>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe68(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f8 <main+0x78>
mov    0x8(%rbx),%rdi
lea    0xe51(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1229 <main+0xa9>
mov    0x10(%rbx),%rdi
lea    0xe3a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1050 <read_images@plt>
mov    %eax,%edi
mov    $0x20,%esi
call   1060 <analyze@plt>
jmp    1221 <main+0xa1>
mov    0x10(%rbx),%rdi
lea    0xe03(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   10a0 <test_images@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-l\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"rb\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
store i32 0, i32* %6
store i32 0, i32* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 1, i32* %6
br label %29
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strncmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 1, i32* %7
br label %28
28: ; preds = %27, %21
br label %29
29: ; preds = %28, %20
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %8
%37 = load i32*, i32** %8
%38 = icmp ne i32* %37, null
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i32*, i32** %8
%42 = call i32 @read_images(i32* %41)
%43 = call i32 @analyze(i32 %42, i32 32)
%44 = load i32*, i32** %8
%45 = call i32 @fclose(i32* %44)
br label %63
46: ; preds = %29
%47 = load i32, i32* %6
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %62
49: ; preds = %46
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %53, i32** %9
%54 = load i32*, i32** %9
%55 = icmp ne i32* %54, null
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = load i32*, i32** %9
%59 = call i32 @test_images(i32* %58)
%60 = load i32*, i32** %9
%61 = call i32 @fclose(i32* %60)
br label %62
62: ; preds = %49, %46
br label %63
63: ; preds = %62, %32
%64 = load i32, i32* @EXIT_SUCCESS
ret i32 %64
}

LLVM IR (-O2):
@.str = [3 x i8] c"-l\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"rb\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i32* %18, null
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @read_images(i32* %18)
%23 = tail call i32 @analyze(i32 %22, i32 32)
br label %32
24: ; preds = %6
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32* %27, null
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call i32 @test_images(i32* %27)
br label %32
32: ; preds = %15, %24
%33 = phi i32* [ %27, %24 ], [ %18, %15 ]
%34 = tail call i32 @fclose(i32* %33)
br label %35
35: ; preds = %32, %11
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}