#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int indice = 0, indiceParcial = 0;
  int *vetor = malloc(sizeof(int) * 10);
  while (1) {
    int valor;
    scanf("%d", &valor);
    if (valor == 0)
      break;
    vetor[indice++] = valor;
    if (indiceParcial++ == 9) {
      int *vetorAuxiliar = malloc(sizeof(int) * (indice + 10));
      memcpy(vetorAuxiliar, vetor, indice * sizeof(int));
      free(vetor);
      vetor = vetorAuxiliar;
      indiceParcial = 0;
    }
  }
  printf("\n");
  for (int i = 0; i < indice; i++)
    printf("%d  ", vetor[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe7e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    119a <main+0x4a>
jmp    1211 <main+0xc1>
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x9,%eax
jne    120c <main+0xbc>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    117b <main+0x2b>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1259 <main+0x109>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1226 <main+0xd6>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe81(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1249 <main+0xe9>
xor    %ebp,%ebp
mov    $0x2c,%ebx
lea    0xe5d(%rip),%r13
lea    0x4(%rsp),%r12
xor    %r15d,%r15d
jmp    11fb <main+0x9b>
nopl   (%rax)
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %r13,%r12
mov    %rax,%r13
lea    -0x28(%rbx),%edx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <memcpy@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
mov    %r13,%r14
mov    %r12,%r13
lea    0x4(%rsp),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0x4,%ebx
add    $0x1,%rbp
test   %eax,%eax
je     120b <main+0xab>
mov    %eax,(%r14,%rbp,4)
cmp    $0x9,%r15d
je     11b0 <main+0x50>
add    $0x1,%r15d
jmp    11e1 <main+0x81>
mov    $0xa,%edi
call   1040 <putchar@plt>
test   %ebp,%ebp
je     1253 <main+0xf3>
mov    %ebp,%ebp
lea    0xde1(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1230 <main+0xd0>
jmp    1253 <main+0xf3>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%8 = call i32* @malloc(i32 40)
store i32* %8, i32** %4
br label %9
9: ; preds = %0, %41
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %42
14: ; preds = %9
%15 = load i32, i32* %5
%16 = load i32*, i32** %4
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i32, i32* %16, i64 %19
store i32 %15, i32* %20
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = icmp eq i32 %21, 9
br i1 %23, label %24, label %41
24: ; preds = %14
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 10
%27 = sext i32 %26 to i64
%28 = mul i64 4, %27
%29 = trunc i64 %28 to i32
%30 = call i32* @malloc(i32 %29)
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = load i32*, i32** %4
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 4
%36 = trunc i64 %35 to i32
%37 = call i32 @memcpy(i32* %31, i32* %32, i32 %36)
%38 = load i32*, i32** %4
%39 = call i32 @free(i32* %38)
%40 = load i32*, i32** %6
store i32* %40, i32** %4
store i32 0, i32* %3
br label %41
41: ; preds = %24, %14
br label %9
42: ; preds = %13
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %44
44: ; preds = %55, %42
%45 = load i32, i32* %7
%46 = load i32, i32* %2
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i32*, i32** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %44
58: ; preds = %44
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32* @malloc(i32 40)
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @putchar(i32 10)
br label %39
9: ; preds = %0, %27
%10 = phi i64 [ %14, %27 ], [ 0, %0 ]
%11 = phi i32 [ %31, %27 ], [ %5, %0 ]
%12 = phi i32* [ %29, %27 ], [ %2, %0 ]
%13 = phi i32 [ %28, %27 ], [ 0, %0 ]
%14 = add nuw i64 %10, 1
%15 = getelementptr inbounds i32, i32* %12, i64 %10
store i32 %11, i32* %15
%16 = add nsw i32 %13, 1
%17 = icmp eq i32 %13, 9
br i1 %17, label %18, label %27
18: ; preds = %9
%19 = trunc i64 %10 to i32
%20 = shl i32 %19, 2
%21 = add i32 %20, 44
%22 = call i32* @malloc(i32 %21)
%23 = trunc i64 %14 to i32
%24 = shl i32 %23, 2
%25 = call i32 @memcpy(i32* %22, i32* %12, i32 %24)
%26 = call i32 @free(i32* %12)
br label %27
27: ; preds = %9, %18
%28 = phi i32 [ 0, %18 ], [ %16, %9 ]
%29 = phi i32* [ %22, %18 ], [ %12, %9 ]
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%31 = load i32, i32* %1
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %9
33: ; preds = %27
%34 = trunc i64 %14 to i32
%35 = call i32 @putchar(i32 10)
%36 = icmp eq i32 %34, 0
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = and i64 %14, 4294967295
br label %40
39: ; preds = %40, %7, %33
ret i32 0
40: ; preds = %37, %40
%41 = phi i64 [ 0, %37 ], [ %45, %40 ]
%42 = getelementptr inbounds i32, i32* %29, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = add nuw nsw i64 %41, 1
%46 = icmp eq i64 %45, %38
br i1 %46, label %39, label %40
}