#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*/ LC_ALL;
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "");
  int tamanho;
  printf("Insira o tamanho do vetor de inteiros: ");
  scanf("%d", &tamanho);
  printf("########\n");
  int X;
  printf("Insira o valor de X que será analisado os múltiplos: ");
  scanf("%d", &X);
  printf("########\n");
  int *nums = (int *)malloc(tamanho * sizeof(int));
  int *mult = (int *)malloc(tamanho * sizeof(int));
  printf("Insira valores nas posições do vetor: \n");
  int i = 0, count = 0;
  for (i = 0; i < tamanho; i++) {
    printf("nums[%d]: ", i);
    scanf("%d", &nums[i]);
    if (X % nums[i] == 0) {
      mult[count] = nums[i];
      count++;
    }
  }
  printf("########\n");
  printf("Múltiplos: ");
  for (i = 0; i < count; i++) {
    if (i < count - 1) {
      printf("%d, ", mult[i]);
    } else {
      printf("%d.\n", mult[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xf37(%rip),%rsi
call   1050 <setlocale@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1287 <main+0x147>
mov    -0x24(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdf0(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rsi
cltd
idivl  (%rcx,%rsi,4)
cmp    $0x0,%edx
jne    1274 <main+0x134>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1279 <main+0x139>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1205 <main+0xc5>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1311 <main+0x1d1>
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12e5 <main+0x1a5>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fe <main+0x1be>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1303 <main+0x1c3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12aa <main+0x16a>
xor    %eax,%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    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xf19(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe89(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0xf15(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    (%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    (%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,(%rsp)
jle    1259 <main+0x109>
lea    0xe2f(%rip),%r12
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1221 <main+0xd1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
movslq (%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jge    1259 <main+0x109>
lea    0xe3b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r15,%r13,1),%rsi
mov    %r12,%rdi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
mov    0x0(%r13,%rbx,4),%ecx
cltd
idiv   %ecx
test   %edx,%edx
jne    1210 <main+0xc0>
movslq %ebp,%rbp
mov    %ecx,(%r14,%rbp,4)
add    $0x1,%ebp
jmp    1210 <main+0xc0>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    12ae <main+0x15e>
lea    -0x1(%rbp),%r13d
mov    %ebp,%ebp
lea    0xdf7(%rip),%r15
lea    0xdf5(%rip),%r12
xor    %ebx,%ebx
nopl   (%rax)
cmp    %r13,%rbx
mov    (%r14,%rbx,4),%esi
mov    %r12,%rdi
cmovb  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1290 <main+0x140>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [40 x i8] c"Insira o tamanho do vetor de inteiros: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"########\0A\00"
@.str.4 = [56 x i8] c"Insira o valor de X que ser\C3\A1 analisado os m\C3\BAltiplos: \00"
@.str.5 = [42 x i8] c"Insira valores nas posi\C3\A7\C3\B5es do vetor: \0A\00"
@.str.6 = [11 x i8] c"nums[%d]: \00"
@.str.7 = [13 x i8] c"M\C3\BAltiplos: \00"
@.str.8 = [5 x i8] c"%d, \00"
@.str.9 = [5 x i8] c"%d.\0A\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
%8 = load i32, i32* @LC_ALL
%9 = call i32 @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %4
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %6
br label %29
29: ; preds = %62, %0
%30 = load i32, i32* %6
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %65
33: ; preds = %29
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = load i32*, i32** %4
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %39)
%41 = load i32, i32* %3
%42 = load i32*, i32** %4
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = srem i32 %41, %46
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %61
49: ; preds = %33
%50 = load i32*, i32** %4
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = load i32, i32* %53
%55 = load i32*, i32** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
store i32 %54, i32* %58
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %61
61: ; preds = %49, %33
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %29
65: ; preds = %29
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %6
br label %68
68: ; preds = %92, %65
%69 = load i32, i32* %6
%70 = load i32, i32* %7
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %95
72: ; preds = %68
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = sub nsw i32 %74, 1
%76 = icmp slt i32 %73, %75
br i1 %76, label %77, label %84
77: ; preds = %72
%78 = load i32*, i32** %5
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %78, i64 %80
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %82)
br label %91
84: ; preds = %72
%85 = load i32*, i32** %5
%86 = load i32, i32* %6
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %89)
br label %91
91: ; preds = %84, %77
br label %92
92: ; preds = %91
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 1
store i32 %94, i32* %6
br label %68
95: ; preds = %68
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [40 x i8] c"Insira o tamanho do vetor de inteiros: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [56 x i8] c"Insira o valor de X que ser\C3\A1 analisado os m\C3\BAltiplos: \00"
@.str.6 = [11 x i8] c"nums[%d]: \00"
@.str.7 = [13 x i8] c"M\C3\BAltiplos: \00"
@.str.8 = [5 x i8] c"%d, \00"
@.str.9 = [5 x i8] c"%d.\0A\00"
@str.11 = [41 x i8] c"Insira valores nas posi\C3\A7\C3\B5es do vetor: \00"
@str.12 = [9 x i8] c"########\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%9 = bitcast i32* %2 to i8*
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = shl i32 %13, 2
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
%17 = load i32, i32* %1
%18 = shl i32 %17, 2
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %45
24: ; preds = %0, %39
%25 = phi i64 [ %41, %39 ], [ 0, %0 ]
%26 = phi i32 [ %40, %39 ], [ 0, %0 ]
%27 = trunc i64 %25 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i32, i32* %16, i64 %25
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %29)
%31 = load i32, i32* %2
%32 = load i32, i32* %29
%33 = srem i32 %31, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %24
%36 = sext i32 %26 to i64
%37 = getelementptr inbounds i32, i32* %20, i64 %36
store i32 %32, i32* %37
%38 = add nsw i32 %26, 1
br label %39
39: ; preds = %24, %35
%40 = phi i32 [ %38, %35 ], [ %26, %24 ]
%41 = add nuw nsw i64 %25, 1
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %41, %43
br i1 %44, label %24, label %45
45: ; preds = %39, %0
%46 = phi i32 [ 0, %0 ], [ %40, %39 ]
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%49 = icmp sgt i32 %46, 0
br i1 %49, label %50, label %63
50: ; preds = %45
%51 = add nsw i32 %46, -1
%52 = zext i32 %51 to i64
%53 = zext i32 %46 to i64
br label %54
54: ; preds = %50, %54
%55 = phi i64 [ 0, %50 ], [ %61, %54 ]
%56 = icmp ult i64 %55, %52
%57 = getelementptr inbounds i32, i32* %20, i64 %55
%58 = load i32, i32* %57
%59 = select i1 %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %59, i32 %58)
%61 = add nuw nsw i64 %55, 1
%62 = icmp eq i64 %61, %53
br i1 %62, label %63, label %54
63: ; preds = %54, %45
ret i32 0
}