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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char const *);
int checkuser(const char *filename, const char *name) {
  FILE *fp;
  int found = 0;
  char *p, line[BUFSIZ];
  fp = fopen(filename, "r");
  if (fp != NULL) {
    while (fgets(line, sizeof(line), fp) != NULL) {
      if (line[0] == '#')
        continue;
      p = strchr(line, '\n');
      if (p != NULL) {
        *p = '\0';
        if (strcmp(line, name) == 0) {
          found = 1;
          break;
        }
      }
    }
    (void)fclose(fp);
  }
  return (found);
}


x86 assembly (clang, -O0):
<checkuser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1247 <checkuser+0xf7>
jmp    11bb <checkuser+0x6b>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     123e <checkuser+0xee>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11ed <checkuser+0x9d>
jmp    11bb <checkuser+0x6b>
mov    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1239 <checkuser+0xe9>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <checkuser+0xe4>
movl   $0x1,-0x1c(%rbp)
jmp    123e <checkuser+0xee>
jmp    1239 <checkuser+0xe9>
jmp    11bb <checkuser+0x6b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkuser>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2e78(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fd <checkuser+0xad>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
xor    %r13d,%r13d
jmp    11be <checkuser+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11f3 <checkuser+0xa3>
cmpb   $0x23,(%rbx)
je     11b0 <checkuser+0x60>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b0 <checkuser+0x60>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11b0 <checkuser+0x60>
mov    $0x1,%r13d
mov    %r12,%rdi
call   1030 <fclose@plt>
jmp    1200 <checkuser+0xb0>
xor    %r13d,%r13d
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
define i32 @checkuser(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%10 = load i32, i32* @BUFSIZ
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i8, i64 %11
store i64 %11, i64* %9
%14 = load i8*, i8** %3
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %5
%16 = load i32*, i32** %5
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %45
18: ; preds = %2
br label %19
19: ; preds = %41, %29, %18
%20 = trunc i64 %11 to i32
%21 = load i32*, i32** %5
%22 = call i32* @fgets(i8* %13, i32 %20, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %42
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %13, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 35
br i1 %28, label %29, label %30
29: ; preds = %24
br label %19
30: ; preds = %24
%31 = call i8* @strchr(i8* %13, i8 signext 10)
store i8* %31, i8** %7
%32 = load i8*, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i8*, i8** %7
store i8 0, i8* %35
%36 = load i8*, i8** %4
%37 = call i64 @strcmp(i8* %13, i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 1, i32* %6
br label %42
40: ; preds = %34
br label %41
41: ; preds = %40, %30
br label %19
42: ; preds = %39, %19
%43 = load i32*, i32** %5
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %42, %2
%46 = load i32, i32* %6
%47 = load i8*, i8** %8
ret i32 %46
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
define i32 @checkuser(i8* nocapture %0, i8* %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %26, label %8
8: ; preds = %2
%9 = call i32* @fgets(i8* %5, i32 %3, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %23, label %11
11: ; preds = %8, %20
%12 = load i8, i8* %5
%13 = icmp eq i8 %12, 35
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = call i8* @strchr(i8* %5, i8 signext 10)
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
store i8 0, i8* %15
%18 = call i64 @strcmp(i8* %5, i8* %1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %14, %17, %11
%21 = call i32* @fgets(i8* %5, i32 %3, i32* %6)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %11
23: ; preds = %20, %17, %8
%24 = phi i32 [ 0, %8 ], [ 1, %17 ], [ 0, %20 ]
%25 = call i32 @fclose(i32* %6)
br label %26
26: ; preds = %23, %2
%27 = phi i32 [ %24, %23 ], [ 0, %2 ]
ret i32 %27
}