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

/* Variables and functions */
char *get_value_from_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
char *get_line_from_file(FILE *db, char *id) {
  ssize_t bytesread = 0;
  char *line = NULL;
  size_t n = 0;
  while ((bytesread = getline(&line, &n, db)) > 0) {
    if (line[0] == '#') {
      continue;
    }
    char *lineid = get_value_from_line(line, 0);
    size_t lng = strlen(lineid);
    if (lng < 1) {
      continue;
    }
    if (strncmp(id, lineid, lng) == 0) {
      return line;
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_line_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    11f2 <get_line_from_file+0xb2>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1199 <get_line_from_file+0x59>
jmp    1167 <get_line_from_file+0x27>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1050 <get_value_from_line@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x1,-0x40(%rbp)
jae    11c5 <get_line_from_file+0x85>
jmp    1167 <get_line_from_file+0x27>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ed <get_line_from_file+0xad>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fa <get_line_from_file+0xba>
jmp    1167 <get_line_from_file+0x27>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line_from_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
test   %eax,%eax
jle    11dd <get_line_from_file+0x9d>
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
xor    %r15d,%r15d
jmp    11a2 <get_line_from_file+0x62>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
test   %eax,%eax
jle    11e0 <get_line_from_file+0xa0>
mov    0x8(%rsp),%rdi
cmpb   $0x23,(%rdi)
je     1190 <get_line_from_file+0x50>
xor    %esi,%esi
call   1050 <get_value_from_line@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     1190 <get_line_from_file+0x50>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <get_line_from_file+0x50>
mov    0x8(%rsp),%r15
jmp    11e0 <get_line_from_file+0xa0>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_line_from_file(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i64 0, i64* %8
br label %11
11: ; preds = %38, %29, %21, %2
%12 = load i32*, i32** %4
%13 = call i32 @getline(i8** %7, i64* %8, i32* %12)
store i32 %13, i32* %6
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 35
br i1 %20, label %21, label %22
21: ; preds = %15
br label %11
22: ; preds = %15
%23 = load i8*, i8** %7
%24 = call i8* @get_value_from_line(i8* %23, i32 0)
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = call i64 @strlen(i8* %25)
store i64 %26, i64* %10
%27 = load i64, i64* %10
%28 = icmp ult i64 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %22
br label %11
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = load i8*, i8** %9
%33 = load i64, i64* %10
%34 = call i64 @strncmp(i8* %31, i8* %32, i64 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = load i8*, i8** %7
store i8* %37, i8** %3
br label %40
38: ; preds = %30
br label %11
39: ; preds = %11
store i8* null, i8** %3
br label %40
40: ; preds = %39, %36
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
define i8* @get_line_from_file(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = call i32 @getline(i8** %3, i64* %4, i32* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %2, %13
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 35
br i1 %12, label %13, label %16
13: ; preds = %16, %20, %9
%14 = call i32 @getline(i8** %3, i64* %4, i32* %0)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %9, label %24
16: ; preds = %9
%17 = call i8* @get_value_from_line(i8* %10, i32 0)
%18 = call i64 @strlen(i8* dereferenceable(1) %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %13, label %20
20: ; preds = %16
%21 = call i64 @strncmp(i8* %1, i8* %17, i64 %18)
%22 = icmp eq i64 %21, 0
%23 = load i8*, i8** %3
br i1 %22, label %24, label %13
24: ; preds = %13, %20, %2
%25 = phi i8* [ null, %2 ], [ %23, %20 ], [ null, %13 ]
ret i8* %25
}