#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 *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int *realloc(int *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int *vetor, contador = 0;
  char c;
  vetor = malloc(sizeof(int));
  while (1) {
    printf("Digite um valor para salvar no vetor: ");
    scanf("%d", &vetor[contador]);
    printf("Deseja cadastrar mais um numero? ");
    scanf(" %c", &c);
    contador++;
    if (c != 's' && c != 'S')
      break;
    vetor = realloc(vetor, sizeof(int) * (contador + 1));
  }
  for (int i = 0; i < contador; i++)
    printf(" (%d) ", vetor[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x73,%eax
je     11d7 <main+0x97>
movsbl -0x15(%rbp),%eax
cmp    $0x53,%eax
je     11d7 <main+0x97>
jmp    11f7 <main+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1164 <main+0x24>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1231 <main+0xf1>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fe <main+0xbe>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x7(%rsp),%al
and    $0xdf,%al
mov    $0x1,%r15d
cmp    $0x53,%al
jne    1224 <main+0xe4>
mov    $0x1,%r15d
mov    $0x4,%r14d
lea    0xe91(%rip),%r13
lea    0x7(%rsp),%rbp
lea    0x4(%r14),%r12
mov    %rbx,%rdi
mov    %r12d,%esi
call   1050 <realloc@plt>
mov    %rax,%rbx
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rsi
add    %r14,%rsi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
and    $0xdf,%al
add    $0x1,%r15
mov    %r12,%r14
cmp    $0x53,%al
je     11c0 <main+0x80>
mov    %r15d,%r15d
lea    0xe25(%rip),%r14
xor    %ebp,%ebp
nopl   (%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1230 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Digite um valor para salvar no vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Deseja cadastrar mais um numero? \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [7 x i8] c" (%d) \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = call i32* @malloc(i32 4)
store i32* %6, i32** %2
br label %7
7: ; preds = %0, %26
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 115
br i1 %20, label %21, label %26
21: ; preds = %7
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 83
br i1 %24, label %25, label %26
25: ; preds = %21
br label %34
26: ; preds = %21, %7
%27 = load i32*, i32** %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = mul i64 4, %30
%32 = trunc i64 %31 to i32
%33 = call i32* @realloc(i32* %27, i32 %32)
store i32* %33, i32** %2
br label %7
34: ; preds = %25
store i32 0, i32* %5
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %5
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i32*, i32** %2
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %35
49: ; preds = %35
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [39 x i8] c"Digite um valor para salvar no vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Deseja cadastrar mais um numero? \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [7 x i8] c" (%d) \00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32* @malloc(i32 4)
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%7 = load i8, i8* %1
%8 = and i8 %7, -33
%9 = icmp eq i8 %8, 83
br i1 %9, label %16, label %13
10: ; preds = %16
%11 = add i64 %17, 2
%12 = and i64 %11, 4294967295
br label %13
13: ; preds = %10, %0
%14 = phi i32* [ %2, %0 ], [ %23, %10 ]
%15 = phi i64 [ 1, %0 ], [ %12, %10 ]
br label %33
16: ; preds = %0, %16
%17 = phi i64 [ %19, %16 ], [ 0, %0 ]
%18 = phi i32* [ %23, %16 ], [ %2, %0 ]
%19 = add nuw i64 %17, 1
%20 = trunc i64 %17 to i32
%21 = shl i32 %20, 2
%22 = add i32 %21, 8
%23 = call i32* @realloc(i32* %18, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds i32, i32* %23, i64 %19
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%29 = load i8, i8* %1
%30 = and i8 %29, -33
%31 = icmp eq i8 %30, 83
br i1 %31, label %16, label %10
32: ; preds = %33
ret i32 0
33: ; preds = %13, %33
%34 = phi i64 [ 0, %13 ], [ %38, %33 ]
%35 = getelementptr inbounds i32, i32* %14, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %15
br i1 %39, label %32, label %33
}