#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(int);
int get_section(char *, char *, char *);
int get_value(char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ write_value(char *, char *, char *, int);
int main(void) {
  int ret;
  char section[4096] = {0};
  char value[40] = {0};
  ret = get_section("./commModule.conf", "RcdCfg", section);
  if (ret < 0) {
    perror("get_section()");
    exit(1);
  }
  printf("The section is:\n%s", section);
  ret = get_value(section, "BoardNum", value);
  if (ret < 0) {
    perror("get_value()");
    exit(1);
  }
  printf("The BoardNum is : %s\n", value);
  write_value("./commModule.conf", "RcdCfg", "BoardNum", 2);
  write_value("./commModule.conf", "RcdCfg", "TimeLength", 258);
  write_value("./commModule.conf", "RcdCfg", "MaxVoltage", 9999);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
lea    -0x1040(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    -0x1010(%rbp),%rdx
lea    0xe4a(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1060 <get_section@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11e5 <main+0x75>
lea    0xe43(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1040(%rbp),%rdx
lea    0xe2d(%rip),%rsi
call   1070 <get_value@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1235 <main+0xc5>
lea    0xe1d(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x1040(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
lea    0xdb1(%rip),%rdi
lea    0xdbc(%rip),%rsi
lea    0xddd(%rip),%rdx
mov    $0x2,%ecx
call   1050 <write_value@plt>
lea    0xd92(%rip),%rdi
lea    0xd9d(%rip),%rsi
lea    0xde9(%rip),%rdx
mov    $0x102,%ecx
call   1050 <write_value@plt>
lea    0xd73(%rip),%rdi
lea    0xd7e(%rip),%rsi
lea    0xdd5(%rip),%rdx
mov    $0x270f,%ecx
call   1050 <write_value@plt>
xor    %eax,%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1038,%rsp
lea    0x30(%rsp),%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe56(%rip),%rdi
lea    0xe61(%rip),%rsi
mov    %rbx,%rdx
call   1060 <get_section@plt>
test   %eax,%eax
js     125a <main+0xea>
lea    0xe5f(%rip),%rdi
lea    0x30(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe5e(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1070 <get_value@plt>
test   %eax,%eax
js     1263 <main+0xf3>
lea    0xe5d(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
lea    0xdff(%rip),%rbx
lea    0xe0a(%rip),%r14
lea    0xe2b(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%ecx
call   1050 <write_value@plt>
lea    0xe3f(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x102,%ecx
call   1050 <write_value@plt>
lea    0xe33(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x270f,%ecx
call   1050 <write_value@plt>
xor    %eax,%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdb8(%rip),%rdi
jmp    126a <main+0xfa>
lea    0xdd9(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"./commModule.conf\00"
@.str.1 = [7 x i8] c"RcdCfg\00"
@.str.2 = [14 x i8] c"get_section()\00"
@.str.3 = [19 x i8] c"The section is:\0A%s\00"
@.str.4 = [9 x i8] c"BoardNum\00"
@.str.5 = [12 x i8] c"get_value()\00"
@.str.6 = [22 x i8] c"The BoardNum is : %s\0A\00"
@.str.7 = [11 x i8] c"TimeLength\00"
@.str.8 = [11 x i8] c"MaxVoltage\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4096 x i8]
%4 = alloca [40 x i8]
store i32 0, i32* %1
%5 = bitcast [4096 x i8]* %3 to i8*
%6 = bitcast [40 x i8]* %4 to i8*
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%8 = call i32 @get_section(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %7)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%19 = call i32 @get_value(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %18)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %14
%26 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %26)
%28 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 2)
%29 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 258)
%30 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 9999)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"./commModule.conf\00"
@.str.1 = [7 x i8] c"RcdCfg\00"
@.str.2 = [14 x i8] c"get_section()\00"
@.str.3 = [19 x i8] c"The section is:\0A%s\00"
@.str.4 = [9 x i8] c"BoardNum\00"
@.str.5 = [12 x i8] c"get_value()\00"
@.str.6 = [22 x i8] c"The BoardNum is : %s\0A\00"
@.str.7 = [11 x i8] c"TimeLength\00"
@.str.8 = [11 x i8] c"MaxVoltage\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_section(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%12 = call i32 @get_value(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%19 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 2)
%20 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 258)
%21 = call i32 @write_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 9999)
ret i32 0
}