#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ removeComments(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  if (argc != 3) {
    printf("Chybne parametry\n");
    return 1;
  }
  in = fopen(argv[1], "r");
  if (in == NULL) {
    printf("Nelze otevrit vstup\n");
    return 2;
  }
  out = fopen(argv[2], "w");
  if (out == NULL) {
    printf("Nelze otevrit vystup\n");
    fclose(in);
    return 3;
  }
  removeComments(in, out);
  fclose(in);
  fclose(out);
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
je     1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b3 <main+0x73>
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f7 <main+0xb7>
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x3,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <removeComments@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    119b <main+0x5b>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ae <main+0x6e>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe93(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c1 <main+0x81>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <removeComments@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    11da <main+0x9a>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    11da <main+0x9a>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%eax
jmp    11da <main+0x9a>
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Chybne parametry\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Nelze otevrit vstup\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [22 x i8] c"Nelze otevrit vystup\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %40
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %40
21: ; preds = %12
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32*, i32** %6
%31 = call i32 @fclose(i32* %30)
store i32 3, i32* %3
br label %40
32: ; preds = %21
%33 = load i32*, i32** %6
%34 = load i32*, i32** %7
%35 = call i32 @removeComments(i32* %33, i32* %34)
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
%38 = load i32*, i32** %7
%39 = call i32 @fclose(i32* %38)
store i32 0, i32* %3
br label %40
40: ; preds = %32, %28, %19, %10
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@str = [21 x i8] c"Nelze otevrit vystup\00"
@str.5 = [20 x i8] c"Nelze otevrit vstup\00"
@str.6 = [17 x i8] c"Chybne parametry\00"
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 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %25
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
br label %25
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @fclose(i32* %9)
br label %25
21: ; preds = %13
%22 = tail call i32 @removeComments(i32* %9, i32* %16)
%23 = tail call i32 @fclose(i32* %9)
%24 = tail call i32 @fclose(i32* %16)
br label %25
25: ; preds = %21, %18, %11, %4
%26 = phi i32 [ 1, %4 ], [ 2, %11 ], [ 3, %18 ], [ 0, %21 ]
ret i32 %26
}