#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 */
scalar_t__ CtiData(int /*<<< orphan*/ *, unsigned int *, unsigned int *);
scalar_t__ Vystup(int /*<<< orphan*/ *, int /*<<< orphan*/ *, unsigned int,
                  int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(unsigned char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  unsigned char fname[256] = {
      '\0',
  };
  unsigned char output[256] = {
      '\0',
  };
  scanf("%s", fname);
  scanf("%s", output);
  FILE *f_input = fopen(fname, "r");
  if (f_input == NULL) {
    printf("Nepodarilo se otevrit vstupni soubor: %s\n", fname);
    return 1;
  }
  FILE *f_output = fopen(output, "w");
  if (f_output == NULL) {
    printf("Nepodarilo se otevrit vystupni soubor: %s\n", output);
    return 2;
  }
  unsigned pocSlov, pocRadku;
  if (CtiData(f_input, &pocSlov, &pocRadku) != 0) {
    printf("Chyba pri volani funkce CtiData\n");
    return 3;
  }
  printf("V souboru %s je %d radku a %d slov\n", fname, pocRadku, pocSlov);
  rewind(f_input);
  int prekopirovatRadku;
  scanf("%d", &prekopirovatRadku);
  if (Vystup(f_input, f_output, pocRadku, prekopirovatRadku) != 0) {
    printf("Chyba pri volani funkce Vystup\n");
    return 4;
  }
  fclose(f_input);
  fclose(f_output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x110(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    -0x210(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    122b <main+0xab>
lea    -0x110(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1356 <main+0x1d6>
lea    -0x210(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x220(%rbp)
jne    1274 <main+0xf4>
lea    -0x210(%rbp),%rsi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1356 <main+0x1d6>
mov    -0x218(%rbp),%rdi
lea    -0x224(%rbp),%rsi
lea    -0x228(%rbp),%rdx
call   1050 <CtiData@plt>
cmp    $0x0,%rax
je     12b2 <main+0x132>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1356 <main+0x1d6>
lea    -0x110(%rbp),%rsi
mov    -0x228(%rbp),%edx
mov    -0x224(%rbp),%ecx
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x218(%rbp),%rdi
call   1070 <rewind@plt>
lea    0xdbb(%rip),%rdi
lea    -0x22c(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x218(%rbp),%rdi
mov    -0x220(%rbp),%rsi
mov    -0x228(%rbp),%edx
mov    -0x22c(%rbp),%ecx
call   1030 <Vystup@plt>
cmp    $0x0,%rax
je     1337 <main+0x1b7>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1356 <main+0x1d6>
mov    -0x218(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x220(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x210,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x200(%rsp)
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xd80(%rip),%rbx
lea    0x110(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xd58(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1301 <main+0x181>
mov    %rax,%rbx
lea    0xd6d(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1321 <main+0x1a1>
mov    %rax,%r14
lea    0xc(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <CtiData@plt>
test   %rax,%rax
je     133b <main+0x1bb>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%ebp
jmp    13b1 <main+0x231>
lea    0xcfd(%rip),%rdi
lea    0x110(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%ebp
jmp    13b1 <main+0x231>
lea    0xd09(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%ebp
jmp    13b1 <main+0x231>
mov    0x4(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xd12(%rip),%rdi
xor    %ebp,%ebp
lea    0x110(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1080 <rewind@plt>
lea    0xd16(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <Vystup@plt>
test   %rax,%rax
je     13a1 <main+0x221>
lea    0xcee(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%ebp
jmp    13b1 <main+0x231>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"Nepodarilo se otevrit vstupni soubor: %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [43 x i8] c"Nepodarilo se otevrit vystupni soubor: %s\0A\00"
@.str.5 = [33 x i8] c"Chyba pri volani funkce CtiData\0A\00"
@.str.6 = [36 x i8] c"V souboru %s je %d radku a %d slov\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [32 x i8] c"Chyba pri volani funkce Vystup\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [256 x i8]* %2 to i8*
%10 = bitcast [256 x i8]* %3 to i8*
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%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** %4
%17 = load i32*, i32** %4
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 1, i32* %1
br label %57
22: ; preds = %0
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %24, i32** %5
%25 = load i32*, i32** %5
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %28)
store i32 2, i32* %1
br label %57
30: ; preds = %22
%31 = load i32*, i32** %4
%32 = call i64 @CtiData(i32* %31, i32* %6, i32* %7)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %1
br label %57
36: ; preds = %30
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%38 = load i32, i32* %7
%39 = load i32, i32* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %37, i32 %38, i32 %39)
%41 = load i32*, i32** %4
%42 = call i32 @rewind(i32* %41)
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %8)
%44 = load i32*, i32** %4
%45 = load i32*, i32** %5
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i64 @Vystup(i32* %44, i32* %45, i32 %46, i32 %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %36
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
store i32 4, i32* %1
br label %57
52: ; preds = %36
%53 = load i32*, i32** %4
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %5
%56 = call i32 @fclose(i32* %55)
store i32 0, i32* %1
br label %57
57: ; preds = %52, %50, %34, %27, %19
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"Nepodarilo se otevrit vstupni soubor: %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [43 x i8] c"Nepodarilo se otevrit vystupni soubor: %s\0A\00"
@.str.6 = [36 x i8] c"V souboru %s je %d radku a %d slov\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@str = [31 x i8] c"Chyba pri volani funkce Vystup\00"
@str.9 = [32 x i8] c"Chyba pri volani funkce CtiData\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%10 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %46
14: ; preds = %0
%15 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %7)
br label %46
19: ; preds = %14
%20 = bitcast i32* %3 to i8*
%21 = bitcast i32* %4 to i8*
%22 = call i64 @CtiData(i32* %10, i32* %3, i32* %4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %44
26: ; preds = %19
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %6, i32 %27, i32 %28)
%30 = call i32 @rewind(i32* %10)
%31 = bitcast i32* %5 to i8*
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = call i64 @Vystup(i32* %10, i32* %15, i32 %33, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %26
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %42
39: ; preds = %26
%40 = call i32 @fclose(i32* %10)
%41 = call i32 @fclose(i32* %15)
br label %42
42: ; preds = %39, %37
%43 = phi i32 [ 4, %37 ], [ 0, %39 ]
br label %44
44: ; preds = %42, %24
%45 = phi i32 [ 3, %24 ], [ %43, %42 ]
br label %46
46: ; preds = %17, %44, %12
%47 = phi i32 [ 1, %12 ], [ 2, %17 ], [ %45, %44 ]
ret i32 %47
}