#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int tamanho;
  printf("Insira o tamanho do vetor: ");
  scanf("%d", &tamanho);
  int *nums = (int *)malloc(tamanho * sizeof(int));
  int i = 0, count_impares = 0, count_pares = 0;
  for (i = 0; i < tamanho; i++) {
    printf("nums[%d]: ", i);
    scanf("%d", &nums[i]);
    if (nums[i] % 2 == 0) {
      count_pares++;
    } else {
      count_impares++;
    }
  }
  printf("Pares: %d\n", count_pares);
  printf("Impares: %d\n", count_impares);
  free(nums);
  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    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xda>
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4d(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11fe <main+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1207 <main+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120c <main+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x5c>
mov    -0x1c(%rbp),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%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
lea    0xeae(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0x4(%rsp)
mov    $0x0,%ebp
jle    11dd <main+0x9d>
lea    0xe8d(%rip),%r12
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r13d,%r13d
nopl   0x0(%rax)
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r14,%r15,1),%rsi
mov    %r12,%rdi
call   1060 <scanf@plt>
mov    (%r14,%rbx,4),%eax
and    $0x1,%eax
add    %eax,%r13d
xor    $0x1,%eax
add    %eax,%ebp
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     11a0 <main+0x60>
lea    0xe46(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Insira o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"nums[%d]: \00"
@.str.3 = [11 x i8] c"Pares: %d\0A\00"
@.str.4 = [13 x i8] c"Impares: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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), i32* %2)
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %4
br label %15
15: ; preds = %41, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = srem i32 %31, 2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %19
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %40
37: ; preds = %19
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %15
44: ; preds = %15
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %3
%50 = call i32 @free(i32* %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Insira o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"nums[%d]: \00"
@.str.3 = [11 x i8] c"Pares: %d\0A\00"
@.str.4 = [13 x i8] c"Impares: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %0, %11
%12 = phi i64 [ %24, %11 ], [ 0, %0 ]
%13 = phi i32 [ %23, %11 ], [ 0, %0 ]
%14 = phi i32 [ %21, %11 ], [ 0, %0 ]
%15 = trunc i64 %12 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %8, i64 %12
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %17
%20 = and i32 %19, 1
%21 = add nuw nsw i32 %20, %14
%22 = xor i32 %20, 1
%23 = add nuw nsw i32 %22, %13
%24 = add nuw nsw i64 %12, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %11, label %28
28: ; preds = %11, %0
%29 = phi i32 [ 0, %0 ], [ %21, %11 ]
%30 = phi i32 [ 0, %0 ], [ %23, %11 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%33 = call i32 @free(i32* %8)
ret i32 0
}