#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 */
void *atoi_2(char *);
int /*<<< orphan*/ clean_array(int *);
int /*<<< orphan*/ clean_text(char *, int);
int /*<<< orphan*/ getline_my(char *);
int /*<<< orphan*/ printf(char *, ...);
int getarray_sort(int sort[], char line[]) {
  short int len = 0;
  short int i = 0;
  printf("Input please lenght of array:");
  clean_text(line, 100);
  getline_my(line);
  len = atoi_2(line);
  clean_array(sort);
  printf("And now please input elements of array split them by \"Enter\". Size "
         "of array = %d;\n",
         len);
  for (i = 0; i < len; ++i) {
    printf("Input please %d-th element of array:", i);
    clean_text(line, 100);
    getline_my(line);
    sort[i] = atoi_2(line);
  };
  for (i = 0; i < len; ++i) {
    printf("sort [ %d ] = %d;\n", i, sort[i]);
  };
  return len;
}


x86 assembly (clang, -O0):
<getarray_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1070 <clean_text@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getline_my@plt>
mov    -0x10(%rbp),%rdi
call   1050 <atoi_2@plt>
mov    %ax,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <clean_array@plt>
movswl -0x12(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    1220 <getarray_sort+0xd0>
movswl -0x14(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1070 <clean_text@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getline_my@plt>
mov    -0x10(%rbp),%rdi
call   1050 <atoi_2@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movswq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    11bf <getarray_sort+0x6f>
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    1265 <getarray_sort+0x115>
movswl -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movswq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1226 <getarray_sort+0xd6>
movswl -0x12(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getarray_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <clean_text@plt>
mov    %rbx,%rdi
call   1060 <getline_my@plt>
mov    %rbx,%rdi
call   1050 <atoi_2@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1040 <clean_array@plt>
mov    %ebp,%r13d
shl    $0x10,%r13d
movswl %bp,%r12d
lea    0xe75(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r13d,%r13d
jle    123e <getarray_sort+0xee>
lea    0xeae(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <clean_text@plt>
mov    %rbx,%rdi
call   1060 <getline_my@plt>
mov    %rbx,%rdi
call   1050 <atoi_2@plt>
movslq %ebp,%rcx
mov    %eax,(%r14,%rcx,4)
add    $0x1,%ecx
movswl %cx,%ebp
cmp    %ebp,%r12d
jg     11d0 <getarray_sort+0x80>
test   %r13d,%r13d
jle    123e <getarray_sort+0xee>
lea    0xe7f(%rip),%rbx
xor    %eax,%eax
nopl   0x0(%rax)
movslq %eax,%rbp
mov    (%r14,%rbp,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
movswl %bp,%eax
cmp    %eax,%r12d
jg     1220 <getarray_sort+0xd0>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Input please lenght of array:\00"
@.str.1 = [83 x i8] c"And now please input elements of array split them by \22Enter\22. Size of array = %d;\0A\00"
@.str.2 = [37 x i8] c"Input please %d-th element of array:\00"
@.str.3 = [19 x i8] c"sort [ %d ] = %d;\0A\00"
define i32 @getarray_sort(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i16
store i32* %0, i32** %3
store i8* %1, i8** %4
store i16 0, i16* %5
store i16 0, i16* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %4
%9 = call i32 @clean_text(i8* %8, i32 100)
%10 = load i8*, i8** %4
%11 = call i32 @getline_my(i8* %10)
%12 = load i8*, i8** %4
%13 = call i8* @atoi_2(i8* %12)
%14 = ptrtoint i8* %13 to i16
store i16 %14, i16* %5
%15 = load i32*, i32** %3
%16 = call i32 @clean_array(i32* %15)
%17 = load i16, i16* %5
%18 = sext i16 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0), i32 %18)
store i16 0, i16* %6
br label %20
20: ; preds = %41, %2
%21 = load i16, i16* %6
%22 = sext i16 %21 to i32
%23 = load i16, i16* %5
%24 = sext i16 %23 to i32
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %44
26: ; preds = %20
%27 = load i16, i16* %6
%28 = sext i16 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i8*, i8** %4
%31 = call i32 @clean_text(i8* %30, i32 100)
%32 = load i8*, i8** %4
%33 = call i32 @getline_my(i8* %32)
%34 = load i8*, i8** %4
%35 = call i8* @atoi_2(i8* %34)
%36 = ptrtoint i8* %35 to i32
%37 = load i32*, i32** %3
%38 = load i16, i16* %6
%39 = sext i16 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %36, i32* %40
br label %41
41: ; preds = %26
%42 = load i16, i16* %6
%43 = add i16 %42, 1
store i16 %43, i16* %6
br label %20
44: ; preds = %20
store i16 0, i16* %6
br label %45
45: ; preds = %60, %44
%46 = load i16, i16* %6
%47 = sext i16 %46 to i32
%48 = load i16, i16* %5
%49 = sext i16 %48 to i32
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %63
51: ; preds = %45
%52 = load i16, i16* %6
%53 = sext i16 %52 to i32
%54 = load i32*, i32** %3
%55 = load i16, i16* %6
%56 = sext i16 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 %58)
br label %60
60: ; preds = %51
%61 = load i16, i16* %6
%62 = add i16 %61, 1
store i16 %62, i16* %6
br label %45
63: ; preds = %45
%64 = load i16, i16* %5
%65 = sext i16 %64 to i32
ret i32 %65
}

LLVM IR (-O2):
@.str = [30 x i8] c"Input please lenght of array:\00"
@.str.1 = [83 x i8] c"And now please input elements of array split them by \22Enter\22. Size of array = %d;\0A\00"
@.str.2 = [37 x i8] c"Input please %d-th element of array:\00"
@.str.3 = [19 x i8] c"sort [ %d ] = %d;\0A\00"
define i32 @getarray_sort(i32* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @clean_text(i8* %1, i32 100)
%5 = tail call i32 @getline_my(i8* %1)
%6 = tail call i8* @atoi_2(i8* %1)
%7 = ptrtoint i8* %6 to i64
%8 = trunc i64 %7 to i32
%9 = tail call i32 @clean_array(i32* %0)
%10 = shl i32 %8, 16
%11 = ashr exact i32 %10, 16
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = icmp sgt i32 %10, 0
br i1 %13, label %15, label %39
14: ; preds = %15
br i1 %13, label %29, label %39
15: ; preds = %2, %15
%16 = phi i32 [ %27, %15 ], [ 0, %2 ]
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 @clean_text(i8* %1, i32 100)
%19 = tail call i32 @getline_my(i8* %1)
%20 = tail call i8* @atoi_2(i8* %1)
%21 = ptrtoint i8* %20 to i64
%22 = trunc i64 %21 to i32
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds i32, i32* %0, i64 %23
store i32 %22, i32* %24
%25 = shl nsw i32 %16, 16
%26 = add i32 %25, 65536
%27 = ashr exact i32 %26, 16
%28 = icmp sgt i32 %11, %27
br i1 %28, label %15, label %14
29: ; preds = %14, %29
%30 = phi i32 [ %37, %29 ], [ 0, %14 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %0, i64 %31
%33 = load i32, i32* %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %33)
%35 = shl nsw i32 %30, 16
%36 = add i32 %35, 65536
%37 = ashr exact i32 %36, 16
%38 = icmp sgt i32 %11, %37
br i1 %38, label %29, label %39
39: ; preds = %29, %2, %14
ret i32 %11
}