#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
char *strtok(char *, char *);
void lookUpStringEntry(char *filename, char *entry, char *val) {
  FILE *fp;
  fp = fopen(filename, "r");
  if (fp == NULL) {
    printf("\n [ERROR]   Unable to open file %s\n\n", filename);
    exit(0);
  }
  char re[100];
  char *dest = NULL;
  while (fscanf(fp, "%s", re) == 1) {
    if (strcmp(entry, re) == 0) {
      if (fscanf(fp, "%s", re) == 1) {
        if (strstr(re, ";") != NULL) {
          dest = strtok(re, ";");
          strcpy(val, dest);
        }
      }
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<lookUpStringEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11dd <lookUpStringEntry+0x4d>
mov    -0x8(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movq   $0x0,-0x98(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe2d(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1298 <lookUpStringEntry+0x108>
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1293 <lookUpStringEntry+0x103>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xdf3(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    128e <lookUpStringEntry+0xfe>
lea    -0x90(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1289 <lookUpStringEntry+0xf9>
lea    -0x90(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    128e <lookUpStringEntry+0xfe>
jmp    1293 <lookUpStringEntry+0x103>
jmp    11e8 <lookUpStringEntry+0x58>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookUpStringEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe52(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1267 <lookUpStringEntry+0xd7>
mov    %rax,%r12
lea    0xe61(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1250 <lookUpStringEntry+0xc0>
mov    %rsp,%rbx
lea    0xe47(%rip),%r13
lea    0xe43(%rip),%rbp
jmp    1203 <lookUpStringEntry+0x73>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1250 <lookUpStringEntry+0xc0>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    11f0 <lookUpStringEntry+0x60>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    11f0 <lookUpStringEntry+0x60>
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11f0 <lookUpStringEntry+0x60>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <strtok@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    11f0 <lookUpStringEntry+0x60>
mov    %r12,%rdi
call   1040 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd94(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"\0A [ERROR] Unable to open file %s\0A\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c";\00"
define void @lookUpStringEntry(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [100 x i8]
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %3
store i8* null, i8** %9
br label %19
19: ; preds = %46, %18
%20 = load i32*, i32** %7
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%22 = call i32 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %47
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %24
%30 = load i32*, i32** %7
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%32 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %45
34: ; preds = %29
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%36 = call i32* @strstr(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%40 = call i8* @strtok(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %40, i8** %9
%41 = load i8*, i8** %6
%42 = load i8*, i8** %9
%43 = call i32 @strcpy(i8* %41, i8* %42)
br label %44
44: ; preds = %38, %34
br label %45
45: ; preds = %44, %29
br label %46
46: ; preds = %45, %24
br label %19
47: ; preds = %19
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"\0A [ERROR] Unable to open file %s\0A\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c";\00"
define void @lookUpStringEntry(i8* %0, i8* %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %3
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %29
14: ; preds = %10, %26
%15 = call i64 @strcmp(i8* %1, i8* %11)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = call i8* @strchr(i8* %11, i32 59)
%22 = icmp eq i8* %21, null
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @strcpy(i8* %2, i8* %24)
br label %26
26: ; preds = %17, %23, %20, %14
%27 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%28 = icmp eq i32 %27, 1
br i1 %28, label %14, label %29
29: ; preds = %26, %10
%30 = call i32 @fclose(i32* %5)
ret void
}