#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  int i;
  float n;
  float compressedVector[50], originalVector[50];
  int originalVectorSize = 0, compressedVectorSize = 0;
  printf("Entre com um vetor: ");
  while (1) {
    scanf("%f", &n);
    if (n == -999)
      break;
    if (n != 0)
      compressedVector[compressedVectorSize++] = n;
    originalVector[originalVectorSize++] = n;
  }
  for (i = compressedVectorSize; i < originalVectorSize; i++) {
    compressedVector[i] = 0;
  }
  compressedVectorSize = originalVectorSize;
  printf("Vetor original: ");
  for (i = 0; i < originalVectorSize; i++) {
    printf("%.1f ", originalVector[i]);
  }
  printf("\n");
  printf("Vetor compactado: ");
  for (i = 0; i < compressedVectorSize; i++) {
    printf("%.1f ", compressedVector[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  0xe8f(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1185 <main+0x65>
jp     1185 <main+0x65>
jmp    11e8 <main+0xc8>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11a1 <main+0x81>
jp     11a1 <main+0x81>
jmp    11c2 <main+0xa2>
movss  -0xc(%rbp),%xmm0
mov    -0x1b8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1b8(%rbp)
cltq
movss  %xmm0,-0xe0(%rbp,%rax,4)
ff ff
movss  -0xc(%rbp),%xmm0
mov    -0x1b4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1b4(%rbp)
cltq
movss  %xmm0,-0x1b0(%rbp,%rax,4)
ff ff
jmp    1154 <main+0x34>
mov    -0x1b8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    121e <main+0xfe>
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe0(%rbp,%rax,4)
ff ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x1b4(%rbp),%eax
mov    %eax,-0x1b8(%rbp)
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    127b <main+0x15b>
movslq -0x8(%rbp),%rax
movss  -0x1b0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xdc7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    123f <main+0x11f>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1b8(%rbp),%eax
jge    12da <main+0x1ba>
movslq -0x8(%rbp),%rax
movss  -0xe0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xd68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129e <main+0x17e>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1b0,%rsp
lea    0xeb2(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe82(%rip),%xmm0
jne    119b <main+0x5b>
jp     119b <main+0x5b>
lea    0xe97(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r15b
jmp    1273 <main+0x133>
lea    0xe7b(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
jmp    11d9 <main+0x99>
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xe0(%rsp,%rbx,4)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe2b(%rip),%xmm0
jne    11d9 <main+0x99>
jnp    11f3 <main+0xb3>
ucomiss 0xe24(%rip),%xmm0
jne    11e4 <main+0xa4>
jnp    11b0 <main+0x70>
movslq %r12d,%rax
add    $0x1,%r12d
movss  %xmm0,0x10(%rsp,%rax,4)
jmp    11b0 <main+0x70>
cmp    %ebx,%r12d
jge    1219 <main+0xd9>
movslq %r12d,%rax
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
not    %r12d
lea    (%rbx,%r12,1),%eax
lea    0x4(,%rax,4),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe00(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
sete   %r15b
je     1193 <main+0x53>
mov    %ebx,%r12d
xor    %ebp,%ebp
lea    0xdef(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0xe0(%rsp,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1250 <main+0x110>
mov    %ebx,%r14d
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15b,%r15b
jne    12bd <main+0x17d>
xor    %ebp,%ebp
lea    0xd98(%rip),%rbx
nopl   0x0(%rax)
movss  0x10(%rsp,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    12a0 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Entre com um vetor: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [17 x i8] c"Vetor original: \00"
@.str.3 = [6 x i8] c"%.1f \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [19 x i8] c"Vetor compactado: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca [50 x float]
%5 = alloca [50 x float]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %0, %23
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%11 = load float, float* %3
%12 = fcmp oeq float %11, -9.990000e+02
br i1 %12, label %13, label %14
13: ; preds = %9
br label %29
14: ; preds = %9
%15 = load float, float* %3
%16 = fcmp une float %15, 0.000000e+00
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load float, float* %3
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [50 x float], [50 x float]* %4, i64 0, i64 %21
store float %18, float* %22
br label %23
23: ; preds = %17, %14
%24 = load float, float* %3
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [50 x float], [50 x float]* %5, i64 0, i64 %27
store float %24, float* %28
br label %9
29: ; preds = %13
%30 = load i32, i32* %7
store i32 %30, i32* %2
br label %31
31: ; preds = %39, %29
%32 = load i32, i32* %2
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [50 x float], [50 x float]* %4, i64 0, i64 %37
store float 0.000000e+00, float* %38
br label %39
39: ; preds = %35
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %31
42: ; preds = %31
%43 = load i32, i32* %6
store i32 %43, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %45
45: ; preds = %56, %42
%46 = load i32, i32* %2
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [50 x float], [50 x float]* %5, i64 0, i64 %51
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %54)
br label %56
56: ; preds = %49
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %45
59: ; preds = %45
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %62
62: ; preds = %73, %59
%63 = load i32, i32* %2
%64 = load i32, i32* %7
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = load i32, i32* %2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [50 x float], [50 x float]* %4, i64 0, i64 %68
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %62
76: ; preds = %62
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Entre com um vetor: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [17 x i8] c"Vetor original: \00"
@.str.3 = [6 x i8] c"%.1f \00"
@.str.5 = [19 x i8] c"Vetor compactado: \00"
define i32 @main() {
%1 = alloca float
%2 = alloca [50 x float]
%3 = alloca [50 x float]
%4 = bitcast float* %1 to i8*
%5 = bitcast [50 x float]* %2 to i8*
%6 = bitcast [50 x float]* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = load float, float* %1
%10 = fcmp oeq float %9, -9.990000e+02
br i1 %10, label %11, label %25
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %56
13: ; preds = %34
%14 = trunc i64 %36 to i32
%15 = icmp slt i32 %35, %14
br i1 %15, label %16, label %41
16: ; preds = %13
%17 = sext i32 %35 to i64
%18 = getelementptr [50 x float], [50 x float]* %2, i64 0, i64 %17
%19 = bitcast float* %18 to i8*
%20 = xor i32 %35, -1
%21 = add i32 %14, %20
%22 = zext i32 %21 to i64
%23 = shl nuw nsw i64 %22, 2
%24 = add nuw nsw i64 %23, 4
br label %41
25: ; preds = %0, %34
%26 = phi i64 [ %36, %34 ], [ 0, %0 ]
%27 = phi float [ %39, %34 ], [ %9, %0 ]
%28 = phi i32 [ %35, %34 ], [ 0, %0 ]
%29 = fcmp une float %27, 0.000000e+00
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = add nsw i32 %28, 1
%32 = sext i32 %28 to i64
%33 = getelementptr inbounds [50 x float], [50 x float]* %2, i64 0, i64 %32
store float %27, float* %33
br label %34
34: ; preds = %30, %25
%35 = phi i32 [ %31, %30 ], [ %28, %25 ]
%36 = add nuw i64 %26, 1
%37 = getelementptr inbounds [50 x float], [50 x float]* %3, i64 0, i64 %26
store float %27, float* %37
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%39 = load float, float* %1
%40 = fcmp oeq float %39, -9.990000e+02
br i1 %40, label %13, label %25
41: ; preds = %16, %13
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i32 %14, 0
br i1 %43, label %56, label %44
44: ; preds = %41
%45 = and i64 %36, 4294967295
br label %46
46: ; preds = %44, %46
%47 = phi i64 [ 0, %44 ], [ %52, %46 ]
%48 = getelementptr inbounds [50 x float], [50 x float]* %3, i64 0, i64 %47
%49 = load float, float* %48
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %50)
%52 = add nuw nsw i64 %47, 1
%53 = icmp eq i64 %52, %45
br i1 %53, label %54, label %46
54: ; preds = %46
%55 = and i64 %36, 4294967295
br label %56
56: ; preds = %54, %11, %41
%57 = phi i1 [ true, %41 ], [ true, %11 ], [ %43, %54 ]
%58 = phi i64 [ 0, %41 ], [ 0, %11 ], [ %55, %54 ]
%59 = call i32 @putchar(i32 10)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br i1 %57, label %69, label %61
61: ; preds = %56, %61
%62 = phi i64 [ %67, %61 ], [ 0, %56 ]
%63 = getelementptr inbounds [50 x float], [50 x float]* %2, i64 0, i64 %62
%64 = load float, float* %63
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %65)
%67 = add nuw nsw i64 %62, 1
%68 = icmp eq i64 %67, %58
br i1 %68, label %69, label %61
69: ; preds = %61, %56
%70 = call i32 @putchar(i32 10)
ret i32 0
}