#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 */
char EOF;
int /*<<< orphan*/ close(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int,
                           int /*<<< orphan*/);
char getc(int /*<<< orphan*/ *);
int *neka_funkcija(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *ulazna_datoteka, *izlazna_datoteka;
  ulazna_datoteka = fopen("ulaz.txt", "r");
  izlazna_datoteka = fopen("izlaz.txt", "w");
  if (ulazna_datoteka == NULL) {
    printf("greska1");
    exit(1);
  } else if (izlazna_datoteka == NULL) {
    printf("greska2");
    close(ulazna_datoteka);
    exit(2);
  } else {
    printf("obe otvoreno uspjesno...\n");
    char niz[1000];
    int i;
    for (i = 0; i < 1000; i++)
      niz[i] = 0;
    char c;
    i = 0;
    while ((c = getc(ulazna_datoteka)) != EOF) {
      niz[i++] = c;
    }
    int *pok;
    pok = neka_funkcija(niz);
    for (i = 0; i < 26; i++) {
      fprintf(izlazna_datoteka, "%c%d ", i + 65, *pok++);
    }
  }
  close(ulazna_datoteka);
  close(izlazna_datoteka);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe6b(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d1 <main+0x61>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11fb <main+0x8b>
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <close@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x404(%rbp)
cmpl   $0x3e8,-0x404(%rbp)
jge    1244 <main+0xd4>
movslq -0x404(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    1211 <main+0xa1>
movl   $0x0,-0x404(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %al,-0x405(%rbp)
movsbl %al,%eax
mov    0x2d81(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1297 <main+0x127>
mov    -0x405(%rbp),%cl
mov    -0x404(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x404(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
jmp    124e <main+0xde>
lea    -0x400(%rbp),%rdi
call   1080 <neka_funkcija@plt>
mov    %rax,-0x410(%rbp)
movl   $0x0,-0x404(%rbp)
cmpl   $0x1a,-0x404(%rbp)
jge    1305 <main+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x404(%rbp),%edx
add    $0x41,%edx
mov    -0x410(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x410(%rbp)
mov    (%rax),%ecx
lea    0xd55(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    12b4 <main+0x144>
jmp    130a <main+0x19a>
jmp    130f <main+0x19f>
mov    -0x10(%rbp),%rdi
call   1040 <close@plt>
mov    -0x18(%rbp),%rdi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
lea    0xe59(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe4e(%rip),%rdi
lea    0xe51(%rip),%rsi
call   1080 <fopen@plt>
test   %r14,%r14
je     128f <main+0xff>
mov    %rax,%r15
test   %rax,%rax
je     12a5 <main+0x115>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    $0x3e8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
call   10b0 <getc@plt>
mov    0x2ddd(%rip),%r12
cmp    (%r12),%al
je     1234 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx)
mov    %r14,%rdi
call   10b0 <getc@plt>
add    $0x1,%rbx
cmp    (%r12),%al
jne    1220 <main+0x90>
mov    %rsp,%rdi
call   10a0 <neka_funkcija@plt>
mov    %rax,%r13
xor    %ebx,%ebx
lea    0xddf(%rip),%r12
nopl   0x0(%rax,%rax,1)
lea    0x41(%rbx),%edx
mov    0x0(%r13,%rbx,4),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x1a,%ebx
jne    1250 <main+0xc0>
mov    %r14,%rdi
call   1060 <close@plt>
mov    %r15,%rdi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd81(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xd73(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1060 <close@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"ulaz.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"izlaz.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c"greska1\00"
@.str.5 = [8 x i8] c"greska2\00"
@.str.6 = [26 x i8] c"obe otvoreno uspjesno...\0A\00"
@EOF = global i8 0
@.str.7 = [6 x i8] c"%c%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %3
%10 = load i32*, i32** %2
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32*, i32** %3
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32*, i32** %2
%21 = call i32 @close(i32* %20)
%22 = call i32 @exit(i32 2)
unreachable
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %5
br label %25
25: ; preds = %32, %23
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 1000
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %28
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %25
35: ; preds = %25
store i32 0, i32* %5
br label %36
36: ; preds = %43, %35
%37 = load i32*, i32** %2
%38 = call signext i8 @getc(i32* %37)
store i8 %38, i8* %6
%39 = sext i8 %38 to i32
%40 = load i8, i8* @EOF
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %39, %41
br i1 %42, label %43, label %49
43: ; preds = %36
%44 = load i8, i8* %6
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %47
store i8 %44, i8* %48
br label %36
49: ; preds = %36
%50 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%51 = call i32* @neka_funkcija(i8* %50)
store i32* %51, i32** %7
store i32 0, i32* %5
br label %52
52: ; preds = %63, %49
%53 = load i32, i32* %5
%54 = icmp slt i32 %53, 26
br i1 %54, label %55, label %66
55: ; preds = %52
%56 = load i32*, i32** %3
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 65
%59 = load i32*, i32** %7
%60 = getelementptr inbounds i32, i32* %59, i32 1
store i32* %60, i32** %7
%61 = load i32, i32* %59
%62 = call i32 @fprintf(i32* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %58, i32 %61)
br label %63
63: ; preds = %55
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %52
66: ; preds = %52
br label %67
67: ; preds = %66
br label %68
68: ; preds = %67
%69 = load i32*, i32** %2
%70 = call i32 @close(i32* %69)
%71 = load i32*, i32** %3
%72 = call i32 @close(i32* %71)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"ulaz.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"izlaz.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c"greska1\00"
@.str.5 = [8 x i8] c"greska2\00"
@EOF = global i8 0
@.str.7 = [6 x i8] c"%c%d \00"
@str = [25 x i8] c"obe otvoreno uspjesno...\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32* %3, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = icmp eq i32* %4, null
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call i32 @close(i32* %3)
%14 = tail call i32 @exit(i32 2)
unreachable
15: ; preds = %9
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%18 = tail call signext i8 @getc(i32* %3)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %29, label %21
21: ; preds = %15, %21
%22 = phi i64 [ %24, %21 ], [ 0, %15 ]
%23 = phi i8 [ %26, %21 ], [ %18, %15 ]
%24 = add nuw i64 %22, 1
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %22
store i8 %23, i8* %25
%26 = tail call signext i8 @getc(i32* %3)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %21
29: ; preds = %21, %15
%30 = call i32* @neka_funkcija(i8* %17)
br label %31
31: ; preds = %29, %31
%32 = phi i32* [ %30, %29 ], [ %35, %31 ]
%33 = phi i32 [ 0, %29 ], [ %38, %31 ]
%34 = add nuw nsw i32 %33, 65
%35 = getelementptr inbounds i32, i32* %32, i64 1
%36 = load i32, i32* %32
%37 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %34, i32 %36)
%38 = add nuw nsw i32 %33, 1
%39 = icmp eq i32 %38, 26
br i1 %39, label %40, label %31
40: ; preds = %31
%41 = call i32 @close(i32* %3)
%42 = call i32 @close(i32* %4)
ret i32 0
}