#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 BUFSIZ;
int errno;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *);
int /*<<< orphan*/ stderr;
char *strerror(int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strtok(char *, char *);
int _condor_config_val(char *var, char *val, size_t valsize,
                       const char *default_val) {
  char cmd[BUFSIZ];
  snprintf(cmd, BUFSIZ, "condor_config_val %s 2>&1", var);
  FILE *proc = popen(cmd, "r");
  if (proc == NULL) {
    fprintf(stderr, "ERROR getting %s config var\n", var);
    return -1;
  }
  char buf[BUFSIZ];
  if (fgets(buf, BUFSIZ, proc) == NULL) {
    fprintf(stderr, "ERROR reading output of condor_config_val\n");
    pclose(proc);
    return -1;
  }
  int status = pclose(proc);
  int saverrno = errno;
  if (strncmp("Not defined:", buf, 12) == 0) {
    if (default_val == NULL) {
      return -1;
    }
    snprintf(val, valsize, "%s", default_val);
    return 0;
  }
  if (status != 0) {
    fprintf(stderr, "ERROR reading condor_config_val %s: %s\n", var,
            strerror(saverrno));
    fprintf(stderr, "%s", buf);
    return -1;
  }
  strtok(buf, "\r\n");
  snprintf(val, valsize, "%s", buf);
  return 0;
}


x86 assembly (clang, -O0):
<_condor_config_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2e0a(%rip),%rax
movslq (%rax),%rsi
mov    -0x10(%rbp),%rcx
lea    0xe24(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x60(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    122e <_condor_config_val+0xae>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13c4 <_condor_config_val+0x244>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
mov    -0x40(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    12a2 <_condor_config_val+0x122>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <pclose@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13c4 <_condor_config_val+0x244>
mov    -0x40(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x68(%rbp),%rsi
mov    %eax,-0x54(%rbp)
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
lea    0xd9f(%rip),%rdi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1322 <_condor_config_val+0x1a2>
cmpq   $0x0,-0x28(%rbp)
jne    12f7 <_condor_config_val+0x177>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13c4 <_condor_config_val+0x244>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    0xd67(%rip),%rdx
call   1050 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13c4 <_condor_config_val+0x244>
cmpl   $0x0,-0x54(%rbp)
je     138e <_condor_config_val+0x20e>
mov    0x2cad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x58(%rbp),%edi
call   10a0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x68(%rbp),%rdx
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
lea    0xcfd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13c4 <_condor_config_val+0x244>
mov    -0x68(%rbp),%rdi
lea    0xd03(%rip),%rsi
call   1090 <strtok@plt>
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xcc0(%rip),%rdx
call   1050 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_condor_config_val>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,-0x38(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdi,%r13
mov    0x2e32(%rip),%r15
movslq (%r15),%rsi
mov    %esi,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe3d(%rip),%rdx
mov    %rbx,%rdi
mov    %r13,%rcx
call   1050 <snprintf@plt>
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     1289 <_condor_config_val+0x109>
mov    %rax,%r14
mov    (%r15),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12a5 <_condor_config_val+0x125>
mov    %r14,%rdi
call   1040 <pclose@plt>
mov    %eax,%r15d
mov    0x2daa(%rip),%rax
mov    (%rax),%r14d
lea    0xe34(%rip),%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12d8 <_condor_config_val+0x158>
test   %r15d,%r15d
je     12f1 <_condor_config_val+0x171>
mov    0x2d8a(%rip),%r12
mov    (%r12),%r15d
mov    %r14d,%edi
call   10a0 <strerror@plt>
lea    0xe0b(%rip),%rsi
mov    %r15d,%edi
mov    %r13,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r12),%edi
lea    0xded(%rip),%rsi
mov    %rbx,%rdx
jmp    129c <_condor_config_val+0x11c>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12c4 <_condor_config_val+0x144>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1040 <pclose@plt>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r12,%r12
je     12c4 <_condor_config_val+0x144>
lea    0xd8d(%rip),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %r12,%rcx
jmp    1312 <_condor_config_val+0x192>
lea    0xda4(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strtok@plt>
lea    0xd6a(%rip),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
xor    %eax,%eax
jmp    12c9 <_condor_config_val+0x149>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [26 x i8] c"condor_config_val %s 2>&1\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"ERROR getting %s config var\0A\00"
@.str.3 = [43 x i8] c"ERROR reading output of condor_config_val\0A\00"
@errno = global i32 0
@.str.4 = [13 x i8] c"Not defined:\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [40 x i8] c"ERROR reading condor_config_val %s: %s\0A\00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define i32 @_condor_config_val(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%17 = load i32, i32* @BUFSIZ
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %10
%20 = alloca i8, i64 %18
store i64 %18, i64* %11
%21 = load i32, i32* @BUFSIZ
%22 = sext i32 %21 to i64
%23 = load i8*, i8** %6
%24 = call i32 @snprintf(i8* %20, i64 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32* @popen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %12
%26 = load i32*, i32** %12
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %4
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %6
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 -1, i32* %5
store i32 1, i32* %13
br label %76
32: ; preds = %4
%33 = load i32, i32* @BUFSIZ
%34 = zext i32 %33 to i64
%35 = alloca i8, i64 %34
store i64 %34, i64* %14
%36 = load i32, i32* @BUFSIZ
%37 = load i32*, i32** %12
%38 = call i32* @fgets(i8* %35, i32 %36, i32* %37)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %45
40: ; preds = %32
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32*, i32** %12
%44 = call i32 @pclose(i32* %43)
store i32 -1, i32* %5
store i32 1, i32* %13
br label %76
45: ; preds = %32
%46 = load i32*, i32** %12
%47 = call i32 @pclose(i32* %46)
store i32 %47, i32* %15
%48 = load i32, i32* @errno
store i32 %48, i32* %16
%49 = call i64 @strncmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %35, i32 12)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %45
%52 = load i8*, i8** %9
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 -1, i32* %5
store i32 1, i32* %13
br label %76
55: ; preds = %51
%56 = load i8*, i8** %7
%57 = load i64, i64* %8
%58 = load i8*, i8** %9
%59 = call i32 @snprintf(i8* %56, i64 %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %58)
store i32 0, i32* %5
store i32 1, i32* %13
br label %76
60: ; preds = %45
%61 = load i32, i32* %15
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %71
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = load i8*, i8** %6
%66 = load i32, i32* %16
%67 = call i8* @strerror(i32 %66)
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %65, i8* %67)
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %35)
store i32 -1, i32* %5
store i32 1, i32* %13
br label %76
71: ; preds = %60
%72 = call i32 @strtok(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%73 = load i8*, i8** %7
%74 = load i64, i64* %8
%75 = call i32 @snprintf(i8* %73, i64 %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %35)
store i32 0, i32* %5
store i32 1, i32* %13
br label %76
76: ; preds = %71, %63, %55, %54, %40, %28
%77 = load i8*, i8** %10
%78 = load i32, i32* %5
ret i32 %78
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [26 x i8] c"condor_config_val %s 2>&1\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"ERROR getting %s config var\0A\00"
@.str.3 = [43 x i8] c"ERROR reading output of condor_config_val\0A\00"
@errno = global i32 0
@.str.4 = [13 x i8] c"Not defined:\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [40 x i8] c"ERROR reading condor_config_val %s: %s\0A\00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define i32 @_condor_config_val(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = sext i32 %5 to i64
%9 = call i32 @snprintf(i8* %7, i64 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %45
15: ; preds = %4
%16 = load i32, i32* @BUFSIZ
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
%19 = call i32* @fgets(i8* %18, i32 %16, i32* %10)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @pclose(i32* %10)
br label %45
25: ; preds = %15
%26 = call i32 @pclose(i32* %10)
%27 = load i32, i32* @errno
%28 = call i64 @strncmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %18, i32 12)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = icmp eq i8* %3, null
br i1 %31, label %45, label %32
32: ; preds = %30
%33 = call i32 @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %45
34: ; preds = %25
%35 = icmp eq i32 %26, 0
br i1 %35, label %42, label %36
36: ; preds = %34
%37 = load i32, i32* @stderr
%38 = call i8* @strerror(i32 %27)
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %38)
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %18)
br label %45
42: ; preds = %34
%43 = call i32 @strtok(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %18)
br label %45
45: ; preds = %32, %36, %42, %30, %21, %12
%46 = phi i32 [ -1, %12 ], [ -1, %21 ], [ 0, %32 ], [ -1, %36 ], [ 0, %42 ], [ -1, %30 ]
ret i32 %46
}