#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int cant, i, edad, *puntero;
  printf("Ingrese la cantidad de niños: ");
  scanf("%d", &cant);
  puntero = (int *)calloc(cant, sizeof(int));
  if (puntero == NULL) {
    puts("ERROR! No hay memoria");
    return 0;
  }
  for (i = 0; i < cant; i++) {
    printf("Edad del niño (%d): ", i + 1);
    scanf("%d", &edad);
  }
  for (i = 0; i < cant; i++)
    printf("El niño %d tiene %d años\n", i + 1, edad);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <main+0x61>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1225 <main+0xe5>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e6 <main+0xa6>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe51(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x68>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <main+0xde>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ed <main+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     11ea <main+0xaa>
cmpl   $0x0,(%rsp)
jle    11f6 <main+0xb6>
lea    0xeb6(%rip),%r14
lea    0xe96(%rip),%r15
lea    0x4(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%eax
cmp    %eax,%ebp
jl     11a0 <main+0x60>
test   %eax,%eax
jle    11f6 <main+0xb6>
lea    0xe83(%rip),%rbx
xor    %ebp,%ebp
xchg   %ax,%ax
add    $0x1,%ebp
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    (%rsp),%ebp
jl     11d0 <main+0x90>
jmp    11f6 <main+0xb6>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Ingrese la cantidad de ni\C3\B1os: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"ERROR! No hay memoria\00"
@.str.3 = [22 x i8] c"Edad del ni\C3\B1o (%d): \00"
@.str.4 = [28 x i8] c"El ni\C3\B1o %d tiene %d a\C3\B1os\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call i64 @calloc(i32 %8, i32 4)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
15: ; preds = %0
store i32 0, i32* %3
br label %16
16: ; preds = %25, %15
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %25
25: ; preds = %20
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %16
28: ; preds = %16
store i32 0, i32* %3
br label %29
29: ; preds = %38, %28
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36)
br label %38
38: ; preds = %33
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %29
41: ; preds = %29
store i32 0, i32* %1
br label %42
42: ; preds = %41, %13
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [32 x i8] c"Ingrese la cantidad de ni\C3\B1os: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"ERROR! No hay memoria\00"
@.str.3 = [22 x i8] c"Edad del ni\C3\B1o (%d): \00"
@.str.4 = [28 x i8] c"El ni\C3\B1o %d tiene %d a\C3\B1os\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i64 @calloc(i32 %7, i32 4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %17, label %31
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %31
15: ; preds = %17
%16 = icmp sgt i32 %22, 0
br i1 %16, label %24, label %31
17: ; preds = %10, %17
%18 = phi i32 [ %19, %17 ], [ 0, %10 ]
%19 = add nuw nsw i32 %18, 1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %1
%23 = icmp slt i32 %19, %22
br i1 %23, label %17, label %15
24: ; preds = %15, %24
%25 = phi i32 [ %26, %24 ], [ 0, %15 ]
%26 = add nuw nsw i32 %25, 1
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32, i32* %1
%30 = icmp slt i32 %26, %29
br i1 %30, label %24, label %31
31: ; preds = %24, %10, %15, %13
ret i32 0
}