#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 */
struct ppm {
  int dummy;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ FatalError(char *, ...);
int /*<<< orphan*/ decodePpm(struct ppm *);
int /*<<< orphan*/ free(struct ppm *);
struct ppm *ppm_read(char *);
int main(int argc, char *argv[]) {
  struct ppm *pic = NULL;
  if (argc != 2) {
    FatalError("Tento program potrebuje prave jeden argument, kterym je "
               "souboru typu PPM.\n");
  }
  if ((pic = ppm_read((argv[1]))) == NULL) {
    FatalError("Neni mozne nacist obrazek %s\n", argv[1]);
  }
  decodePpm(pic);
  free(pic);
  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)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1176 <main+0x36>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <FatalError@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <ppm_read@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1050 <FatalError@plt>
mov    -0x18(%rbp),%rdi
call   1030 <decodePpm@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
je     115a <main+0x1a>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <FatalError@plt>
mov    0x8(%r14),%rdi
call   1060 <ppm_read@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117d <main+0x3d>
mov    0x8(%r14),%rsi
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1050 <FatalError@plt>
mov    %rbx,%rdi
call   1030 <decodePpm@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ppm = type { i32 }
@.str = [75 x i8] c"Tento program potrebuje prave jeden argument, kterym je souboru typu PPM.\0A\00"
@.str.1 = [30 x i8] c"Neni mozne nacist obrazek %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ppm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.ppm* null, %struct.ppm** %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @FatalError(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call %struct.ppm* @ppm_read(i8* %14)
store %struct.ppm* %15, %struct.ppm** %6
%16 = icmp eq %struct.ppm* %15, null
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @FatalError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %17, %11
%23 = load %struct.ppm*, %struct.ppm** %6
%24 = call i32 @decodePpm(%struct.ppm* %23)
%25 = load %struct.ppm*, %struct.ppm** %6
%26 = call i32 @free(%struct.ppm* %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
%struct.ppm = type { i32 }
@.str = [75 x i8] c"Tento program potrebuje prave jeden argument, kterym je souboru typu PPM.\0A\00"
@.str.1 = [30 x i8] c"Neni mozne nacist obrazek %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @FatalError(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call %struct.ppm* @ppm_read(i8* %8)
%10 = icmp eq %struct.ppm* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 (i8*, ...) @FatalError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %6
%15 = tail call i32 @decodePpm(%struct.ppm* %9)
%16 = tail call i32 @free(%struct.ppm* %9)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}