#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
void do_help(int man) {
  puts("Usage: elf2ppm [-o out.ppm] image.elf [image2.elf ...]");
  if (man) {
    puts("");
    puts("  image.elf should be a binary file in ELF format, as");
    puts("produced by the fungasm assembler. The elf2ppm program will");
    puts("convert the ELF file to a PPM (Portable Pixelmap) image,");
    puts("512 pixels on a side, graphically representing the memory");
    puts("layout of the binary image.");
    puts("  Cells that are part of a section in the ELF file");
    puts("will be colored according to their octal value; for example,");
    puts("a cell whose initial octal value is 777000 will be colored");
    puts("with the RGB hex value (#77,#70,#00), a brownish shade.");
    puts("  Cells that are not part of the ELF image will be colored");
    puts("with the RGB hex value (#FF,#FF,#FF), or white, a color");
    puts("which is easily distinguished from any octal value.");
    puts("  Input files that are not in ELF format will be read");
    puts("as plain ASCII files; therefore, elf2ppm kernel.elf hello.b93");
    puts("will show the kernel and a \"hello world\" program together");
    puts("in the same memory image.");
  }
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<do_help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x4(%rbp)
je     120d <do_help+0xed>
lea    0xf99(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf98(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
lea    0xfcf(%rip),%rdi
call   1030 <puts@plt>
lea    0x1000(%rip),%rdi
call   1030 <puts@plt>
lea    0x102f(%rip),%rdi
call   1030 <puts@plt>
lea    0x105b(%rip),%rdi
call   1030 <puts@plt>
lea    0x108a(%rip),%rdi
call   1030 <puts@plt>
lea    0x10b6(%rip),%rdi
call   1030 <puts@plt>
lea    0x10de(%rip),%rdi
call   1030 <puts@plt>
lea    0x1108(%rip),%rdi
call   1030 <puts@plt>
lea    0x113a(%rip),%rdi
call   1030 <puts@plt>
lea    0x1168(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<do_help>:
push   %rbx
mov    %edi,%ebx
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
je     1211 <do_help+0xe1>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xedf(%rip),%rdi
call   1040 <puts@plt>
lea    0xf09(%rip),%rdi
call   1040 <puts@plt>
lea    0xf39(%rip),%rdi
call   1040 <puts@plt>
lea    0xf66(%rip),%rdi
call   1040 <puts@plt>
lea    0xf94(%rip),%rdi
call   1040 <puts@plt>
lea    0xfa4(%rip),%rdi
call   1040 <puts@plt>
lea    0xfcb(%rip),%rdi
call   1040 <puts@plt>
lea    0xffc(%rip),%rdi
call   1040 <puts@plt>
lea    0x102b(%rip),%rdi
call   1040 <puts@plt>
lea    0x1057(%rip),%rdi
call   1040 <puts@plt>
lea    0x1086(%rip),%rdi
call   1040 <puts@plt>
lea    0x10b2(%rip),%rdi
call   1040 <puts@plt>
lea    0x10da(%rip),%rdi
call   1040 <puts@plt>
lea    0x1104(%rip),%rdi
call   1040 <puts@plt>
lea    0x1136(%rip),%rdi
call   1040 <puts@plt>
lea    0x1164(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"Usage: elf2ppm [-o out.ppm] image.elf [image2.elf ...]\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [54 x i8] c" image.elf should be a binary file in ELF format, as\00"
@.str.3 = [60 x i8] c"produced by the fungasm assembler. The elf2ppm program will\00"
@.str.4 = [57 x i8] c"convert the ELF file to a PPM (Portable Pixelmap) image,\00"
@.str.5 = [58 x i8] c"512 pixels on a side, graphically representing the memory\00"
@.str.6 = [28 x i8] c"layout of the binary image.\00"
@.str.7 = [51 x i8] c" Cells that are part of a section in the ELF file\00"
@.str.8 = [61 x i8] c"will be colored according to their octal value; for example,\00"
@.str.9 = [59 x i8] c"a cell whose initial octal value is 777000 will be colored\00"
@.str.10 = [56 x i8] c"with the RGB hex value (,,), a brownish shade.\00"
@.str.11 = [59 x i8] c" Cells that are not part of the ELF image will be colored\00"
@.str.12 = [56 x i8] c"with the RGB hex value (#FF,#FF,#FF), or white, a color\00"
@.str.13 = [52 x i8] c"which is easily distinguished from any octal value.\00"
@.str.14 = [54 x i8] c" Input files that are not in ELF format will be read\00"
@.str.15 = [62 x i8] c"as plain ASCII files; therefore, elf2ppm kernel.elf hello.b93\00"
@.str.16 = [58 x i8] c"will show the kernel and a \22hello world\22 program together\00"
@.str.17 = [26 x i8] c"in the same memory image.\00"
@EXIT_FAILURE = global i32 0
define void @do_help(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @puts(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %24
6: ; preds = %1
%7 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @puts(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 @puts(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.10, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0))
%18 = call i32 @puts(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
%19 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.13, i64 0, i64 0))
%20 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.14, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.15, i64 0, i64 0))
%22 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.16, i64 0, i64 0))
%23 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0))
br label %24
24: ; preds = %6, %1
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
@.str = [55 x i8] c"Usage: elf2ppm [-o out.ppm] image.elf [image2.elf ...]\00"
@.str.2 = [54 x i8] c" image.elf should be a binary file in ELF format, as\00"
@.str.3 = [60 x i8] c"produced by the fungasm assembler. The elf2ppm program will\00"
@.str.4 = [57 x i8] c"convert the ELF file to a PPM (Portable Pixelmap) image,\00"
@.str.5 = [58 x i8] c"512 pixels on a side, graphically representing the memory\00"
@.str.6 = [28 x i8] c"layout of the binary image.\00"
@.str.7 = [51 x i8] c" Cells that are part of a section in the ELF file\00"
@.str.8 = [61 x i8] c"will be colored according to their octal value; for example,\00"
@.str.9 = [59 x i8] c"a cell whose initial octal value is 777000 will be colored\00"
@.str.10 = [56 x i8] c"with the RGB hex value (,,), a brownish shade.\00"
@.str.11 = [59 x i8] c" Cells that are not part of the ELF image will be colored\00"
@.str.12 = [56 x i8] c"with the RGB hex value (#FF,#FF,#FF), or white, a color\00"
@.str.13 = [52 x i8] c"which is easily distinguished from any octal value.\00"
@.str.14 = [54 x i8] c" Input files that are not in ELF format will be read\00"
@.str.15 = [62 x i8] c"as plain ASCII files; therefore, elf2ppm kernel.elf hello.b93\00"
@.str.16 = [58 x i8] c"will show the kernel and a \22hello world\22 program together\00"
@.str.17 = [26 x i8] c"in the same memory image.\00"
@EXIT_FAILURE = global i32 0
define void @do_help(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %0, 0
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.10, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.13, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.14, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.15, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.16, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0))
br label %22
22: ; preds = %4, %1
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
}