#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*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int hash_container_size(const char *filepath) {
  FILE *file = fopen(filepath, "r");
  if (file == NULL) {
    fprintf(stderr, " [HASH_CONTAINER_SIZE] : Given file path is not "
                    "open.Could not generate dynamically hash container\n");
    return -1;
  }
  char buffer[1024];
  char *option_tag = malloc(sizeof(char) * 1024);
  int counter = 0;
  char *option_tag_value = malloc(sizeof(char) * 1024);
  while (!feof(file)) {
    if (fgets(buffer, 1024, file) != NULL) {
      if (strlen(buffer) == 1)
        continue;
      sscanf(buffer, "%[^\t:] : %[^\t\n]", option_tag, option_tag_value);
      if (strcmp(option_tag, "hash") != 0 && strcmp(option_tag, "UUID") != 0) {
        counter++;
      }
    }
  }
  fclose(file);
  free(option_tag_value);
  free(option_tag);
  return counter;
}


x86 assembly (clang, -O0):
<hash_container_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ef <hash_container_size+0x4f>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <hash_container_size+0x170>
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x428(%rbp)
movl   $0x0,-0x42c(%rbp)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x438(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1239 <hash_container_size+0x99>
jmp    12e6 <hash_container_size+0x146>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12e1 <hash_container_size+0x141>
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    1272 <hash_container_size+0xd2>
jmp    121b <hash_container_size+0x7b>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    -0x438(%rbp),%rcx
lea    0xdd8(%rip),%rsi
call   10b0 <sscanf@plt>
mov    -0x428(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12dc <hash_container_size+0x13c>
mov    -0x428(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12dc <hash_container_size+0x13c>
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
jmp    12e1 <hash_container_size+0x141>
jmp    121b <hash_container_size+0x7b>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x438(%rbp),%rdi
call   1030 <free@plt>
mov    -0x428(%rbp),%rdi
call   1030 <free@plt>
mov    -0x42c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_container_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe48(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1276 <hash_container_size+0xd6>
mov    %rax,%rbx
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
xor    %r14d,%r14d
mov    %rsp,%rbp
lea    0xe86(%rip),%r13
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    125c <hash_container_size+0xbc>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f0 <hash_container_size+0x50>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
je     11f0 <hash_container_size+0x50>
mov    %rbp,%rdi
lea    0xe3e(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   10b0 <sscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f0 <hash_container_size+0x50>
mov    %r12,%rdi
lea    0xe2e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r14d
jmp    11f0 <hash_container_size+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    1291 <hash_container_size+0xf1>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [100 x i8] c" [HASH_CONTAINER_SIZE] : Given file path is not open.Could not generate dynamically hash container\0A\00"
@.str.2 = [16 x i8] c"%[^\09:] : %[^\09\0A]\00"
@.str.3 = [5 x i8] c"hash\00"
@.str.4 = [5 x i8] c"UUID\00"
define i32 @hash_container_size(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %59
16: ; preds = %1
%17 = call i8* @malloc(i32 1024)
store i8* %17, i8** %6
store i32 0, i32* %7
%18 = call i8* @malloc(i32 1024)
store i8* %18, i8** %8
br label %19
19: ; preds = %50, %33, %16
%20 = load i32*, i32** %4
%21 = call i32 @feof(i32* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %51
24: ; preds = %19
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = load i32*, i32** %4
%27 = call i32* @fgets(i8* %25, i32 1024, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %50
29: ; preds = %24
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %29
br label %19
34: ; preds = %29
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = load i8*, i8** %6
%37 = load i8*, i8** %8
%38 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %37)
%39 = load i8*, i8** %6
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %34
%43 = load i8*, i8** %6
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %49
49: ; preds = %46, %42, %34
br label %50
50: ; preds = %49, %24
br label %19
51: ; preds = %19
%52 = load i32*, i32** %4
%53 = call i32 @fclose(i32* %52)
%54 = load i8*, i8** %8
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %6
%57 = call i32 @free(i8* %56)
%58 = load i32, i32* %7
store i32 %58, i32* %2
br label %59
59: ; preds = %51, %13
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [100 x i8] c" [HASH_CONTAINER_SIZE] : Given file path is not open.Could not generate dynamically hash container\0A\00"
@.str.2 = [16 x i8] c"%[^\09:] : %[^\09\0A]\00"
@.str.3 = [5 x i8] c"hash\00"
@.str.4 = [5 x i8] c"UUID\00"
define i32 @hash_container_size(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.1, i64 0, i64 0))
br label %38
8: ; preds = %1
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%10 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%11 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
br label %12
12: ; preds = %29, %8
%13 = phi i32 [ %33, %29 ], [ 0, %8 ]
br label %14
14: ; preds = %28, %12
br label %15
15: ; preds = %14, %21
%16 = call i32 @feof(i32* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = call i32* @fgets(i8* %9, i32 1024, i32* %3)
%20 = icmp eq i32* %19, null
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = call i32 @strlen(i8* %9)
%23 = icmp eq i32 %22, 1
br i1 %23, label %15, label %24
24: ; preds = %21
%25 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %11)
%26 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %18, %24
br label %14
29: ; preds = %24
%30 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
%33 = add nuw nsw i32 %13, %32
br label %12
34: ; preds = %15
%35 = call i32 @fclose(i32* %3)
%36 = call i32 @free(i8* %11)
%37 = call i32 @free(i8* %10)
br label %38
38: ; preds = %34, %5
%39 = phi i32 [ -1, %5 ], [ %13, %34 ]
ret i32 %39
}