#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char *copy_string_to_heap(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char const *, char *);
int strlen(char const *);
int /*<<< orphan*/ write_error_var(char *, size_t, char const *);
char *extract_value(char ***key_value, const char *key) {
  for (int i = 0; i < 4; i++) {
    if (!strcmp(key, key_value[0][i])) {
      key_value[0][i][0] = '\0';
      return copy_string_to_heap(key_value[1][i]);
    }
  }
  size_t size = strlen("Configuration value %s couldn't be found. Exiting.") +
                strlen(key) + 1;
  write_error_var("Configuration value %s couldn't be found. Exiting.", size,
                  key);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<extract_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11d2 <extract_value+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11bf <extract_value+0x6f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <copy_string_to_heap@plt>
add    $0x30,%rsp
pop    %rbp
ret
jmp    11c4 <extract_value+0x74>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <extract_value+0x17>
lea    0xe27(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xdf7(%rip),%rdi
call   1040 <write_error_var@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<extract_value>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%r12
mov    (%r12),%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11ef <extract_value+0x9f>
mov    0x8(%r12),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11f3 <extract_value+0xa3>
mov    0x10(%r12),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11fa <extract_value+0xaa>
mov    0x18(%r12),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
mov    $0x3,%ecx
test   %eax,%eax
je     11ff <extract_value+0xaf>
lea    0xe44(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x1,%eax
movslq %eax,%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1040 <write_error_var@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
xor    %ecx,%ecx
jmp    11ff <extract_value+0xaf>
mov    $0x1,%ecx
jmp    11ff <extract_value+0xaf>
mov    $0x2,%ecx
movb   $0x0,(%rbx)
mov    0x8(%r14),%rax
mov    (%rax,%rcx,8),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <copy_string_to_heap@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Configuration value %s couldn't be found. Exiting.\00"
@EXIT_FAILURE = global i32 0
define i8* @extract_value(i8*** %0, i8* %1) {
%3 = alloca i8***
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
store i8*** %0, i8**** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %7
7: ; preds = %39, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %42
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = load i8***, i8**** %3
%13 = getelementptr inbounds i8**, i8*** %12, i64 0
%14 = load i8**, i8*** %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %11, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %38, label %21
21: ; preds = %10
%22 = load i8***, i8**** %3
%23 = getelementptr inbounds i8**, i8*** %22, i64 0
%24 = load i8**, i8*** %23
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 0, i8* %29
%30 = load i8***, i8**** %3
%31 = getelementptr inbounds i8**, i8*** %30, i64 1
%32 = load i8**, i8*** %31
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i8* @copy_string_to_heap(i8* %36)
ret i8* %37
38: ; preds = %10
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %7
42: ; preds = %7
%43 = call i32 @strlen(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%44 = load i8*, i8** %4
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %43, %45
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
store i64 %48, i64* %6
%49 = load i64, i64* %6
%50 = load i8*, i8** %4
%51 = call i32 @write_error_var(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 %49, i8* %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
}

LLVM IR (-O2):
@.str = [51 x i8] c"Configuration value %s couldn't be found. Exiting.\00"
@EXIT_FAILURE = global i32 0
define i8* @extract_value(i8*** nocapture %0, i8* %1) {
%3 = load i8**, i8*** %0
%4 = load i8*, i8** %3
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(1) %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %31, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %3, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(1) %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %3, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(1) %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %31, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %3, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(1) %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %17
%23 = tail call i32 @strlen(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%24 = tail call i32 @strlen(i8* %1)
%25 = add i32 %23, 1
%26 = add i32 %25, %24
%27 = sext i32 %26 to i64
%28 = tail call i32 @write_error_var(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 %27, i8* %1)
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %17, %12, %7, %2
%32 = phi i64 [ 0, %2 ], [ 1, %7 ], [ 2, %12 ], [ 3, %17 ]
%33 = phi i8* [ %4, %2 ], [ %9, %7 ], [ %14, %12 ], [ %19, %17 ]
store i8 0, i8* %33
%34 = getelementptr inbounds i8**, i8*** %0, i64 1
%35 = load i8**, i8*** %34
%36 = getelementptr inbounds i8*, i8** %35, i64 %32
%37 = load i8*, i8** %36
%38 = tail call i8* @copy_string_to_heap(i8* %37)
ret i8* %38
}