#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 */
char *copy_string_to_heap(char *);
void *easy_malloc(int);
char *easy_readline_var(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
char *strsep(char **, char *);
int /*<<< orphan*/ write_error(char *);
char ***extract_lines(FILE *conf_file) {
  char ***key_value = easy_malloc(2 * sizeof(char **));
  char **keys = easy_malloc(4 * sizeof(char *));
  key_value[0] = keys;
  char **values = easy_malloc(4 * sizeof(char *));
  key_value[1] = values;
  char *newline = NULL;
  for (int i = 0; i < 4; i++) {
    char *temp = easy_readline_var(
        conf_file,
        "Malformed line: Two colons in one line. Check file %s. Exiting.",
        "./config");
    char *line = temp;
    char *token = strsep(&line, ":");
    key_value[0][i] = copy_string_to_heap(token);
    token = strsep(&line, ":");
    newline = strchr(token, '\n');
    *newline = '\0';
    key_value[1][i] = copy_string_to_heap(token);
    if ((line = strsep(&line, ":"))) {
      write_error(
          "Malformed line: Two colons in one line. Check file %s. Exiting.");
    }
    free(temp);
  }
  return key_value;
}


x86 assembly (clang, -O0):
<extract_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x10,%edi
call   1040 <easy_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x20,%edi
call   1040 <easy_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x20,%edi
call   1040 <easy_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    12b2 <extract_lines+0x142>
mov    -0x8(%rbp),%rdi
lea    0xe1f(%rip),%rsi
lea    0xe58(%rip),%rdx
call   1080 <easy_readline_var@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1090 <copy_string_to_heap@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
lea    -0x40(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rdi
call   1090 <copy_string_to_heap@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
lea    -0x40(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     129b <extract_lines+0x12b>
lea    0xd6a(%rip),%rdi
call   1060 <write_error@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11cc <extract_lines+0x5c>
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
mov    $0x10,%edi
call   1040 <easy_malloc@plt>
mov    %rax,%rbx
mov    $0x20,%edi
call   1040 <easy_malloc@plt>
mov    %rax,(%rbx)
mov    $0x20,%edi
call   1040 <easy_malloc@plt>
mov    %rbx,0x8(%rsp)
mov    %rax,0x8(%rbx)
xor    %r14d,%r14d
lea    0xe46(%rip),%rbp
mov    0x8(%rsp),%rbx
jmp    11e6 <extract_lines+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x1,%r14
cmp    $0x4,%r14
je     1278 <extract_lines+0x108>
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
lea    0xe4b(%rip),%rdx
call   1080 <easy_readline_var@plt>
mov    %rax,%r12
mov    %rax,(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
lea    0xe3b(%rip),%r13
mov    %r13,%rsi
call   1070 <strsep@plt>
mov    %rax,%rdi
call   1090 <copy_string_to_heap@plt>
mov    (%rbx),%rcx
mov    %rax,(%rcx,%r14,8)
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <strsep@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1090 <copy_string_to_heap@plt>
mov    0x8(%rbx),%rcx
mov    %rax,(%rcx,%r14,8)
mov    %rsp,%rdi
mov    %r13,%rsi
call   1070 <strsep@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11d0 <extract_lines+0x60>
mov    %rbp,%rdi
call   1060 <write_error@plt>
jmp    11d0 <extract_lines+0x60>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Malformed line: Two colons in one line. Check file %s. Exiting.\00"
@.str.1 = [9 x i8] c"./config\00"
@.str.2 = [2 x i8] c":\00"
define i8*** @extract_lines(i32* %0) {
%2 = alloca i32*
%3 = alloca i8***
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %2
%11 = call i8* @easy_malloc(i32 16)
%12 = bitcast i8* %11 to i8***
store i8*** %12, i8**** %3
%13 = call i8* @easy_malloc(i32 32)
%14 = bitcast i8* %13 to i8**
store i8** %14, i8*** %4
%15 = load i8**, i8*** %4
%16 = load i8***, i8**** %3
%17 = getelementptr inbounds i8**, i8*** %16, i64 0
store i8** %15, i8*** %17
%18 = call i8* @easy_malloc(i32 32)
%19 = bitcast i8* %18 to i8**
store i8** %19, i8*** %5
%20 = load i8**, i8*** %5
%21 = load i8***, i8**** %3
%22 = getelementptr inbounds i8**, i8*** %21, i64 1
store i8** %20, i8*** %22
store i8* null, i8** %6
store i32 0, i32* %7
br label %23
23: ; preds = %58, %1
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %61
26: ; preds = %23
%27 = load i32*, i32** %2
%28 = call i8* @easy_readline_var(i32* %27, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %8
%29 = load i8*, i8** %8
store i8* %29, i8** %9
%30 = call i8* @strsep(i8** %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = call i8* @copy_string_to_heap(i8* %31)
%33 = load i8***, i8**** %3
%34 = getelementptr inbounds i8**, i8*** %33, i64 0
%35 = load i8**, i8*** %34
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* %32, i8** %38
%39 = call i8* @strsep(i8** %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %39, i8** %10
%40 = load i8*, i8** %10
%41 = call i8* @strchr(i8* %40, i8 signext 10)
store i8* %41, i8** %6
%42 = load i8*, i8** %6
store i8 0, i8* %42
%43 = load i8*, i8** %10
%44 = call i8* @copy_string_to_heap(i8* %43)
%45 = load i8***, i8**** %3
%46 = getelementptr inbounds i8**, i8*** %45, i64 1
%47 = load i8**, i8*** %46
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
store i8* %44, i8** %50
%51 = call i8* @strsep(i8** %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %51, i8** %9
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %55
53: ; preds = %26
%54 = call i32 @write_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53, %26
%56 = load i8*, i8** %8
%57 = call i32 @free(i8* %56)
br label %58
58: ; preds = %55
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %23
61: ; preds = %23
%62 = load i8***, i8**** %3
ret i8*** %62
}

LLVM IR (-O2):
@.str = [64 x i8] c"Malformed line: Two colons in one line. Check file %s. Exiting.\00"
@.str.1 = [9 x i8] c"./config\00"
@.str.2 = [2 x i8] c":\00"
define i8*** @extract_lines(i32* %0) {
%2 = alloca i8*
%3 = tail call i8* @easy_malloc(i32 16)
%4 = bitcast i8* %3 to i8***
%5 = tail call i8* @easy_malloc(i32 32)
%6 = bitcast i8* %3 to i8**
store i8* %5, i8** %6
%7 = tail call i8* @easy_malloc(i32 32)
%8 = getelementptr inbounds i8, i8* %3, i64 8
%9 = bitcast i8* %8 to i8***
%10 = bitcast i8* %8 to i8**
store i8* %7, i8** %10
%11 = bitcast i8** %2 to i8*
br label %13
12: ; preds = %29
ret i8*** %4
13: ; preds = %1, %29
%14 = phi i64 [ 0, %1 ], [ %31, %29 ]
%15 = call i8* @easy_readline_var(i32* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %2
%16 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = call i8* @copy_string_to_heap(i8* %16)
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 %14
store i8* %17, i8** %19
%20 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i8* @strchr(i8* dereferenceable(1) %20, i8 signext 10)
store i8 0, i8* %21
%22 = call i8* @copy_string_to_heap(i8* %20)
%23 = load i8**, i8*** %9
%24 = getelementptr inbounds i8*, i8** %23, i64 %14
store i8* %22, i8** %24
%25 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %25, i8** %2
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %13
%28 = call i32 @write_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %13
%30 = call i32 @free(i8* %15)
%31 = add nuw nsw i64 %14, 1
%32 = icmp eq i64 %31, 4
br i1 %32, label %12, label %13
}