#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char gradovi[10][20];
  char grad[20];
  int br_grad = 0;
  int duz, i;
  char c;
  int nastavi;
  do {
    for (duz = 0; (c = getchar()) != '\n';) {
      if (duz < 20 - 1)
        grad[duz++] = c;
    }
    grad[duz] = '\0';
    if (duz != 0) {
      for (i = br_grad - 1, nastavi = 1; i >= 0 && nastavi == 1;) {
        if ((strcmp(gradovi[i], grad) > 0)) {
          strcpy(gradovi[i + 1], gradovi[i]);
          i--;
        } else
          nastavi = 0;
      }
      strcpy(gradovi[i + 1], grad);
      br_grad++;
    }
  } while (br_grad < 10 && duz > 0);
  printf("Sortiran niz naziva je \n");
  for (i = 0; i <= br_grad; i++)
    printf("%s\n", gradovi[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0xfd(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11b1 <main+0x71>
cmpl   $0x13,-0xf8(%rbp)
jge    11ac <main+0x6c>
mov    -0xfd(%rbp),%cl
mov    -0xf8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xf8(%rbp)
cltq
mov    %cl,-0xf0(%rbp,%rax,1)
jmp    1166 <main+0x26>
movslq -0xf8(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
cmpl   $0x0,-0xf8(%rbp)
je     12d3 <main+0x193>
mov    -0xf4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xfc(%rbp)
movl   $0x1,-0x104(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xfc(%rbp)
mov    %al,-0x105(%rbp)
jl     120b <main+0xcb>
cmpl   $0x1,-0x104(%rbp)
sete   %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    121e <main+0xde>
jmp    129f <main+0x15f>
movslq -0xfc(%rbp),%rax
lea    -0xd0(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
lea    -0xf0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jle    1290 <main+0x150>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0xd0(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
movslq -0xfc(%rbp),%rax
lea    -0xd0(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0xfc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xfc(%rbp)
jmp    129a <main+0x15a>
movl   $0x0,-0x104(%rbp)
jmp    11e6 <main+0xa6>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0xd0(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    12d8 <main+0x198>
xor    %eax,%eax
cmpl   $0xa,-0xf4(%rbp)
mov    %al,-0x106(%rbp)
jge    12fd <main+0x1bd>
cmpl   $0x0,-0xf8(%rbp)
setg   %al
mov    %al,-0x106(%rbp)
mov    -0x106(%rbp),%al
test   $0x1,%al
jne    115c <main+0x1c>
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xfc(%rbp)
mov    -0xfc(%rbp),%eax
cmp    -0xf4(%rbp),%eax
jg     136c <main+0x22c>
movslq -0xfc(%rbp),%rax
lea    -0xd0(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc(%rbp)
jmp    1323 <main+0x1e3>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
lea    0x30(%rsp),%r12
mov    $0xffffffff,%ebx
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1275 <main+0x135>
mov    %ebx,%ecx
lea    (%rcx,%rcx,4),%rcx
lea    (%rsp,%rcx,4),%r15
add    $0x30,%r15
xor    %r13d,%r13d
jmp    119b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     11b0 <main+0x70>
cmp    $0x12,%r13d
jg     1190 <main+0x50>
movslq %r13d,%rcx
add    $0x1,%r13d
mov    %al,0x10(%rsp,%rcx,1)
jmp    1190 <main+0x50>
xchg   %ax,%ax
movslq %r13d,%rax
movb   $0x0,0x10(%rsp,%rax,1)
test   %eax,%eax
je     127a <main+0x13a>
mov    %ebx,0xc(%rsp)
test   %r14d,%r14d
mov    %r12,0x28(%rsp)
je     1220 <main+0xe0>
lea    -0x1(%r14),%ebp
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    1230 <main+0xf0>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    -0x1(%rbp),%eax
test   %ebp,%ebp
jle    1232 <main+0xf2>
add    $0xffffffffffffffec,%rbx
add    $0xffffffffffffffec,%r15
mov    %eax,%ebp
test   %r12,%r12
jg     11e0 <main+0xa0>
jmp    1232 <main+0xf2>
nopl   0x0(%rax,%rax,1)
mov    $0xffffffff,%eax
jmp    1232 <main+0xf2>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
add    $0x1,%eax
cltq
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rdi
add    $0x30,%rdi
lea    0x10(%rsp),%rsi
call   1030 <strcpy@plt>
lea    0x1(%r14),%ebp
cmp    $0x8,%r14d
ja     127d <main+0x13d>
mov    0x28(%rsp),%r12
add    $0x14,%r12
mov    0xc(%rsp),%ebx
add    $0x1,%ebx
mov    %ebp,%r14d
test   %r13d,%r13d
jg     1160 <main+0x20>
jmp    127d <main+0x13d>
movb   $0x0,0x10(%rsp)
mov    %r14d,%ebp
lea    0xd7c(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%ebp
lea    0x30(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <puts@plt>
add    $0x14,%rbx
add    $0xffffffffffffffff,%rbp
jne    12a0 <main+0x160>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Sortiran niz naziva je \0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [20 x i8]]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %9
9: ; preds = %81, %0
store i32 0, i32* %5
br label %10
10: ; preds = %23, %9
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %7
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 19
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i8, i8* %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %17, %14
br label %10
24: ; preds = %10
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %74
30: ; preds = %24
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %6
store i32 1, i32* %8
br label %33
33: ; preds = %63, %30
%34 = load i32, i32* %6
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %8
%38 = icmp eq i32 %37, 1
br label %39
39: ; preds = %36, %33
%40 = phi i1 [ false, %33 ], [ %38, %36 ]
br i1 %40, label %41, label %64
41: ; preds = %39
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 %43
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %44, i64 0, i64 0
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%47 = call i64 @strcmp(i8* %45, i8* %46)
%48 = icmp sgt i64 %47, 0
br i1 %48, label %49, label %62
49: ; preds = %41
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 %52
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %53, i64 0, i64 0
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 %56
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %57, i64 0, i64 0
%59 = call i32 @strcpy(i8* %54, i8* %58)
%60 = load i32, i32* %6
%61 = add nsw i32 %60, -1
store i32 %61, i32* %6
br label %63
62: ; preds = %41
store i32 0, i32* %8
br label %63
63: ; preds = %62, %49
br label %33
64: ; preds = %39
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 %67
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %68, i64 0, i64 0
%70 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%71 = call i32 @strcpy(i8* %69, i8* %70)
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %74
74: ; preds = %64, %24
br label %75
75: ; preds = %74
%76 = load i32, i32* %4
%77 = icmp slt i32 %76, 10
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i32, i32* %5
%80 = icmp sgt i32 %79, 0
br label %81
81: ; preds = %78, %75
%82 = phi i1 [ false, %75 ], [ %80, %78 ]
br i1 %82, label %9, label %83
83: ; preds = %81
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %85
85: ; preds = %95, %83
%86 = load i32, i32* %6
%87 = load i32, i32* %4
%88 = icmp sle i32 %86, %87
br i1 %88, label %89, label %98
89: ; preds = %85
%90 = load i32, i32* %6
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 %91
%93 = getelementptr inbounds [20 x i8], [20 x i8]* %92, i64 0, i64 0
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %89
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
br label %85
98: ; preds = %85
ret i32 0
}

LLVM IR (-O2):
@str = [24 x i8] c"Sortiran niz naziva je \00"
define i32 @main() {
%1 = alloca [10 x [20 x i8]]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %1, i64 0, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %45, %0
%6 = phi i32 [ 0, %0 ], [ %51, %45 ]
%7 = call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 10
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8 0, i8* %10
br label %55
11: ; preds = %5, %19
%12 = phi i8 [ %21, %19 ], [ %7, %5 ]
%13 = phi i32 [ %20, %19 ], [ 0, %5 ]
%14 = icmp slt i32 %13, 19
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = add nsw i32 %13, 1
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %17
store i8 %12, i8* %18
br label %19
19: ; preds = %15, %11
%20 = phi i32 [ %16, %15 ], [ %13, %11 ]
%21 = call signext i8 (...) @getchar()
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %11
23: ; preds = %19
%24 = sext i32 %20 to i64
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %24
store i8 0, i8* %25
%26 = icmp eq i32 %20, 0
br i1 %26, label %55, label %27
27: ; preds = %23
%28 = icmp eq i32 %6, 0
br i1 %28, label %45, label %29
29: ; preds = %27
%30 = add nsw i32 %6, -1
br label %31
31: ; preds = %29, %37
%32 = phi i32 [ %42, %37 ], [ %30, %29 ]
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %1, i64 0, i64 %33, i64 0
%35 = call i64 @strcmp(i8* %34, i8* %4)
%36 = icmp sgt i64 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %31
%38 = add nuw nsw i32 %32, 1
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %1, i64 0, i64 %39, i64 0
%41 = call i32 @strcpy(i8* %40, i8* %34)
%42 = add nsw i32 %32, -1
%43 = icmp sgt i32 %32, 0
%44 = and i1 %43, %36
br i1 %44, label %31, label %45
45: ; preds = %31, %37, %27
%46 = phi i32 [ -1, %27 ], [ %32, %31 ], [ %42, %37 ]
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %1, i64 0, i64 %48, i64 0
%50 = call i32 @strcpy(i8* %49, i8* %4)
%51 = add nuw nsw i32 %6, 1
%52 = icmp ult i32 %6, 9
%53 = icmp sgt i32 %20, 0
%54 = select i1 %52, i1 %53, i1 false
br i1 %54, label %5, label %55
55: ; preds = %23, %45, %9
%56 = phi i32 [ %6, %9 ], [ %6, %23 ], [ %51, %45 ]
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%58 = add nuw nsw i32 %56, 1
%59 = zext i32 %58 to i64
br label %60
60: ; preds = %55, %60
%61 = phi i64 [ 0, %55 ], [ %64, %60 ]
%62 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %1, i64 0, i64 %61, i64 0
%63 = call i32 @puts(i8* %62)
%64 = add nuw nsw i64 %61, 1
%65 = icmp eq i64 %64, %59
br i1 %65, label %66, label %60
66: ; preds = %60
ret i32 0
}