#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isspace(unsigned char);
int strlen(char *);
int /*<<< orphan*/ strlwr(char *);
scalar_t__ strnicmp(char *, char *, int);
int find_user(char *user, char *user_info, char *file_name) {
  FILE *cfg_file;
  int user_len = strlen(user);
  unsigned char c;
  int success = 0;
  cfg_file = fopen(file_name, "r");
  if (!cfg_file)
    return 0;
  strlwr(user);
  while (fgets(user_info, 128, cfg_file)) {
    if (*user_info == '#' || *user_info == '\n')
      continue;
    c = user_info[user_len];
    if ((isspace(c) || c == ':') && strnicmp(user_info, user, user_len) == 0) {
      success = 1;
      break;
    }
  }
  fclose(cfg_file);
  return success;
}


x86 assembly (clang, -O0):
<find_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c2 <find_user+0x52>
movl   $0x0,-0x4(%rbp)
jmp    1274 <find_user+0x104>
mov    -0x10(%rbp),%rdi
call   1030 <strlwr@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x80,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1265 <find_user+0xf5>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1207 <find_user+0x97>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    120c <find_user+0x9c>
jmp    11cb <find_user+0x5b>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x2d(%rbp)
movzbl -0x2d(%rbp),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
jne    123a <find_user+0xca>
movzbl -0x2d(%rbp),%eax
cmp    $0x3a,%eax
jne    1260 <find_user+0xf0>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <strnicmp@plt>
cmp    $0x0,%rax
jne    1260 <find_user+0xf0>
movl   $0x1,-0x34(%rbp)
jmp    1265 <find_user+0xf5>
jmp    11cb <find_user+0x5b>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_user>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r15
call   1060 <strlen@plt>
mov    %eax,%r13d
lea    0xe6d(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1218 <find_user+0xa8>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlwr@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     121e <find_user+0xae>
movslq %r13d,%r12
jmp    11f5 <find_user+0x85>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <strnicmp@plt>
test   %rax,%rax
je     1237 <find_user+0xc7>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     121c <find_user+0xac>
movzbl (%rbx),%eax
cmp    $0x23,%al
je     11e0 <find_user+0x70>
cmp    $0xa,%al
je     11e0 <find_user+0x70>
movzbl (%rbx,%r12,1),%ebp
mov    %ebp,%edi
call   1070 <isspace@plt>
cmp    $0x3a,%ebp
je     11c7 <find_user+0x57>
test   %rax,%rax
je     11e0 <find_user+0x70>
jmp    11c7 <find_user+0x57>
xor    %ebp,%ebp
jmp    1226 <find_user+0xb6>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
jmp    121e <find_user+0xae>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @find_user(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %9
store i32 0, i32* %11
%14 = load i8*, i8** %7
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %8
%16 = load i32*, i32** %8
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %3
store i32 0, i32* %4
br label %63
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = call i32 @strlwr(i8* %20)
br label %22
22: ; preds = %58, %37, %19
%23 = load i8*, i8** %6
%24 = load i32*, i32** %8
%25 = call i64 @fgets(i8* %23, i32 128, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %59
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 35
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %32, %27
br label %22
38: ; preds = %32
%39 = load i8*, i8** %6
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
store i8 %43, i8* %10
%44 = load i8, i8* %10
%45 = call i64 @isspace(i8 zeroext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %38
%48 = load i8, i8* %10
%49 = zext i8 %48 to i32
%50 = icmp eq i32 %49, 58
br i1 %50, label %51, label %58
51: ; preds = %47, %38
%52 = load i8*, i8** %6
%53 = load i8*, i8** %5
%54 = load i32, i32* %9
%55 = call i64 @strnicmp(i8* %52, i8* %53, i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %51
store i32 1, i32* %11
br label %59
58: ; preds = %51, %47
br label %22
59: ; preds = %57, %22
%60 = load i32*, i32** %8
%61 = call i32 @fclose(i32* %60)
%62 = load i32, i32* %11
store i32 %62, i32* %4
br label %63
63: ; preds = %59, %18
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @find_user(i8* %0, i8* %1, i8* nocapture %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %31, label %7
7: ; preds = %3
%8 = tail call i32 @strlwr(i8* %0)
%9 = tail call i64 @fgets(i8* %1, i32 128, i32* %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %7
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
br label %14
14: ; preds = %11, %16
%15 = load i8, i8* %1
switch i8 %15, label %19 [
i8 35, label %16
i8 10, label %16
]
16: ; preds = %25, %19, %14, %14
%17 = tail call i64 @fgets(i8* %1, i32 128, i32* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %28, label %14
19: ; preds = %14
%20 = load i8, i8* %13
%21 = tail call i64 @isspace(i8 zeroext %20)
%22 = icmp ne i64 %21, 0
%23 = icmp eq i8 %20, 58
%24 = or i1 %23, %22
br i1 %24, label %25, label %16
25: ; preds = %19
%26 = tail call i64 @strnicmp(i8* %1, i8* %0, i32 %4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %16
28: ; preds = %16, %25, %7
%29 = phi i32 [ 0, %7 ], [ 1, %25 ], [ 0, %16 ]
%30 = tail call i32 @fclose(i32* %5)
br label %31
31: ; preds = %3, %28
%32 = phi i32 [ %29, %28 ], [ 0, %3 ]
ret i32 %32
}