#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 EFAULT;
int EINVAL;
scalar_t__ isblank(char);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
char *strchr(char *, char);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char const *, char *);
int get_value(const char *section, const char *node_name, char *revalue) {
  int i;
  char *begin, *end, *p;
  char name_cmp[40] = {0};
  char value_tmp[40] = {0};
  if (section == NULL || node_name == NULL) {
    printf("The section or node name pointer is null\n");
    return -EINVAL;
  }
  snprintf(name_cmp, strlen(node_name) + 1, "%s", node_name);
  p = value_tmp;
  begin = strstr(section, name_cmp);
  if (begin == NULL) {
    return -EFAULT;
  }
  begin += strlen(name_cmp);
  end = strchr(begin, '\n');
  while (isblank(*begin) || (*begin) == '=') {
    begin++;
  }
  strncpy(value_tmp, begin, end - begin);
  for (i = 0; i < strlen(value_tmp); ++i) {
    if (isblank(p[i]))
      p[i] = '\0';
  }
  memcpy(revalue, value_tmp, strlen(value_tmp));
  return 0;
}


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1090 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1090 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
je     11e0 <get_value+0x50>
cmpq   $0x0,-0x18(%rbp)
jne    11ff <get_value+0x6f>
lea    0xe19(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    0x2de3(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    13b0 <get_value+0x220>
lea    -0x70(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rcx
lea    0xe00(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1269 <get_value+0xd9>
xor    %eax,%eax
mov    0x2d99(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    13b0 <get_value+0x220>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isblank@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xa9(%rbp)
jne    12c8 <get_value+0x138>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
sete   %al
mov    %al,-0xa9(%rbp)
mov    -0xa9(%rbp),%al
test   $0x1,%al
jne    12db <get_value+0x14b>
jmp    12ec <get_value+0x15c>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1294 <get_value+0x104>
lea    -0xa0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0xb0(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xb0(%rbp),%eax
cmp    %ecx,%eax
jge    136f <get_value+0x1df>
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <isblank@plt>
cmp    $0x0,%rax
je     135c <get_value+0x1cc>
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1361 <get_value+0x1d1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1310 <get_value+0x180>
mov    -0x20(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb8(%rbp),%rsi
mov    %eax,%edx
call   10a0 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x50(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
test   %rdi,%rdi
je     12a7 <get_value+0x127>
mov    %rsi,%rbx
test   %rsi,%rsi
je     12a7 <get_value+0x127>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%esi
lea    0xe1e(%rip),%rdx
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rcx
call   1080 <snprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10a0 <strstr@plt>
test   %rax,%rax
je     12d8 <get_value+0x158>
mov    %rax,%r12
lea    0x30(%rsp),%rdi
call   1050 <strlen@plt>
movslq %eax,%r13
mov    %r12,%rbx
add    %r13,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,%r15
add    %r12d,%r13d
sub    %r13d,%r15d
jmp    1248 <get_value+0xc8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
add    $0xffffffff,%r15d
movsbl (%rbx),%edi
call   1070 <isblank@plt>
test   %rax,%rax
jne    1240 <get_value+0xc0>
cmpb   $0x3d,(%rbx)
je     1240 <get_value+0xc0>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    12bc <get_value+0x13c>
xor    %ebx,%ebx
mov    %rsp,%r15
jmp    1293 <get_value+0x113>
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    12bc <get_value+0x13c>
movsbl (%rsp,%rbx,1),%edi
call   1070 <isblank@plt>
test   %rax,%rax
je     1280 <get_value+0x100>
movb   $0x0,(%rsp,%rbx,1)
jmp    1280 <get_value+0x100>
lea    0xd55(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d1e(%rip),%rcx
jmp    12df <get_value+0x15f>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1090 <memcpy@plt>
xor    %eax,%eax
jmp    12e3 <get_value+0x163>
mov    0x2d19(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"The section or node name pointer is null\0A\00"
@EINVAL = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@EFAULT = global i32 0
define i32 @get_value(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [40 x i8]
%13 = alloca [40 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%14 = bitcast [40 x i8]* %12 to i8*
%15 = bitcast [40 x i8]* %13 to i8*
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18, %3
%22 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EINVAL
%24 = sub nsw i32 0, %23
store i32 %24, i32* %4
br label %102
25: ; preds = %18
%26 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%27 = load i8*, i8** %6
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %28, 1
%30 = load i8*, i8** %6
%31 = call i32 @snprintf(i8* %26, i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
store i8* %32, i8** %11
%33 = load i8*, i8** %5
%34 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%35 = call i8* @strstr(i8* %33, i8* %34)
store i8* %35, i8** %9
%36 = load i8*, i8** %9
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %41
38: ; preds = %25
%39 = load i32, i32* @EFAULT
%40 = sub nsw i32 0, %39
store i32 %40, i32* %4
br label %102
41: ; preds = %25
%42 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = load i8*, i8** %9
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %9
%47 = load i8*, i8** %9
%48 = call i8* @strchr(i8* %47, i8 signext 10)
store i8* %48, i8** %10
br label %49
49: ; preds = %61, %41
%50 = load i8*, i8** %9
%51 = load i8, i8* %50
%52 = call i64 @isblank(i8 signext %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %49
%55 = load i8*, i8** %9
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 61
br label %59
59: ; preds = %54, %49
%60 = phi i1 [ true, %49 ], [ %58, %54 ]
br i1 %60, label %61, label %64
61: ; preds = %59
%62 = load i8*, i8** %9
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %9
br label %49
64: ; preds = %59
%65 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%66 = load i8*, i8** %9
%67 = load i8*, i8** %10
%68 = load i8*, i8** %9
%69 = ptrtoint i8* %67 to i64
%70 = ptrtoint i8* %68 to i64
%71 = sub i64 %69, %70
%72 = trunc i64 %71 to i32
%73 = call i32 @strncpy(i8* %65, i8* %66, i32 %72)
store i32 0, i32* %8
br label %74
74: ; preds = %93, %64
%75 = load i32, i32* %8
%76 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%77 = call i32 @strlen(i8* %76)
%78 = icmp slt i32 %75, %77
br i1 %78, label %79, label %96
79: ; preds = %74
%80 = load i8*, i8** %11
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = load i8, i8* %83
%85 = call i64 @isblank(i8 signext %84)
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %79
%88 = load i8*, i8** %11
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
store i8 0, i8* %91
br label %92
92: ; preds = %87, %79
br label %93
93: ; preds = %92
%94 = load i32, i32* %8
%95 = add nsw i32 %94, 1
store i32 %95, i32* %8
br label %74
96: ; preds = %74
%97 = load i8*, i8** %7
%98 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%99 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%100 = call i32 @strlen(i8* %99)
%101 = call i32 @memcpy(i8* %97, i8* %98, i32 %100)
store i32 0, i32* %4
br label %102
102: ; preds = %96, %38, %21
%103 = load i32, i32* %4
ret i32 %103
}

LLVM IR (-O2):
@EINVAL = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@EFAULT = global i32 0
@str = [41 x i8] c"The section or node name pointer is null\00"
define i32 @get_value(i8* %0, i8* %1, i8* %2) {
%4 = alloca [40 x i8]
%5 = alloca [40 x i8]
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%8 = icmp eq i8* %0, null
%9 = icmp eq i8* %1, null
%10 = or i1 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @EINVAL
%14 = sub nsw i32 0, %13
br label %62
15: ; preds = %3
%16 = tail call i32 @strlen(i8* %1)
%17 = add nsw i32 %16, 1
%18 = call i32 @snprintf(i8* %6, i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%19 = call i8* @strstr(i8* dereferenceable(1) %0, i8* %6)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @EFAULT
%23 = sub nsw i32 0, %22
br label %62
24: ; preds = %15
%25 = call i32 @strlen(i8* %6)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %19, i64 %26
%28 = call i8* @strchr(i8* %27, i8 signext 10)
br label %29
29: ; preds = %37, %24
%30 = phi i8* [ %27, %24 ], [ %38, %37 ]
%31 = load i8, i8* %30
%32 = call i64 @isblank(i8 signext %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8, i8* %30
%36 = icmp eq i8 %35, 61
br i1 %36, label %37, label %39
37: ; preds = %29, %34
%38 = getelementptr inbounds i8, i8* %30, i64 1
br label %29
39: ; preds = %34
%40 = ptrtoint i8* %28 to i64
%41 = ptrtoint i8* %30 to i64
%42 = sub i64 %40, %41
%43 = trunc i64 %42 to i32
%44 = call i32 @strncpy(i8* %7, i8* %30, i32 %43)
%45 = call i32 @strlen(i8* %7)
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %59
47: ; preds = %39, %54
%48 = phi i64 [ %55, %54 ], [ 0, %39 ]
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i64 @isblank(i8 signext %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %47
store i8 0, i8* %49
br label %54
54: ; preds = %47, %53
%55 = add nuw nsw i64 %48, 1
%56 = call i32 @strlen(i8* %7)
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %55, %57
br i1 %58, label %47, label %59
59: ; preds = %54, %39
%60 = call i32 @strlen(i8* %7)
%61 = call i32 @memcpy(i8* %2, i8* %7, i32 %60)
br label %62
62: ; preds = %59, %21, %11
%63 = phi i32 [ %14, %11 ], [ %23, %21 ], [ 0, %59 ]
ret i32 %63
}