#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *);
scalar_t__ strcmp(char const *, char *);
int find_in_db(FILE *fdb, const char *login, const char *pass) {
  char mode;
  char l[11];
  char p[11];
  while (3 == fscanf(fdb, " %10[a-zA-Z] %10[^;\t\r\n ] %c", l, p, &mode)) {
    if (0 == strcmp(login, l) && 0 == strcmp(pass, p))
      return mode - '0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_in_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x2c(%rbp),%rdx
lea    -0x37(%rbp),%rcx
lea    0xeb9(%rip),%rsi
lea    -0x21(%rbp),%r8
call   1030 <fscanf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jne    11a9 <find_in_db+0x89>
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a4 <find_in_db+0x84>
mov    -0x20(%rbp),%rdi
lea    -0x37(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a4 <find_in_db+0x84>
movsbl -0x21(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <find_in_db+0x90>
jmp    1134 <find_in_db+0x14>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_in_db>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xec0(%rip),%rsi
lea    0x1d(%rsp),%rdx
lea    0x12(%rsp),%rcx
lea    0x7(%rsp),%r8
call   1030 <fscanf@plt>
xor    %ecx,%ecx
cmp    $0x3,%eax
jne    11c7 <find_in_db+0xa7>
lea    0x1d(%rsp),%rbp
lea    0x12(%rsp),%r13
lea    0xe94(%rip),%r12
lea    0x7(%rsp),%r14
jmp    1199 <find_in_db+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <fscanf@plt>
cmp    $0x3,%eax
jne    11c5 <find_in_db+0xa5>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <find_in_db+0x60>
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <find_in_db+0x60>
movsbl 0x7(%rsp),%ecx
add    $0xffffffd0,%ecx
jmp    11c7 <find_in_db+0xa7>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c" %10[a-zA-Z] %10[^;\09\0D\0A ] %c\00"
define i32 @find_in_db(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca [11 x i8]
%10 = alloca [11 x i8]
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
br label %11
11: ; preds = %31, %3
%12 = load i32*, i32** %5
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%15 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i8* %8)
%16 = icmp eq i32 3, %15
br i1 %16, label %17, label %32
17: ; preds = %11
%18 = load i8*, i8** %6
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %31
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp eq i64 0, %25
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 48
store i32 %30, i32* %4
br label %33
31: ; preds = %22, %17
br label %11
32: ; preds = %11
store i32 0, i32* %4
br label %33
33: ; preds = %32, %27
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@.str = [28 x i8] c" %10[a-zA-Z] %10[^;\09\0D\0A ] %c\00"
define i32 @find_in_db(i32* nocapture %0, i8* %1, i8* %2) {
%4 = alloca i8
%5 = alloca [11 x i8]
%6 = alloca [11 x i8]
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%9 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8, i8* %4)
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %24
11: ; preds = %3, %21
%12 = call i64 @strcmp(i8* %1, i8* %7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = call i64 @strcmp(i8* %2, i8* %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = add nsw i32 %19, -48
br label %24
21: ; preds = %14, %11
%22 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8, i8* %4)
%23 = icmp eq i32 %22, 3
br i1 %23, label %11, label %24
24: ; preds = %21, %3, %17
%25 = phi i32 [ %20, %17 ], [ 0, %3 ], [ 0, %21 ]
ret i32 %25
}