#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 Config_change_param(char *, char *);
int Config_close();
int Config_init(char *);
char *Config_read_param(char *);
int Config_write_param(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a;
  const char *par_val;
  a = Config_init("test_config");
  if (a) {
    printf("Can`t initialize config library! \n");
    return -1;
  } else
    printf("Config library initialized! \n");
  a = Config_write_param("config_param1", "value1");
  if (a) {
    printf("Can`t write config param! \n");
    return -1;
  } else
    printf("Config parameter wrote! \n");
  a = Config_write_param("config_param2", "value2");
  if (a) {
    printf("Can`t write config param! \n");
    return -1;
  } else
    printf("Config parameter wrote! \n");
  par_val = Config_read_param("config_param1");
  if (!par_val) {
    printf("Can`t read config param! \n");
    return -1;
  } else
    printf("Config param: %s\n", par_val);
  a = Config_change_param("config_param1", "new_value1");
  if (a) {
    printf("Can`t change config param! \n");
    return -1;
  } else
    printf("Config parameter changed! \n");
  a = Config_close();
  printf("Config library closed! \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1080 <Config_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11a2 <main+0x42>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ee <main+0x18e>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe96(%rip),%rdi
lea    0xf19(%rip),%rsi
call   1050 <Config_write_param@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11ea <main+0x8a>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ee <main+0x18e>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <Config_write_param@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1232 <main+0xd2>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ee <main+0x18e>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe06(%rip),%rdi
call   1030 <Config_read_param@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1275 <main+0x115>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ee <main+0x18e>
mov    -0x10(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdbf(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <Config_change_param@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12c1 <main+0x161>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ee <main+0x18e>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <Config_close@plt>
mov    %eax,-0x8(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe86(%rip),%rdi
call   1090 <Config_init@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     1191 <main+0x21>
lea    0xf77(%rip),%rbx
jmp    11de <main+0x6e>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <Config_write_param@plt>
lea    0xf34(%rip),%rbx
test   %eax,%eax
jne    11de <main+0x6e>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4c(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1060 <Config_write_param@plt>
test   %eax,%eax
je     11ef <main+0x7f>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0a(%rip),%rdi
call   1040 <Config_read_param@plt>
test   %rax,%rax
je     123d <main+0xcd>
lea    0xe1c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde8(%rip),%rdi
lea    0xe16(%rip),%rsi
call   1070 <Config_change_param@plt>
test   %eax,%eax
je     1246 <main+0xd6>
lea    0xe94(%rip),%rbx
jmp    11de <main+0x6e>
lea    0xe3e(%rip),%rbx
jmp    11de <main+0x6e>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <Config_close@plt>
lea    0xe57(%rip),%rbx
xor    %ebp,%ebp
jmp    11de <main+0x6e>

LLVM IR (-O0):
@.str = [12 x i8] c"test_config\00"
@.str.1 = [35 x i8] c"Can`t initialize config library! \0A\00"
@.str.2 = [30 x i8] c"Config library initialized! \0A\00"
@.str.3 = [14 x i8] c"config_param1\00"
@.str.4 = [7 x i8] c"value1\00"
@.str.5 = [28 x i8] c"Can`t write config param! \0A\00"
@.str.6 = [26 x i8] c"Config parameter wrote! \0A\00"
@.str.7 = [14 x i8] c"config_param2\00"
@.str.8 = [7 x i8] c"value2\00"
@.str.9 = [27 x i8] c"Can`t read config param! \0A\00"
@.str.10 = [18 x i8] c"Config param: %s\0A\00"
@.str.11 = [11 x i8] c"new_value1\00"
@.str.12 = [29 x i8] c"Can`t change config param! \0A\00"
@.str.13 = [28 x i8] c"Config parameter changed! \0A\00"
@.str.14 = [25 x i8] c"Config library closed! \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @Config_init(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9
%12 = call i32 @Config_write_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %19
19: ; preds = %17
%20 = call i32 @Config_write_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = call i8* @Config_read_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i8* %28, i8** %3
%29 = load i8*, i8** %3
%30 = icmp ne i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33
%37 = call i32 @Config_change_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
42: ; preds = %36
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = call i32 (...) @Config_close()
store i32 %45, i32* %2
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %1
br label %47
47: ; preds = %44, %40, %31, %23, %15, %7
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [12 x i8] c"test_config\00"
@.str.3 = [14 x i8] c"config_param1\00"
@.str.4 = [7 x i8] c"value1\00"
@.str.7 = [14 x i8] c"config_param2\00"
@.str.8 = [7 x i8] c"value2\00"
@.str.10 = [18 x i8] c"Config param: %s\0A\00"
@.str.11 = [11 x i8] c"new_value1\00"
@str = [29 x i8] c"Config library initialized! \00"
@str.16 = [25 x i8] c"Config parameter wrote! \00"
@str.17 = [26 x i8] c"Can`t read config param! \00"
@str.18 = [27 x i8] c"Config parameter changed! \00"
@str.19 = [24 x i8] c"Config library closed! \00"
@str.20 = [28 x i8] c"Can`t change config param! \00"
@str.22 = [27 x i8] c"Can`t write config param! \00"
@str.23 = [34 x i8] c"Can`t initialize config library! \00"
define i32 @main() {
%1 = tail call i32 @Config_init(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %22
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @Config_write_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%9 = tail call i32 @Config_write_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%13 = tail call i8* @Config_read_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %13)
%17 = tail call i32 @Config_change_param(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%21 = tail call i32 (...) @Config_close()
br label %22
22: ; preds = %15, %11, %7, %3, %0, %19
%23 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.19, i64 0, i64 0), %19 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.23, i64 0, i64 0), %0 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0), %3 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0), %7 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.17, i64 0, i64 0), %11 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.20, i64 0, i64 0), %15 ]
%24 = phi i32 [ 0, %19 ], [ -1, %0 ], [ -1, %3 ], [ -1, %7 ], [ -1, %11 ], [ -1, %15 ]
%25 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret i32 %24
}