#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ read_vars(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void read_config_file(char *path, char *conf) {
  FILE *vars;
  char cmd[1024];
  if (conf)
    sprintf(cmd, "bash %s/pgxc_ctl_bash --configure %s print_values", path,
            conf);
  else
    sprintf(cmd, "bash %s/pgxc_ctl_bash print_values", path);
  vars = popen(cmd, "r");
  read_vars(vars);
  pclose(vars);
}


x86 assembly (clang, -O0):
<read_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1180 <read_config_file+0x40>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1199 <read_config_file+0x59>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1040 <popen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <read_vars@plt>
mov    -0x18(%rbp),%rdi
call   1030 <pclose@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config_file>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rdx
test   %rsi,%rsi
je     1166 <read_config_file+0x26>
mov    %rsi,%rcx
lea    0xea6(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    1177 <read_config_file+0x37>
lea    0xec5(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xed7(%rip),%rsi
mov    %rsp,%rdi
call   1040 <popen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <read_vars@plt>
mov    %rbx,%rdi
add    $0x400,%rsp
pop    %rbx
jmp    1030 <pclose@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"bash %s/pgxc_ctl_bash --configure %s print_values\00"
@.str.1 = [35 x i8] c"bash %s/pgxc_ctl_bash print_values\00"
@.str.2 = [2 x i8] c"r\00"
define void @read_config_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
br label %18
14: ; preds = %2
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %9
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = call i32* @popen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %5
%21 = load i32*, i32** %5
%22 = call i32 @read_vars(i32* %21)
%23 = load i32*, i32** %5
%24 = call i32 @pclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"bash %s/pgxc_ctl_bash --configure %s print_values\00"
@.str.1 = [35 x i8] c"bash %s/pgxc_ctl_bash print_values\00"
@.str.2 = [2 x i8] c"r\00"
define void @read_config_file(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %10
8: ; preds = %2
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %6
%11 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @read_vars(i32* %11)
%13 = tail call i32 @pclose(i32* %11)
ret void
}