#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 */
int /*<<< orphan*/ free(char *);
char *get_value_from_line(char *, int);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
size_t strlen(char *);
unsigned int fill_tac_pool_from_file(char **pool, char *vendor, char *model,
                                     FILE *file) {
  ssize_t bytesread = 0;
  char *line = NULL;
  size_t n = 0;
  unsigned int ret = 0;
  if (vendor == NULL && model == NULL)
    return 0;
  while ((bytesread = getline(&line, &n, file)) > 0) {
    if (*pool == (char *)-1) {
      break;
    }
    if (line[0] == '#') {
      continue;
    }
    char *lineid = get_value_from_line(line, 0);
    size_t lng = strlen(lineid);
    if (lng < 1) {
      continue;
    }
    char *ven = get_value_from_line(line, 1);
    char *mod = get_value_from_line(line, 2);
    if ((vendor == NULL || strcmp(ven, vendor) == 0) &&
        (model == NULL || strcmp(mod, model) == 0)) {
      *pool = lineid;
      pool++;
      ret++;
    }
    free(ven);
    free(mod);
  }
  return ret;
}


x86 assembly (clang, -O0):
<fill_tac_pool_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a8 <fill_tac_pool_from_file+0x58>
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <fill_tac_pool_from_file+0x58>
movl   $0x0,-0x4(%rbp)
jmp    12c9 <fill_tac_pool_from_file+0x179>
jmp    11ad <fill_tac_pool_from_file+0x5d>
mov    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jle    12c3 <fill_tac_pool_from_file+0x173>
mov    -0x10(%rbp),%rax
mov    $0xffffffffffffffff,%rcx
cmp    %rcx,(%rax)
jne    11e3 <fill_tac_pool_from_file+0x93>
jmp    12c3 <fill_tac_pool_from_file+0x173>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11f8 <fill_tac_pool_from_file+0xa8>
jmp    11ad <fill_tac_pool_from_file+0x5d>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1050 <get_value_from_line@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x1,-0x58(%rbp)
jae    1224 <fill_tac_pool_from_file+0xd4>
jmp    11ad <fill_tac_pool_from_file+0x5d>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
call   1050 <get_value_from_line@plt>
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x2,%esi
call   1050 <get_value_from_line@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     126a <fill_tac_pool_from_file+0x11a>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ac <fill_tac_pool_from_file+0x15c>
cmpq   $0x0,-0x20(%rbp)
je     128c <fill_tac_pool_from_file+0x13c>
mov    -0x68(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ac <fill_tac_pool_from_file+0x15c>
mov    -0x50(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
jmp    11ad <fill_tac_pool_from_file+0x5d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_tac_pool_from_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
xor    %r12d,%r12d
mov    %rsi,%rax
or     %rdx,%rax
jne    117d <fill_tac_pool_from_file+0x3d>
mov    %r12d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rcx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rdx,0x28(%rsp)
xor    %r12d,%r12d
lea    0x10(%rsp),%r13
lea    0x30(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
test   %eax,%eax
jle    116b <fill_tac_pool_from_file+0x2b>
cmpq   $0xffffffffffffffff,0x0(%rbp)
je     116b <fill_tac_pool_from_file+0x2b>
mov    0x10(%rsp),%rdi
cmpb   $0x23,(%rdi)
je     11a0 <fill_tac_pool_from_file+0x60>
xor    %esi,%esi
call   1040 <get_value_from_line@plt>
cmpb   $0x0,(%rax)
je     11a0 <fill_tac_pool_from_file+0x60>
mov    %rax,0x20(%rsp)
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
call   1040 <get_value_from_line@plt>
mov    %rax,0x8(%rsp)
mov    0x10(%rsp),%rdi
mov    $0x2,%esi
call   1040 <get_value_from_line@plt>
mov    %rax,0x18(%rsp)
test   %r15,%r15
je     1213 <fill_tac_pool_from_file+0xd3>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    123d <fill_tac_pool_from_file+0xfd>
mov    0x28(%rsp),%rsi
test   %rsi,%rsi
je     122c <fill_tac_pool_from_file+0xec>
mov    0x18(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    123d <fill_tac_pool_from_file+0xfd>
mov    0x20(%rsp),%rax
mov    %rax,0x0(%rbp)
add    $0x8,%rbp
add    $0x1,%r12d
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
jmp    11a0 <fill_tac_pool_from_file+0x60>

LLVM IR (-O0):
define i32 @fill_tac_pool_from_file(i8** %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i8*
store i8** %0, i8*** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32 0, i32* %10
store i8* null, i8** %11
store i64 0, i64* %12
store i32 0, i32* %13
%18 = load i8*, i8** %7
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %4
%21 = load i8*, i8** %8
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %5
br label %83
24: ; preds = %20, %4
br label %25
25: ; preds = %76, %48, %40, %24
%26 = load i32*, i32** %9
%27 = call i32 @getline(i8** %11, i64* %12, i32* %26)
store i32 %27, i32* %10
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %81
29: ; preds = %25
%30 = load i8**, i8*** %6
%31 = load i8*, i8** %30
%32 = icmp eq i8* %31, inttoptr (i64 -1 to i8*)
br i1 %32, label %33, label %34
33: ; preds = %29
br label %81
34: ; preds = %29
%35 = load i8*, i8** %11
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 35
br i1 %39, label %40, label %41
40: ; preds = %34
br label %25
41: ; preds = %34
%42 = load i8*, i8** %11
%43 = call i8* @get_value_from_line(i8* %42, i32 0)
store i8* %43, i8** %14
%44 = load i8*, i8** %14
%45 = call i64 @strlen(i8* %44)
store i64 %45, i64* %15
%46 = load i64, i64* %15
%47 = icmp ult i64 %46, 1
br i1 %47, label %48, label %49
48: ; preds = %41
br label %25
49: ; preds = %41
%50 = load i8*, i8** %11
%51 = call i8* @get_value_from_line(i8* %50, i32 1)
store i8* %51, i8** %16
%52 = load i8*, i8** %11
%53 = call i8* @get_value_from_line(i8* %52, i32 2)
store i8* %53, i8** %17
%54 = load i8*, i8** %7
%55 = icmp eq i8* %54, null
br i1 %55, label %61, label %56
56: ; preds = %49
%57 = load i8*, i8** %16
%58 = load i8*, i8** %7
%59 = call i64 @strcmp(i8* %57, i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %56, %49
%62 = load i8*, i8** %8
%63 = icmp eq i8* %62, null
br i1 %63, label %69, label %64
64: ; preds = %61
%65 = load i8*, i8** %17
%66 = load i8*, i8** %8
%67 = call i64 @strcmp(i8* %65, i8* %66)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %64, %61
%70 = load i8*, i8** %14
%71 = load i8**, i8*** %6
store i8* %70, i8** %71
%72 = load i8**, i8*** %6
%73 = getelementptr inbounds i8*, i8** %72, i32 1
store i8** %73, i8*** %6
%74 = load i32, i32* %13
%75 = add i32 %74, 1
store i32 %75, i32* %13
br label %76
76: ; preds = %69, %64, %56
%77 = load i8*, i8** %16
%78 = call i32 @free(i8* %77)
%79 = load i8*, i8** %17
%80 = call i32 @free(i8* %79)
br label %25
81: ; preds = %33, %25
%82 = load i32, i32* %13
store i32 %82, i32* %5
br label %83
83: ; preds = %81, %23
%84 = load i32, i32* %5
ret i32 %84
}

LLVM IR (-O2):
define i32 @fill_tac_pool_from_file(i8** nocapture %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%9 = icmp eq i8* %1, null
%10 = icmp eq i8* %2, null
%11 = and i1 %9, %10
br i1 %11, label %50, label %12
12: ; preds = %4, %45
%13 = phi i32 [ %46, %45 ], [ 0, %4 ]
%14 = phi i8** [ %47, %45 ], [ %0, %4 ]
br label %15
15: ; preds = %12, %26
br label %16
16: ; preds = %15, %22
%17 = call i32 @getline(i8** %5, i64* %6, i32* %3)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %50
19: ; preds = %16
%20 = load i8*, i8** %14
%21 = icmp eq i8* %20, inttoptr (i64 -1 to i8*)
br i1 %21, label %50, label %22
22: ; preds = %19
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 35
br i1 %25, label %16, label %26
26: ; preds = %22
%27 = call i8* @get_value_from_line(i8* %23, i32 0)
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %15, label %30
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = call i8* @get_value_from_line(i8* %31, i32 1)
%33 = load i8*, i8** %5
%34 = call i8* @get_value_from_line(i8* %33, i32 2)
br i1 %9, label %38, label %35
35: ; preds = %30
%36 = call i64 @strcmp(i8* %32, i8* %1)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35, %30
br i1 %10, label %42, label %39
39: ; preds = %38
%40 = call i64 @strcmp(i8* %34, i8* %2)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39, %38
store i8* %27, i8** %14
%43 = getelementptr inbounds i8*, i8** %14, i64 1
%44 = add i32 %13, 1
br label %45
45: ; preds = %42, %39, %35
%46 = phi i32 [ %44, %42 ], [ %13, %39 ], [ %13, %35 ]
%47 = phi i8** [ %43, %42 ], [ %14, %39 ], [ %14, %35 ]
%48 = call i32 @free(i8* %32)
%49 = call i32 @free(i8* %34)
br label %12
50: ; preds = %16, %19, %4
%51 = phi i32 [ 0, %4 ], [ %13, %19 ], [ %13, %16 ]
ret i32 %51
}