#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*/ clear_zero(int *, int);
int count(int *, int);
int /*<<< orphan*/ fill(int *, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ outputAr(int *, int);
scalar_t__ realloc(int *, int);
int /*<<< orphan*/ resheto(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int n, *Ar, countt;
  scanf("%d", &n);
  Ar = (int *)malloc(n * sizeof(int));
  fill(Ar, n);
  outputAr(Ar, n);
  resheto(Ar, n);
  outputAr(Ar, n);
  clear_zero(Ar, n);
  outputAr(Ar, n);
  countt = count(Ar, n);
  Ar = (int *)realloc(Ar, countt * sizeof(int));
  n = countt;
  outputAr(Ar, n);
  free(Ar);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <fill@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <outputAr@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <resheto@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <outputAr@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <clear_zero@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <outputAr@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <count@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <outputAr@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe65(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1050 <fill@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <outputAr@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1060 <resheto@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <outputAr@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1090 <clear_zero@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <outputAr@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <count@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%esi
mov    %rbx,%rdi
call   1080 <realloc@plt>
mov    %rax,%rbx
mov    %r14d,0x4(%rsp)
mov    %rax,%rdi
mov    %r14d,%esi
call   10b0 <outputAr@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 4
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = load i32, i32* %2
%14 = call i32 @fill(i32* %12, i32 %13)
%15 = load i32*, i32** %3
%16 = load i32, i32* %2
%17 = call i32 @outputAr(i32* %15, i32 %16)
%18 = load i32*, i32** %3
%19 = load i32, i32* %2
%20 = call i32 @resheto(i32* %18, i32 %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* %2
%23 = call i32 @outputAr(i32* %21, i32 %22)
%24 = load i32*, i32** %3
%25 = load i32, i32* %2
%26 = call i32 @clear_zero(i32* %24, i32 %25)
%27 = load i32*, i32** %3
%28 = load i32, i32* %2
%29 = call i32 @outputAr(i32* %27, i32 %28)
%30 = load i32*, i32** %3
%31 = load i32, i32* %2
%32 = call i32 @count(i32* %30, i32 %31)
store i32 %32, i32* %4
%33 = load i32*, i32** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 4
%37 = trunc i64 %36 to i32
%38 = call i64 @realloc(i32* %33, i32 %37)
%39 = inttoptr i64 %38 to i32*
store i32* %39, i32** %3
%40 = load i32, i32* %4
store i32 %40, i32* %2
%41 = load i32*, i32** %3
%42 = load i32, i32* %2
%43 = call i32 @outputAr(i32* %41, i32 %42)
%44 = load i32*, i32** %3
%45 = call i32 @free(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = shl i32 %4, 2
%6 = call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = load i32, i32* %1
%9 = call i32 @fill(i32* %7, i32 %8)
%10 = load i32, i32* %1
%11 = call i32 @outputAr(i32* %7, i32 %10)
%12 = load i32, i32* %1
%13 = call i32 @resheto(i32* %7, i32 %12)
%14 = load i32, i32* %1
%15 = call i32 @outputAr(i32* %7, i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @clear_zero(i32* %7, i32 %16)
%18 = load i32, i32* %1
%19 = call i32 @outputAr(i32* %7, i32 %18)
%20 = load i32, i32* %1
%21 = call i32 @count(i32* %7, i32 %20)
%22 = shl i32 %21, 2
%23 = call i64 @realloc(i32* %7, i32 %22)
%24 = inttoptr i64 %23 to i32*
store i32 %21, i32* %1
%25 = call i32 @outputAr(i32* %24, i32 %21)
%26 = call i32 @free(i32* %24)
ret i32 0
}