#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 rand();
void generaAleatorio(int incognita[], int dim) {
  char numeros[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i, randNum;
  for (i = 0; i < dim; i++) {
    do {
      randNum = rand() % 9;
    } while (numeros[randNum] == -1);
    incognita[i] = numeros[randNum];
    numeros[randNum] = -1;
  }
}


x86 assembly (clang, -O0):
<generaAleatorio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x15(%rbp)
mov    0xed8(%rip),%al
mov    %al,-0xd(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119a <generaAleatorio+0x8a>
jmp    114b <generaAleatorio+0x3b>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
movslq -0x20(%rbp),%rax
movsbl -0x15(%rbp,%rax,1),%eax
cmp    $0xffffffff,%eax
je     114b <generaAleatorio+0x3b>
movslq -0x20(%rbp),%rax
movsbl -0x15(%rbp,%rax,1),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x20(%rbp),%rax
movb   $0xff,-0x15(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <generaAleatorio+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generaAleatorio>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movabs $0x807060504030201,%rax
06 07 08
mov    %rax,(%rsp)
movb   $0x9,0x8(%rsp)
test   %esi,%esi
jle    117e <generaAleatorio+0x6e>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
cltq
movsbl (%rsp,%rax,1),%ecx
cmp    $0xffffffff,%ecx
je     1140 <generaAleatorio+0x30>
mov    %ecx,(%r14,%rbx,4)
movb   $0xff,(%rsp,%rax,1)
add    $0x1,%rbx
cmp    %r15,%rbx
jne    1140 <generaAleatorio+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.generaAleatorio.numeros = [9 x i8] c"\01\02\03\04\05\06\07\08\09"
define void @generaAleatorio(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [9 x i8]
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = bitcast [9 x i8]* %5 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %9
br label %14
14: ; preds = %17, %13
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 9
store i32 %16, i32* %7
br label %17
17: ; preds = %14
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, -1
br i1 %23, label %14, label %24
24: ; preds = %17
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i32*, i32** %3
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %35
store i8 -1, i8* %36
br label %37
37: ; preds = %24
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %9
40: ; preds = %9
ret void
}

LLVM IR (-O2):
@__const.generaAleatorio.numeros = [9 x i8] c"\01\02\03\04\05\06\07\08\09"
define void @generaAleatorio(i32* nocapture writeonly %0, i32 %1) {
%3 = alloca [9 x i8]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %23
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %17
%9 = phi i64 [ 0, %6 ], [ %21, %17 ]
br label %10
10: ; preds = %8, %10
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 9
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, -1
br i1 %16, label %10, label %17
17: ; preds = %10
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %13
%19 = sext i8 %15 to i32
%20 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %19, i32* %20
store i8 -1, i8* %18
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %17, %2
ret void
}