#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*/ _dcontent_from_file(char *);
scalar_t__ _dcontent_to_file(char *, char *);
char *bmp_decode(char *);
int /*<<< orphan*/ bmp_encode(char *, int /*<<< orphan*/, char *);
char *ppm_decode(char *);
int /*<<< orphan*/ ppm_encode(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int args_len, char *args[]) {
  if (args_len == 5 && args[1][1] == 'e') {
    char *host_filename = args[2];
    char *secret_filename = args[3];
    char *resulting_filename = args[4];
    int host_filename_len = strlen(host_filename);
    if (host_filename[host_filename_len - 1] == 'm' &&
        host_filename[host_filename_len - 2] == 'p' &&
        host_filename[host_filename_len - 3] == 'p') {
      printf("\n>>> PPM: TRYING TO CREATE AN IMAGE WITH SECRET...\n");
      ppm_encode(host_filename, _dcontent_from_file(secret_filename),
                 resulting_filename);
    } else if (host_filename[host_filename_len - 1] == 'p' &&
               host_filename[host_filename_len - 2] == 'm' &&
               host_filename[host_filename_len - 3] == 'b') {
      printf("\n>>> BMP: TRYING TO CREATE AN IMAGE WITH SECRET...\n");
      bmp_encode(host_filename, _dcontent_from_file(secret_filename),
                 resulting_filename);
    } else {
      printf("Unsupported file type: should be .ppm or .bmp.\n");
      return 1;
    }
    return 0;
  } else if (args_len == 4 && args[1][1] == 'd') {
    char *host_filename = args[2];
    char *secret_filename = args[3];
    int host_filename_len = strlen(host_filename);
    if (host_filename[host_filename_len - 1] == 'm' &&
        host_filename[host_filename_len - 2] == 'p' &&
        host_filename[host_filename_len - 3] == 'p') {
      printf("\n>>> PPM: READING SECRET INSIDE THE CREATED IMAGE...\n");
      char *message = ppm_decode(host_filename);
      if (strlen(message)) {
        if (_dcontent_to_file(secret_filename, message)) {
          printf("Discovered message file: %s\n", secret_filename);
        } else {
          printf("Failed to write at %s file. Here's the message then:\n\n%s\n",
                 secret_filename, message);
        }
      } else {
        printf("No message could be found.\n");
        return 1;
      }
    } else if (host_filename[host_filename_len - 1] == 'p' &&
               host_filename[host_filename_len - 2] == 'm' &&
               host_filename[host_filename_len - 3] == 'b') {
      printf("\n>>> BMP: READING SECRET INSIDE THE CREATED IMAGE...\n");
      char *message = bmp_decode(host_filename);
      if (strlen(message)) {
        if (_dcontent_to_file(secret_filename, message)) {
          printf("Discovered message file: %s\n", secret_filename);
        } else {
          printf("Failed to write at %s file. Here's the message then:\n\n%s\n",
                 secret_filename, message);
        }
      } else {
        printf("No message could be found.\n");
        return 1;
      }
    } else {
      printf("Unsupported file type: should be .ppm or .bmp.\n");
      return 1;
    }
    return 0;
  } else {
    printf("Invalid flag. Check the readme.md file in the repository for cool "
           "instructions.\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    1312 <main+0x192>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x65,%eax
jne    1312 <main+0x192>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    1266 <main+0xe6>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    1266 <main+0xe6>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    1266 <main+0xe6>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <_dcontent_from_file@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
mov    -0x28(%rbp),%rdx
call   1080 <ppm_encode@plt>
jmp    1306 <main+0x186>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    12e7 <main+0x167>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    12e7 <main+0x167>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x62,%eax
jne    12e7 <main+0x167>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <_dcontent_from_file@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
mov    -0x28(%rbp),%rdx
call   10a0 <bmp_encode@plt>
jmp    1301 <main+0x181>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    155b <main+0x3db>
jmp    1306 <main+0x186>
movl   $0x0,-0x4(%rbp)
jmp    155b <main+0x3db>
cmpl   $0x4,-0x8(%rbp)
jne    1546 <main+0x3c6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    1546 <main+0x3c6>
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
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    1438 <main+0x2b8>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    1438 <main+0x2b8>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    1438 <main+0x2b8>
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1070 <ppm_decode@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
je     1419 <main+0x299>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1090 <_dcontent_to_file@plt>
cmp    $0x0,%rax
je     13fe <main+0x27e>
mov    -0x40(%rbp),%rsi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1414 <main+0x294>
mov    -0x40(%rbp),%rsi
mov    -0x50(%rbp),%rdx
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1433 <main+0x2b3>
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    155b <main+0x3db>
jmp    153a <main+0x3ba>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    151b <main+0x39b>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    151b <main+0x39b>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x62,%eax
jne    151b <main+0x39b>
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <bmp_decode@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
je     14fc <main+0x37c>
mov    -0x40(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1090 <_dcontent_to_file@plt>
cmp    $0x0,%rax
je     14e1 <main+0x361>
mov    -0x40(%rbp),%rsi
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f7 <main+0x377>
mov    -0x40(%rbp),%rsi
mov    -0x58(%rbp),%rdx
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1516 <main+0x396>
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    155b <main+0x3db>
jmp    1535 <main+0x3b5>
lea    0xb46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    155b <main+0x3db>
jmp    153a <main+0x3ba>
movl   $0x0,-0x4(%rbp)
jmp    155b <main+0x3db>
lea    0xc2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x4,%edi
je     121e <main+0x8e>
cmp    $0x5,%edi
jne    1278 <main+0xe8>
mov    0x8(%rsi),%rax
cmpb   $0x65,0x1(%rax)
jne    1278 <main+0xe8>
mov    0x10(%rsi),%rbp
mov    0x18(%rsi),%rbx
mov    0x20(%rsi),%r14
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
mov    -0x1(%rax,%rbp,1),%cl
cmp    $0x70,%cl
je     1284 <main+0xf4>
cmp    $0x6d,%cl
jne    1311 <main+0x181>
cmpb   $0x70,-0x2(%rax,%rbp,1)
jne    1311 <main+0x181>
cmpb   $0x70,-0x3(%rax,%rbp,1)
jne    1311 <main+0x181>
lea    0xf91(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <_dcontent_from_file@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1090 <ppm_encode@plt>
xor    %ebp,%ebp
jmp    1322 <main+0x192>
mov    0x8(%rsi),%rax
cmpb   $0x64,0x1(%rax)
jne    1278 <main+0xe8>
mov    0x10(%rsi),%rbp
mov    0x18(%rsi),%rbx
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
mov    -0x1(%rax,%rbp,1),%cl
cmp    $0x70,%cl
je     12bb <main+0x12b>
cmp    $0x6d,%cl
jne    1311 <main+0x181>
cmpb   $0x70,-0x2(%rax,%rbp,1)
jne    1311 <main+0x181>
cmpb   $0x70,-0x3(%rax,%rbp,1)
jne    1311 <main+0x181>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1080 <ppm_decode@plt>
jmp    12dd <main+0x14d>
lea    0xdd8(%rip),%rdi
jmp    1318 <main+0x188>
cmpb   $0x6d,-0x2(%rax,%rbp,1)
jne    1311 <main+0x181>
cmpb   $0x62,-0x3(%rax,%rbp,1)
jne    1311 <main+0x181>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <_dcontent_from_file@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   10b0 <bmp_encode@plt>
xor    %ebp,%ebp
jmp    1322 <main+0x192>
cmpb   $0x6d,-0x2(%rax,%rbp,1)
jne    1311 <main+0x181>
cmpb   $0x62,-0x3(%rax,%rbp,1)
jne    1311 <main+0x181>
lea    0xdd7(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <bmp_decode@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
je     1329 <main+0x199>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <_dcontent_to_file@plt>
test   %rax,%rax
je     1332 <main+0x1a2>
lea    0xcfd(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1322 <main+0x192>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xde1(%rip),%rdi
jmp    1318 <main+0x188>
lea    0xce4(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1322 <main+0x192>

LLVM IR (-O0):
@.str = [52 x i8] c"\0A>>> PPM: TRYING TO CREATE AN IMAGE WITH SECRET...\0A\00"
@.str.1 = [52 x i8] c"\0A>>> BMP: TRYING TO CREATE AN IMAGE WITH SECRET...\0A\00"
@.str.2 = [48 x i8] c"Unsupported file type: should be .ppm or .bmp.\0A\00"
@.str.3 = [54 x i8] c"\0A>>> PPM: READING SECRET INSIDE THE CREATED IMAGE...\0A\00"
@.str.4 = [29 x i8] c"Discovered message file: %s\0A\00"
@.str.5 = [58 x i8] c"Failed to write at %s file. Here's the message then:\0A\0A%s\0A\00"
@.str.6 = [28 x i8] c"No message could be found.\0A\00"
@.str.7 = [54 x i8] c"\0A>>> BMP: READING SECRET INSIDE THE CREATED IMAGE...\0A\00"
@.str.8 = [81 x i8] c"Invalid flag. Check the readme.md file in the repository for cool instructions.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 5
br i1 %16, label %17, label %108
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 101
br i1 %24, label %25, label %108
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
store i8* %31, i8** %7
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 4
%34 = load i8*, i8** %33
store i8* %34, i8** %8
%35 = load i8*, i8** %6
%36 = call i32 @strlen(i8* %35)
store i32 %36, i32* %9
%37 = load i8*, i8** %6
%38 = load i32, i32* %9
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 109
br i1 %44, label %45, label %70
45: ; preds = %25
%46 = load i8*, i8** %6
%47 = load i32, i32* %9
%48 = sub nsw i32 %47, 2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 112
br i1 %53, label %54, label %70
54: ; preds = %45
%55 = load i8*, i8** %6
%56 = load i32, i32* %9
%57 = sub nsw i32 %56, 3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 112
br i1 %62, label %63, label %70
63: ; preds = %54
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%65 = load i8*, i8** %6
%66 = load i8*, i8** %7
%67 = call i32 @_dcontent_from_file(i8* %66)
%68 = load i8*, i8** %8
%69 = call i32 @ppm_encode(i8* %65, i32 %67, i8* %68)
br label %107
70: ; preds = %54, %45, %25
%71 = load i8*, i8** %6
%72 = load i32, i32* %9
%73 = sub nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %71, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 112
br i1 %78, label %79, label %104
79: ; preds = %70
%80 = load i8*, i8** %6
%81 = load i32, i32* %9
%82 = sub nsw i32 %81, 2
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %80, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 109
br i1 %87, label %88, label %104
88: ; preds = %79
%89 = load i8*, i8** %6
%90 = load i32, i32* %9
%91 = sub nsw i32 %90, 3
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %89, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 98
br i1 %96, label %97, label %104
97: ; preds = %88
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%99 = load i8*, i8** %6
%100 = load i8*, i8** %7
%101 = call i32 @_dcontent_from_file(i8* %100)
%102 = load i8*, i8** %8
%103 = call i32 @bmp_encode(i8* %99, i32 %101, i8* %102)
br label %106
104: ; preds = %88, %79, %70
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %233
106: ; preds = %97
br label %107
107: ; preds = %106, %63
store i32 0, i32* %3
br label %233
108: ; preds = %17, %2
%109 = load i32, i32* %4
%110 = icmp eq i32 %109, 4
br i1 %110, label %111, label %231
111: ; preds = %108
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 1
%114 = load i8*, i8** %113
%115 = getelementptr inbounds i8, i8* %114, i64 1
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 100
br i1 %118, label %119, label %231
119: ; preds = %111
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 2
%122 = load i8*, i8** %121
store i8* %122, i8** %10
%123 = load i8**, i8*** %5
%124 = getelementptr inbounds i8*, i8** %123, i64 3
%125 = load i8*, i8** %124
store i8* %125, i8** %11
%126 = load i8*, i8** %10
%127 = call i32 @strlen(i8* %126)
store i32 %127, i32* %12
%128 = load i8*, i8** %10
%129 = load i32, i32* %12
%130 = sub nsw i32 %129, 1
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i8, i8* %128, i64 %131
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 109
br i1 %135, label %136, label %177
136: ; preds = %119
%137 = load i8*, i8** %10
%138 = load i32, i32* %12
%139 = sub nsw i32 %138, 2
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %137, i64 %140
%142 = load i8, i8* %141
%143 = sext i8 %142 to i32
%144 = icmp eq i32 %143, 112
br i1 %144, label %145, label %177
145: ; preds = %136
%146 = load i8*, i8** %10
%147 = load i32, i32* %12
%148 = sub nsw i32 %147, 3
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i8, i8* %146, i64 %149
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = icmp eq i32 %152, 112
br i1 %153, label %154, label %177
154: ; preds = %145
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%156 = load i8*, i8** %10
%157 = call i8* @ppm_decode(i8* %156)
store i8* %157, i8** %13
%158 = load i8*, i8** %13
%159 = call i32 @strlen(i8* %158)
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %174
161: ; preds = %154
%162 = load i8*, i8** %11
%163 = load i8*, i8** %13
%164 = call i64 @_dcontent_to_file(i8* %162, i8* %163)
%165 = icmp ne i64 %164, 0
br i1 %165, label %166, label %169
166: ; preds = %161
%167 = load i8*, i8** %11
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %167)
br label %173
169: ; preds = %161
%170 = load i8*, i8** %11
%171 = load i8*, i8** %13
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %170, i8* %171)
br label %173
173: ; preds = %169, %166
br label %176
174: ; preds = %154
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %233
176: ; preds = %173
br label %230
177: ; preds = %145, %136, %119
%178 = load i8*, i8** %10
%179 = load i32, i32* %12
%180 = sub nsw i32 %179, 1
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds i8, i8* %178, i64 %181
%183 = load i8, i8* %182
%184 = sext i8 %183 to i32
%185 = icmp eq i32 %184, 112
br i1 %185, label %186, label %227
186: ; preds = %177
%187 = load i8*, i8** %10
%188 = load i32, i32* %12
%189 = sub nsw i32 %188, 2
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i8, i8* %187, i64 %190
%192 = load i8, i8* %191
%193 = sext i8 %192 to i32
%194 = icmp eq i32 %193, 109
br i1 %194, label %195, label %227
195: ; preds = %186
%196 = load i8*, i8** %10
%197 = load i32, i32* %12
%198 = sub nsw i32 %197, 3
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i8, i8* %196, i64 %199
%201 = load i8, i8* %200
%202 = sext i8 %201 to i32
%203 = icmp eq i32 %202, 98
br i1 %203, label %204, label %227
204: ; preds = %195
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0))
%206 = load i8*, i8** %10
%207 = call i8* @bmp_decode(i8* %206)
store i8* %207, i8** %14
%208 = load i8*, i8** %14
%209 = call i32 @strlen(i8* %208)
%210 = icmp ne i32 %209, 0
br i1 %210, label %211, label %224
211: ; preds = %204
%212 = load i8*, i8** %11
%213 = load i8*, i8** %14
%214 = call i64 @_dcontent_to_file(i8* %212, i8* %213)
%215 = icmp ne i64 %214, 0
br i1 %215, label %216, label %219
216: ; preds = %211
%217 = load i8*, i8** %11
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %217)
br label %223
219: ; preds = %211
%220 = load i8*, i8** %11
%221 = load i8*, i8** %14
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %220, i8* %221)
br label %223
223: ; preds = %219, %216
br label %226
224: ; preds = %204
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %233
226: ; preds = %223
br label %229
227: ; preds = %195, %186, %177
%228 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %233
229: ; preds = %226
br label %230
230: ; preds = %229, %176
store i32 0, i32* %3
br label %233
231: ; preds = %111, %108
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %233
233: ; preds = %231, %230, %227, %224, %174, %107, %104
%234 = load i32, i32* %3
ret i32 %234
}

LLVM IR (-O2):
@.str.4 = [29 x i8] c"Discovered message file: %s\0A\00"
@.str.5 = [58 x i8] c"Failed to write at %s file. Here's the message then:\0A\0A%s\0A\00"
@str = [80 x i8] c"Invalid flag. Check the readme.md file in the repository for cool instructions.\00"
@str.10 = [53 x i8] c"\0A>>> BMP: READING SECRET INSIDE THE CREATED IMAGE...\00"
@str.12 = [53 x i8] c"\0A>>> PPM: READING SECRET INSIDE THE CREATED IMAGE...\00"
@str.13 = [27 x i8] c"No message could be found.\00"
@str.14 = [47 x i8] c"Unsupported file type: should be .ppm or .bmp.\00"
@str.15 = [51 x i8] c"\0A>>> BMP: TRYING TO CREATE AN IMAGE WITH SECRET...\00"
@str.16 = [51 x i8] c"\0A>>> PPM: TRYING TO CREATE AN IMAGE WITH SECRET...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %125 [
i32 5, label %3
i32 4, label %55
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 101
br i1 %8, label %9, label %125
9: ; preds = %3
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 4
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %11)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %11, i64 %18
%20 = load i8, i8* %19
switch i8 %20, label %53 [
i8 109, label %21
i8 112, label %37
]
21: ; preds = %9
%22 = add nsw i32 %16, -2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %11, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 112
br i1 %26, label %27, label %53
27: ; preds = %21
%28 = add nsw i32 %16, -3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %11, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 112
br i1 %32, label %33, label %53
33: ; preds = %27
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.16, i64 0, i64 0))
%35 = tail call i32 @_dcontent_from_file(i8* %13)
%36 = tail call i32 @ppm_encode(i8* %11, i32 %35, i8* %15)
br label %127
37: ; preds = %9
%38 = add nsw i32 %16, -2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %11, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 109
br i1 %42, label %43, label %53
43: ; preds = %37
%44 = add nsw i32 %16, -3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %11, i64 %45
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 98
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%51 = tail call i32 @_dcontent_from_file(i8* %13)
%52 = tail call i32 @bmp_encode(i8* %11, i32 %51, i8* %15)
br label %127
53: ; preds = %9, %21, %27, %43, %37
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.14, i64 0, i64 0))
br label %127
55: ; preds = %2
%56 = getelementptr inbounds i8*, i8** %1, i64 1
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 100
br i1 %60, label %61, label %125
61: ; preds = %55
%62 = getelementptr inbounds i8*, i8** %1, i64 2
%63 = load i8*, i8** %62
%64 = getelementptr inbounds i8*, i8** %1, i64 3
%65 = load i8*, i8** %64
%66 = tail call i32 @strlen(i8* %63)
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %63, i64 %68
%70 = load i8, i8* %69
switch i8 %70, label %123 [
i8 109, label %71
i8 112, label %97
]
71: ; preds = %61
%72 = add nsw i32 %66, -2
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %63, i64 %73
%75 = load i8, i8* %74
%76 = icmp eq i8 %75, 112
br i1 %76, label %77, label %123
77: ; preds = %71
%78 = add nsw i32 %66, -3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %63, i64 %79
%81 = load i8, i8* %80
%82 = icmp eq i8 %81, 112
br i1 %82, label %83, label %123
83: ; preds = %77
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.12, i64 0, i64 0))
%85 = tail call i8* @ppm_decode(i8* %63)
%86 = tail call i32 @strlen(i8* %85)
%87 = icmp eq i32 %86, 0
br i1 %87, label %95, label %88
88: ; preds = %83
%89 = tail call i64 @_dcontent_to_file(i8* %65, i8* %85)
%90 = icmp eq i64 %89, 0
br i1 %90, label %93, label %91
91: ; preds = %88
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %127
93: ; preds = %88
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* %85)
br label %127
95: ; preds = %83
%96 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %127
97: ; preds = %61
%98 = add nsw i32 %66, -2
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %63, i64 %99
%101 = load i8, i8* %100
%102 = icmp eq i8 %101, 109
br i1 %102, label %103, label %123
103: ; preds = %97
%104 = add nsw i32 %66, -3
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %63, i64 %105
%107 = load i8, i8* %106
%108 = icmp eq i8 %107, 98
br i1 %108, label %109, label %123
109: ; preds = %103
%110 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.10, i64 0, i64 0))
%111 = tail call i8* @bmp_decode(i8* %63)
%112 = tail call i32 @strlen(i8* %111)
%113 = icmp eq i32 %112, 0
br i1 %113, label %121, label %114
114: ; preds = %109
%115 = tail call i64 @_dcontent_to_file(i8* %65, i8* %111)
%116 = icmp eq i64 %115, 0
br i1 %116, label %119, label %117
117: ; preds = %114
%118 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %127
119: ; preds = %114
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* %111)
br label %127
121: ; preds = %109
%122 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %127
123: ; preds = %61, %71, %77, %103, %97
%124 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.14, i64 0, i64 0))
br label %127
125: ; preds = %3, %2, %55
%126 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
br label %127
127: ; preds = %117, %119, %91, %93, %121, %95, %123, %53, %49, %33, %125
%128 = phi i32 [ 1, %125 ], [ 1, %53 ], [ 0, %49 ], [ 0, %33 ], [ 1, %95 ], [ 1, %121 ], [ 1, %123 ], [ 0, %93 ], [ 0, %91 ], [ 0, %119 ], [ 0, %117 ]
ret i32 %128
}