#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 */
typedef int /*<<< orphan*/ CONF;

/* Variables and functions */
int /*<<< orphan*/ NCONF_dump_fp(int /*<<< orphan*/ *, int /*<<< orphan*/);
int NCONF_load(int /*<<< orphan*/ *, char *, long *);
int /*<<< orphan*/ *NCONF_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  long eline;
  char *cmd, *path;
  char *key;
  CONF *cnf;
  cnf = NCONF_new(NULL);
  if (cnf == NULL) {
    perror("NCONF_new");
    exit(1);
  }
  cmd = argv[0];
  argc--, argv++;
  if (argc != 1) {
    fprintf(stderr, "usage: %s path_to_config_file\n", cmd);
    exit(1);
  }
  path = *argv;
  (void)putenv("TESTENV=testvalue");
  int res = NCONF_load(cnf, path, &eline);
  if (res <= 0) {
    fprintf(stderr, "error on line %ld\n", eline);
    exit(1);
  }
  NCONF_dump_fp(cnf, stdout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <NCONF_new@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ad <main+0x3d>
lea    0xe62(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     11fc <main+0x8c>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xe1b(%rip),%rdi
call   1040 <putenv@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <NCONF_load@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jg     1256 <main+0xe6>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
call   1060 <NCONF_dump_fp@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
call   1030 <NCONF_new@plt>
test   %rax,%rax
je     11d1 <main+0x61>
cmp    $0x2,%ebp
jne    11e7 <main+0x77>
mov    %rax,%rbx
mov    0x8(%r14),%rbp
lea    0xe8d(%rip),%rdi
call   1040 <putenv@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <NCONF_load@plt>
test   %eax,%eax
jle    11fc <main+0x8c>
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <NCONF_dump_fp@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe28(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    (%r14),%rdx
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
jmp    1211 <main+0xa1>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xe2a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"NCONF_new\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"usage: %s path_to_config_file\0A\00"
@.str.2 = [18 x i8] c"TESTENV=testvalue\00"
@.str.3 = [19 x i8] c"error on line %ld\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%11 = call i32* @NCONF_new(i32* null)
store i32* %11, i32** %9
%12 = load i32*, i32** %9
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %4
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %32
27: ; preds = %17
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %6
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %17
%33 = load i8**, i8*** %4
%34 = load i8*, i8** %33
store i8* %34, i8** %7
%35 = call i32 @putenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32*, i32** %9
%37 = load i8*, i8** %7
%38 = call i32 @NCONF_load(i32* %36, i8* %37, i64* %5)
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %32
%42 = load i32, i32* @stderr
%43 = load i64, i64* %5
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %32
%47 = load i32*, i32** %9
%48 = load i32, i32* @stdout
%49 = call i32 @NCONF_dump_fp(i32* %47, i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"NCONF_new\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"usage: %s path_to_config_file\0A\00"
@.str.2 = [18 x i8] c"TESTENV=testvalue\00"
@.str.3 = [19 x i8] c"error on line %ld\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32* @NCONF_new(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %17, label %12
12: ; preds = %10
%13 = load i8*, i8** %1
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @putenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @NCONF_load(i32* %5, i8* %19, i64* %3)
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i64, i64* %3
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %17
%29 = load i32, i32* @stdout
%30 = call i32 @NCONF_dump_fp(i32* %5, i32 %29)
ret i32 0
}