#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 euklidNzd(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *f;
  int x, y, d;
  f = fopen("primer3.txt", "r");
  if (f == NULL) {
    printf("Datoteka primer3.txt nije otvorena");
    exit(1);
  }
  while (1) {
    if (fscanf(f, "%d %d", &x, &y) < 2)
      break;
    d = euklidNzd(x, y);
    printf("%d %d %d\n", x, y, d);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <main+0x49>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    119e <main+0x4e>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jge    11c4 <main+0x74>
jmp    11ee <main+0x9e>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <euklidNzd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <main+0x4e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1207 <main+0xb7>
mov    %rax,%rbx
lea    0xeae(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jl     11f7 <main+0xa7>
lea    0xe96(%rip),%r14
lea    0xe89(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1070 <euklidNzd@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jg     11c0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"primer3.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Datoteka primer3.txt nije otvorena\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
br label %13
13: ; preds = %12, %18
%14 = load i32*, i32** %2
%15 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %13
br label %26
18: ; preds = %13
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @euklidNzd(i32 %19, i32 %20)
store i32 %21, i32* %5
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %13
26: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"primer3.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Datoteka primer3.txt nije otvorena\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%9 = icmp slt i32 %8, 2
br i1 %9, label %22, label %13
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %7, %13
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @euklidNzd(i32 %14, i32 %15)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18, i32 %16)
%20 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %13
22: ; preds = %13, %7
ret i32 0
}