#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 *);
void aleatorio(int niv) {
  int aleat = (rand() % niv) + 1;
  int tent = -1;
  while (aleat != tent) {
    printf("Digite o numero secreto");
    scanf("%d", &tent);
  }
  printf("parabéns voce acertou!!\n");
}


x86 assembly (clang, -O0):
<aleatorio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x4(%rbp)
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1180 <aleatorio+0x50>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1153 <aleatorio+0x23>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aleatorio>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %ebx
mov    %edx,%ebx
add    $0x1,%ebx
movl   $0xffffffff,0x4(%rsp)
ff
cmp    $0xffffffff,%ebx
je     1199 <aleatorio+0x59>
lea    0xe93(%rip),%r14
lea    0xea4(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    0x4(%rsp),%ebx
jne    1180 <aleatorio+0x40>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Digite o numero secreto\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"parab\C3\A9ns voce acertou!!\0A\00"
define void @aleatorio(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @rand()
%6 = load i32, i32* %2
%7 = srem i32 %5, %6
%8 = add nsw i32 %7, 1
store i32 %8, i32* %3
store i32 -1, i32* %4
br label %9
9: ; preds = %13, %1
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %9
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Digite o numero secreto\00"
@.str.1 = [3 x i8] c"%d\00"
@str = [25 x i8] c"parab\C3\A9ns voce acertou!!\00"
define void @aleatorio(i32 %0) {
%2 = alloca i32
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, %0
%5 = add nsw i32 %4, 1
%6 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%7 = icmp eq i32 %5, -1
br i1 %7, label %13, label %8
8: ; preds = %1, %8
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp eq i32 %5, %11
br i1 %12, label %13, label %8
13: ; preds = %8, %1
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
ret void
}