#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 /*<<< orphan*/ scanf(char *, int *);
void password() {
  int clave_usuario, clave_secreta = 246;
  int oportunidades = 0;
  do {
    printf("Para ingresar al sistema, \n");
    printf("por favor ingresa la clave secreta: ");
    scanf("%d", &clave_usuario);
    oportunidades++;
  } while (oportunidades < 3 && clave_usuario != clave_secreta);
  if (clave_usuario != clave_secreta)
    printf("Tus oportunidades se agotaron.\n");
  else
    printf("Has accedido..\n");
}


x86 assembly (clang, -O0):
<password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xf6,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x3,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jge    1182 <password+0x62>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1136 <password+0x16>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11aa <password+0x8a>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <password+0x96>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<password>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
lea    0xee3(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xed2(%rip),%r12
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%ebp
ja     118e <password+0x5e>
add    $0x1,%ebp
cmp    $0xf6,%eax
jne    1160 <password+0x30>
cmp    $0xf6,%eax
lea    0xeb8(%rip),%rax
lea    0xea2(%rip),%rdi
cmovne %rax,%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Para ingresar al sistema, \0A\00"
@.str.1 = [37 x i8] c"por favor ingresa la clave secreta: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Tus oportunidades se agotaron.\0A\00"
@.str.4 = [16 x i8] c"Has accedido..\0A\00"
define void @password() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 246, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %17, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 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 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %3
br label %10
10: ; preds = %4
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = icmp ne i32 %14, %15
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %4, label %19
19: ; preds = %17
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %27
25: ; preds = %19
%26 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
ret void
}

LLVM IR (-O2):
@.str.1 = [37 x i8] c"por favor ingresa la clave secreta: \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [27 x i8] c"Para ingresar al sistema, \00"
@str.5 = [15 x i8] c"Has accedido..\00"
@str.6 = [31 x i8] c"Tus oportunidades se agotaron.\00"
define void @password() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i32 [ 0, %0 ], [ %8, %3 ]
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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 = add nuw nsw i32 %4, 1
%9 = icmp ult i32 %4, 2
%10 = load i32, i32* %1
%11 = icmp ne i32 %10, 246
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %3, label %13
13: ; preds = %3
%14 = select i1 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0)
%15 = call i32 @puts(i8* dereferenceable(1) %14)
ret void
}