#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 */

/* Variables and functions */
int /*<<< orphan*/ kopiraj(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int ucitaj_liniju(char *, int);
int main() {
  char line[10];
  char longest[10];
  int max = 0, len = 0;
  while ((len = ucitaj_liniju(line, 10)) > 0) {
    if (len > max) {
      max = len;
      kopiraj(longest, line);
    }
  }
  printf("Najduza do sada je %s\n", longest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0xe(%rbp),%rdi
mov    $0xa,%esi
call   1030 <ucitaj_liniju@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    118b <main+0x5b>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1186 <main+0x56>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1050 <kopiraj@plt>
jmp    114d <main+0x1d>
lea    -0x18(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
call   1030 <ucitaj_liniju@plt>
test   %eax,%eax
jle    1186 <main+0x56>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x4(%rsp),%r14
lea    0xe(%rsp),%r15
jmp    1173 <main+0x43>
nopl   (%rax)
mov    %r15,%rdi
mov    $0xa,%esi
call   1030 <ucitaj_liniju@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1186 <main+0x56>
cmp    %ebx,%ebp
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <kopiraj@plt>
mov    %ebp,%ebx
jmp    1160 <main+0x30>
lea    0xe73(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Najduza do sada je %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %19, %0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%8 = call i32 @ucitaj_liniju(i8* %7, i32 10)
store i32 %8, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %5
store i32 %15, i32* %4
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%18 = call i32 @kopiraj(i8* %16, i8* %17)
br label %19
19: ; preds = %14, %10
br label %6
20: ; preds = %6
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Najduza do sada je %s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @ucitaj_liniju(i8* %3, i32 10)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0, %13
%8 = phi i32 [ %15, %13 ], [ %5, %0 ]
%9 = phi i32 [ %14, %13 ], [ 0, %0 ]
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @kopiraj(i8* %4, i8* %3)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @ucitaj_liniju(i8* %3, i32 10)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %7, label %17
17: ; preds = %13, %0
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}