#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int LOG_CONS;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_ERR;
int LOG_PERROR;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ config_close();
int /*<<< orphan*/ config_exist();
int /*<<< orphan*/ config_handler();
char *config_value(char *);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ options_parse(int, char **);
int /*<<< orphan*/ printf(char *, char *);
char *strrchr(char *, char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main(int argc, char **argv) {
  openlog(strrchr(argv[0], '/') != NULL ? strrchr(argv[0], '/') + 1 : argv[0],
          LOG_CONS | LOG_PERROR, LOG_DAEMON);
  options_parse(argc, argv);
  if (!config_exist()) {
    syslog(LOG_ERR, "Config file not loaded, exiting");
    return EXIT_FAILURE;
  }
  if (!config_handler()) {
    syslog(LOG_ERR, "Can't set config handler, exiting");
    return EXIT_FAILURE;
  }
  syslog(LOG_ERR, "Started!!!");
  printf("key: %s\n", "section/param");
  printf("value: %s\n", config_value("section/param"));
  config_close();
  closelog();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
cmp    $0x0,%rax
je     11ef <main+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11fa <main+0x5a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    0x2dd2(%rip),%rax
or     (%rax),%esi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
call   10c0 <openlog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <options_parse@plt>
mov    $0x0,%al
call   1040 <config_exist@plt>
cmp    $0x0,%eax
jne    1260 <main+0xc0>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   1090 <syslog@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x153>
mov    $0x0,%al
call   10b0 <config_handler@plt>
cmp    $0x0,%eax
jne    1296 <main+0xf6>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
call   1090 <syslog@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x153>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
call   1090 <syslog@plt>
lea    0xd9b(%rip),%rdi
lea    0xd9d(%rip),%rsi
call   1050 <printf@plt>
lea    0xd91(%rip),%rdi
call   1080 <config_value@plt>
mov    %rax,%rsi
lea    0xd90(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <config_close@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %rbp,%rdi
mov    0x2e04(%rip),%rax
mov    0x2e0d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
call   10c0 <openlog@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   10a0 <options_parse@plt>
xor    %eax,%eax
call   1040 <config_exist@plt>
test   %eax,%eax
je     125f <main+0xbf>
xor    %eax,%eax
call   10b0 <config_handler@plt>
mov    0x2da7(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     1271 <main+0xd1>
lea    0xe2c(%rip),%rsi
call   1090 <syslog@plt>
lea    0xe2b(%rip),%rdi
lea    0xe2d(%rip),%rbx
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <config_value@plt>
lea    0xe24(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <config_close@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    0x2d63(%rip),%rax
jmp    1284 <main+0xe4>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
jmp    1278 <main+0xd8>
lea    0xda8(%rip),%rsi
call   1090 <syslog@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_DAEMON = global i32 0
@LOG_ERR = global i32 0
@.str = [32 x i8] c"Config file not loaded, exiting\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"Can't set config handler, exiting\00"
@.str.2 = [11 x i8] c"Started!!!\00"
@.str.3 = [9 x i8] c"key: %s\0A\00"
@.str.4 = [14 x i8] c"section/param\00"
@.str.5 = [11 x i8] c"value: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = call i8* @strrchr(i8* %8, i8 signext 47)
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i8* @strrchr(i8* %14, i8 signext 47)
%16 = getelementptr inbounds i8, i8* %15, i64 1
br label %21
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
br label %21
21: ; preds = %17, %11
%22 = phi i8* [ %16, %11 ], [ %20, %17 ]
%23 = load i32, i32* @LOG_CONS
%24 = load i32, i32* @LOG_PERROR
%25 = or i32 %23, %24
%26 = load i32, i32* @LOG_DAEMON
%27 = call i32 @openlog(i8* %22, i32 %25, i32 %26)
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call i32 @options_parse(i32 %28, i8** %29)
%31 = call i32 (...) @config_exist()
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %21
%34 = load i32, i32* @LOG_ERR
%35 = call i32 @syslog(i32 %34, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %53
37: ; preds = %21
%38 = call i32 (...) @config_handler()
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = load i32, i32* @LOG_ERR
%42 = call i32 @syslog(i32 %41, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
store i32 %43, i32* %3
br label %53
44: ; preds = %37
%45 = load i32, i32* @LOG_ERR
%46 = call i32 @syslog(i32 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%48 = call i8* @config_value(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = call i32 (...) @config_close()
%51 = call i32 (...) @closelog()
%52 = load i32, i32* @EXIT_SUCCESS
store i32 %52, i32* %3
br label %53
53: ; preds = %44, %40, %33
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_DAEMON = global i32 0
@LOG_ERR = global i32 0
@.str = [32 x i8] c"Config file not loaded, exiting\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"Can't set config handler, exiting\00"
@.str.2 = [11 x i8] c"Started!!!\00"
@.str.3 = [9 x i8] c"key: %s\0A\00"
@.str.4 = [14 x i8] c"section/param\00"
@.str.5 = [11 x i8] c"value: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
%8 = load i32, i32* @LOG_CONS
%9 = load i32, i32* @LOG_PERROR
%10 = or i32 %9, %8
%11 = load i32, i32* @LOG_DAEMON
%12 = tail call i32 @openlog(i8* %7, i32 %10, i32 %11)
%13 = tail call i32 @options_parse(i32 %0, i8** %1)
%14 = tail call i32 (...) @config_exist()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @LOG_ERR
%18 = tail call i32 @syslog(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %32
19: ; preds = %2
%20 = tail call i32 (...) @config_handler()
%21 = icmp eq i32 %20, 0
%22 = load i32, i32* @LOG_ERR
br i1 %21, label %23, label %25
23: ; preds = %19
%24 = tail call i32 @syslog(i32 %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %32
25: ; preds = %19
%26 = tail call i32 @syslog(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%28 = tail call i8* @config_value(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%29 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = tail call i32 (...) @config_close()
%31 = tail call i32 (...) @closelog()
br label %32
32: ; preds = %25, %23, %16
%33 = phi i32* [ @EXIT_SUCCESS, %25 ], [ @EXIT_FAILURE, %23 ], [ @EXIT_FAILURE, %16 ]
%34 = load i32, i32* %33
ret i32 %34
}