#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*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int var_dimensiune;
  printf("INtroduceti dimensiune \n");
  scanf("%i", &var_dimensiune);
  int vector[var_dimensiune];
  int index;
  srand(time(NULL));
  int r = rand() % 100;
  for (r = 0; r < var_dimensiune; r++) {
    int variabila_rand = rand() % 10;
    vector[r] = variabila_rand;
    printf("%i ", vector[r]);
  }
  printf("\n");
  printf("Numerele multiplu de 3 sunt: \n");
  for (r = 0; r < var_dimensiune; r++) {
    if (vector[r] % 3 == 0) {
      printf("%i ", vector[r]);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121c <main+0xcc>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%edx
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cd <main+0x7d>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1293 <main+0x143>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1280 <main+0x130>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <main+0x135>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    123f <main+0xef>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6e(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1080 <scanf@plt>
mov    %rsp,%r14
mov    -0x24(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1090 <rand@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1220 <main+0xb0>
lea    0xe2b(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %esi,(%r12,%rbx,4)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdee(%rip),%rdi
call   1040 <puts@plt>
mov    -0x24(%rbp),%eax
test   %eax,%eax
jle    1283 <main+0x113>
lea    0xdbf(%rip),%r15
xor    %ebx,%ebx
jmp    125c <main+0xec>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    1283 <main+0x113>
mov    (%r12,%rbx,4),%esi
imul   $0xaaaaaaab,%esi,%ecx
add    $0x2aaaaaaa,%ecx
cmp    $0x55555554,%ecx
ja     1250 <main+0xe0>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
jmp    1250 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [4 x i8] c"%i \00"
@str = [24 x i8] c"INtroduceti dimensiune \00"
@str.5 = [30 x i8] c"Numerele multiplu de 3 sunt: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10
%18 = getelementptr inbounds i32, i32* %8, i64 %15
store i32 %17, i32* %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%20 = add nuw nsw i64 %15, 1
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %0
%25 = call i32 @putchar(i32 10)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
%27 = load i32, i32* %1
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %44
29: ; preds = %24, %39
%30 = phi i32 [ %40, %39 ], [ %27, %24 ]
%31 = phi i64 [ %41, %39 ], [ 0, %24 ]
%32 = getelementptr inbounds i32, i32* %8, i64 %31
%33 = load i32, i32* %32
%34 = srem i32 %33, 3
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%38 = load i32, i32* %1
br label %39
39: ; preds = %29, %36
%40 = phi i32 [ %30, %29 ], [ %38, %36 ]
%41 = add nuw nsw i64 %31, 1
%42 = sext i32 %40 to i64
%43 = icmp slt i64 %41, %42
br i1 %43, label %29, label %44
44: ; preds = %39, %24
%45 = call i32 @putchar(i32 10)
ret i32 0
}