#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 l[11];
  char p[11];
  char m;
  while (3 == fscanf(fdb, " %10[a-zA-Z] %10[^;\t\r\n ] %hhd", l, p, &m)) {
    if (0 == strcmp(login, l) && 0 == strcmp(pass, p))
      return m;
  }
  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    -0x2b(%rbp),%rdx
lea    -0x36(%rbp),%rcx
lea    0xeb9(%rip),%rsi
lea    -0x37(%rbp),%r8
call   1030 <fscanf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jne    11a6 <find_in_db+0x86>
mov    -0x18(%rbp),%rdi
lea    -0x2b(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a1 <find_in_db+0x81>
mov    -0x20(%rbp),%rdi
lea    -0x36(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a1 <find_in_db+0x81>
movsbl -0x37(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <find_in_db+0x8d>
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    11c4 <find_in_db+0xa4>
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    11c2 <find_in_db+0xa2>
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
jmp    11c4 <find_in_db+0xa4>
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 = [30 x i8] c" %10[a-zA-Z] %10[^;\09\0D\0A ] %hhd\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 [11 x i8]
%9 = alloca [11 x i8]
%10 = alloca i8
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
br label %11
11: ; preds = %30, %3
%12 = load i32*, i32** %5
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%15 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i8* %10)
%16 = icmp eq i32 3, %15
br i1 %16, label %17, label %31
17: ; preds = %11
%18 = load i8*, i8** %6
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp eq i64 0, %25
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8, i8* %10
%29 = sext i8 %28 to i32
store i32 %29, i32* %4
br label %32
30: ; preds = %22, %17
br label %11
31: ; preds = %11
store i32 0, i32* %4
br label %32
32: ; preds = %31, %27
%33 = load i32, i32* %4
ret i32 %33
}

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