#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 /*<<< orphan*/ strcmp(char *, char *);
int main() {
  char user[20];
  int senha, contador = 0;
  do {
    printf("Entre com o usuario: ");
    scanf("%s", user);
    printf("Entre com a senha: ");
    scanf("%d", &senha);
    if (!strcmp(user, "leonardo") && senha == 123) {
      printf("\nAcesso concedido.\n");
      break;
    }
    contador++;
  } while (contador < 3);
  if (contador == 3)
    printf("Limite de tentativas alcancadas.\n");
  printf("Fim.\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b6 <main+0x86>
cmpl   $0x7b,-0x24(%rbp)
jne    11b6 <main+0x86>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    11c9 <main+0x99>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jl     1146 <main+0x16>
cmpl   $0x3,-0x28(%rbp)
jne    11df <main+0xaf>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movabs $0x6f6472616e6f656c,%rbx
72 64 6f
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%rax
xor    %rbx,%rax
movzbl 0x18(%rsp),%ecx
or     %rax,%rcx
jne    119a <main+0x6a>
cmpl   $0x7b,0xc(%rsp)
je     124c <main+0x11c>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
lea    0xe61(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%rax
xor    %rbx,%rax
movzbl 0x18(%rsp),%ecx
or     %rax,%rcx
jne    11f1 <main+0xc1>
cmpl   $0x7b,0xc(%rsp)
je     124c <main+0x11c>
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
lea    0xe12(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xor    0x10(%rsp),%rbx
movzbl 0x18(%rsp),%eax
or     %rbx,%rax
lea    0xdfb(%rip),%rdi
jne    1253 <main+0x123>
cmpl   $0x7b,0xc(%rsp)
jne    1253 <main+0x123>
lea    0xe0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xdda(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Entre com o usuario: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"Entre com a senha: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"leonardo\00"
@.str.5 = [20 x i8] c"\0AAcesso concedido.\0A\00"
@.str.6 = [34 x i8] c"Limite de tentativas alcancadas.\0A\00"
@.str.7 = [6 x i8] c"Fim.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %22, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %5
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 123
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %25
19: ; preds = %14, %5
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 3
br i1 %24, label %5, label %25
25: ; preds = %22, %17
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [22 x i8] c"Entre com o usuario: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"Entre com a senha: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"leonardo\00"
@str = [5 x i8] c"Fim.\00"
@str.8 = [33 x i8] c"Limite de tentativas alcancadas.\00"
@str.9 = [19 x i8] c"\0AAcesso concedido.\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = call i32 @bcmp(i8* dereferenceable(9) %3, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 9)
%10 = icmp eq i32 %9, 0
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 123
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %34, label %14
14: ; preds = %0
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%19 = call i32 @bcmp(i8* dereferenceable(9) %3, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 9)
%20 = icmp eq i32 %19, 0
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 123
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %34, label %24
24: ; preds = %14
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%29 = call i32 @bcmp(i8* dereferenceable(9) %3, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 9)
%30 = icmp eq i32 %29, 0
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 123
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %34, label %35
34: ; preds = %24, %14, %0
br label %35
35: ; preds = %24, %34
%36 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), %34 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0), %24 ]
%37 = call i32 @puts(i8* dereferenceable(1) %36)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}