#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 *, char *);
int getKeyAndValue(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int getValueOf(char *key, int *value) {
  FILE *configFile = fopen("config.conf", "r");
  char buffer[100];
  char currentKey[100];
  int currentValue;
  int ret = -1;
  if (configFile == NULL) {
    fclose(configFile);
    return (-1);
  }
  do {
    fgets(buffer, 100, configFile);
    if (getKeyAndValue(buffer, currentKey, &currentValue) == -1) {
      ret = -1;
      break;
    }
    if (strcmp(currentKey, key) == 0) {
      ret = 0;
      *value = currentValue;
      break;
    }
  } while (!feof(configFile));
  fclose(configFile);
  return (ret);
}


x86 assembly (clang, -O0):
<getValueOf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe86(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0xffffffff,-0x108(%rbp)
ff ff ff
cmpq   $0x0,-0x20(%rbp)
jne    11b4 <getValueOf+0x54>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <getValueOf+0x105>
jmp    11b9 <getValueOf+0x59>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0x104(%rbp),%rdx
call   1060 <getKeyAndValue@plt>
cmp    $0xffffffff,%eax
jne    1200 <getValueOf+0xa0>
movl   $0xffffffff,-0x108(%rbp)
ff ff ff
jmp    1253 <getValueOf+0xf3>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1235 <getValueOf+0xd5>
movl   $0x0,-0x108(%rbp)
mov    -0x104(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1253 <getValueOf+0xf3>
jmp    123a <getValueOf+0xda>
mov    -0x20(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b9 <getValueOf+0x59>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x108(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getValueOf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xe82(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f1 <getValueOf+0x91>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
lea    0x80(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0x4(%rsp),%r14
mov    $0xffffffff,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <getKeyAndValue@plt>
cmp    $0xffffffff,%eax
je     120c <getValueOf+0xac>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ff <getValueOf+0x9f>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11b0 <getValueOf+0x50>
jmp    120c <getValueOf+0xac>
xor    %edi,%edi
call   1030 <fclose@plt>
mov    $0xffffffff,%ebp
jmp    1214 <getValueOf+0xb4>
mov    0x4(%rsp),%eax
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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