#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 */
float atof(char *);
int atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ isspace(char const);
char *strdup(char *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char const *, int);
int config_parse_entry(void *dst, const char *src, const char *string,
                       int type) {
  int len = strlen(string);
  if (!strncmp(src, string, len) && isspace(src[len])) {
    char *value = src + len + 1;
    while (isspace(*value))
      ++value;
    if (type == 1)
      *((int *)dst) = atoi(value);
    else if (type == 2)
      *((float *)dst) = atof(value);
    else if (type == 3) {
      if (*(char **)dst)
        free(*(char **)dst);
      *(char **)dst = strdup(value);
    } else
      return 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<config_parse_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    129f <config_parse_entry+0x12f>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     129f <config_parse_entry+0x12f>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     1201 <config_parse_entry+0x91>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11da <config_parse_entry+0x6a>
cmpl   $0x1,-0x24(%rbp)
jne    1221 <config_parse_entry+0xb1>
mov    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1293 <config_parse_entry+0x123>
cmpl   $0x2,-0x24(%rbp)
jne    1241 <config_parse_entry+0xd1>
mov    -0x30(%rbp),%rdi
call   1050 <atof@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    128e <config_parse_entry+0x11e>
cmpl   $0x3,-0x24(%rbp)
jne    127d <config_parse_entry+0x10d>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1265 <config_parse_entry+0xf5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1289 <config_parse_entry+0x119>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <config_parse_entry+0x136>
jmp    128e <config_parse_entry+0x11e>
jmp    1293 <config_parse_entry+0x123>
movl   $0x1,-0x4(%rbp)
jmp    12a6 <config_parse_entry+0x136>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_parse_entry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
xor    %r12d,%r12d
test   %eax,%eax
jne    121e <config_parse_entry+0xae>
movslq %r13d,%rbp
movsbl (%rbx,%rbp,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     121e <config_parse_entry+0xae>
add    %rbp,%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1070 <isspace@plt>
test   %rax,%rax
jne    11c0 <config_parse_entry+0x50>
cmp    $0x3,%r15d
je     11f1 <config_parse_entry+0x81>
cmp    $0x2,%r15d
je     120b <config_parse_entry+0x9b>
cmp    $0x1,%r15d
jne    121e <config_parse_entry+0xae>
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %eax,(%r14)
jmp    1218 <config_parse_entry+0xa8>
mov    (%r14),%rdi
test   %rdi,%rdi
je     11fe <config_parse_entry+0x8e>
call   1030 <free@plt>
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    %rax,(%r14)
jmp    1218 <config_parse_entry+0xa8>
mov    %rbx,%rdi
call   1050 <atof@plt>
movss  %xmm0,(%r14)
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @config_parse_entry(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %8
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %10
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i32, i32* %10
%17 = call i32 @strncmp(i8* %14, i8* %15, i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %79, label %19
19: ; preds = %4
%20 = load i8*, i8** %7
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i64 @isspace(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %79
27: ; preds = %19
%28 = load i8*, i8** %7
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %11
br label %33
33: ; preds = %38, %27
%34 = load i8*, i8** %11
%35 = load i8, i8* %34
%36 = call i64 @isspace(i8 signext %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %11
br label %33
41: ; preds = %33
%42 = load i32, i32* %9
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i8*, i8** %11
%46 = call i32 @atoi(i8* %45)
%47 = load i8*, i8** %6
%48 = bitcast i8* %47 to i32*
store i32 %46, i32* %48
br label %78
49: ; preds = %41
%50 = load i32, i32* %9
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i8*, i8** %11
%54 = call float @atof(i8* %53)
%55 = load i8*, i8** %6
%56 = bitcast i8* %55 to float*
store float %54, float* %56
br label %77
57: ; preds = %49
%58 = load i32, i32* %9
%59 = icmp eq i32 %58, 3
br i1 %59, label %60, label %75
60: ; preds = %57
%61 = load i8*, i8** %6
%62 = bitcast i8* %61 to i8**
%63 = load i8*, i8** %62
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %70
65: ; preds = %60
%66 = load i8*, i8** %6
%67 = bitcast i8* %66 to i8**
%68 = load i8*, i8** %67
%69 = call i32 @free(i8* %68)
br label %70
70: ; preds = %65, %60
%71 = load i8*, i8** %11
%72 = call i8* @strdup(i8* %71)
%73 = load i8*, i8** %6
%74 = bitcast i8* %73 to i8**
store i8* %72, i8** %74
br label %76
75: ; preds = %57
store i32 0, i32* %5
br label %80
76: ; preds = %70
br label %77
77: ; preds = %76, %52
br label %78
78: ; preds = %77, %44
store i32 1, i32* %5
br label %80
79: ; preds = %19, %4
store i32 0, i32* %5
br label %80
80: ; preds = %79, %78, %75
%81 = load i32, i32* %5
ret i32 %81
}

LLVM IR (-O2):
define i32 @config_parse_entry(i8* nocapture %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %2)
%6 = tail call i32 @strncmp(i8* %1, i8* %2, i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %4
%9 = sext i32 %5 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @isspace(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %35, label %14
14: ; preds = %8, %14
%15 = phi i8* [ %16, %14 ], [ %10, %8 ]
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = tail call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %14
20: ; preds = %14
switch i32 %3, label %35 [
i32 1, label %21
i32 2, label %24
i32 3, label %27
]
21: ; preds = %20
%22 = tail call i32 @atoi(i8* %16)
%23 = bitcast i8* %0 to i32*
store i32 %22, i32* %23
br label %35
24: ; preds = %20
%25 = tail call float @atof(i8* %16)
%26 = bitcast i8* %0 to float*
store float %25, float* %26
br label %35
27: ; preds = %20
%28 = bitcast i8* %0 to i8**
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = tail call i32 @free(i8* %29)
br label %33
33: ; preds = %31, %27
%34 = tail call i8* @strdup(i8* %16)
store i8* %34, i8** %28
br label %35
35: ; preds = %4, %8, %20, %24, %33, %21
%36 = phi i32 [ 0, %20 ], [ 1, %24 ], [ 1, %33 ], [ 1, %21 ], [ 0, %8 ], [ 0, %4 ]
ret i32 %36
}