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

/* Variables and functions */
int /*<<< orphan*/ _CS_GNU_LIBC_VERSION;
int /*<<< orphan*/ _CS_GNU_LIBPTHREAD_VERSION;
int /*<<< orphan*/ _CS_PATH;
int /*<<< orphan*/ abort();
size_t confstr(int /*<<< orphan*/, char *, size_t);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, char *, ...);
int main() {
  char buf[128];
  confstr(_CS_PATH, buf, sizeof(buf));
  printf("_CS_PATH -> %s\n", buf);
  confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
  printf("_CS_GNU_LIBC_VERSION -> %s\n", buf);
  confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf));
  printf("_CS_GNU_LIBPTHREAD_VERSION -> %s\n", buf);
  char *pathbuf;
  size_t n;
  n = confstr(_CS_PATH, NULL, (size_t)0);
  pathbuf = malloc(n);
  if (pathbuf == NULL)
    abort();
  confstr(_CS_PATH, pathbuf, n);
  printf("_CS_PATH -> %s; n -> %d\n", pathbuf, (int)n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1060 <confstr@plt>
lea    -0x90(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1060 <confstr@plt>
lea    -0x90(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1060 <confstr@plt>
lea    -0x90(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1060 <confstr@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    1223 <main+0xe3>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x98(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
call   1060 <confstr@plt>
mov    -0x98(%rbp),%rsi
mov    -0xa0(%rbp),%rax
mov    %eax,%edx
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    0x2e95(%rip),%r15
mov    (%r15),%edi
mov    %rsp,%rbx
mov    $0x80,%edx
mov    %rbx,%rsi
call   1060 <confstr@plt>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    $0x80,%edx
mov    %rbx,%rsi
call   1060 <confstr@plt>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    $0x80,%edx
mov    %rbx,%rsi
call   1060 <confstr@plt>
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <confstr@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <malloc@plt>
test   %rax,%rax
je     1215 <main+0xd5>
mov    %rax,%rbx
mov    (%r15),%edi
mov    %rax,%rsi
mov    %r14,%rdx
call   1060 <confstr@plt>
lea    0xe55(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@_CS_PATH = global i32 0
@.str = [16 x i8] c"_CS_PATH -> %s\0A\00"
@_CS_GNU_LIBC_VERSION = global i32 0
@.str.1 = [28 x i8] c"_CS_GNU_LIBC_VERSION -> %s\0A\00"
@_CS_GNU_LIBPTHREAD_VERSION = global i32 0
@.str.2 = [34 x i8] c"_CS_GNU_LIBPTHREAD_VERSION -> %s\0A\00"
@.str.3 = [25 x i8] c"_CS_PATH -> %s; n -> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i8*
%4 = alloca i64
store i32 0, i32* %1
%5 = load i32, i32* @_CS_PATH
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = call i64 @confstr(i32 %5, i8* %6, i64 128)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @_CS_GNU_LIBC_VERSION
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = call i64 @confstr(i32 %10, i8* %11, i64 128)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @_CS_GNU_LIBPTHREAD_VERSION
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%17 = call i64 @confstr(i32 %15, i8* %16, i64 128)
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @_CS_PATH
%21 = call i64 @confstr(i32 %20, i8* null, i64 0)
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = call i8* @malloc(i64 %22)
store i8* %23, i8** %3
%24 = load i8*, i8** %3
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %0
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %0
%29 = load i32, i32* @_CS_PATH
%30 = load i8*, i8** %3
%31 = load i64, i64* %4
%32 = call i64 @confstr(i32 %29, i8* %30, i64 %31)
%33 = load i8*, i8** %3
%34 = load i64, i64* %4
%35 = trunc i64 %34 to i32
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %33, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@_CS_PATH = global i32 0
@.str = [16 x i8] c"_CS_PATH -> %s\0A\00"
@_CS_GNU_LIBC_VERSION = global i32 0
@.str.1 = [28 x i8] c"_CS_GNU_LIBC_VERSION -> %s\0A\00"
@_CS_GNU_LIBPTHREAD_VERSION = global i32 0
@.str.2 = [34 x i8] c"_CS_GNU_LIBPTHREAD_VERSION -> %s\0A\00"
@.str.3 = [25 x i8] c"_CS_PATH -> %s; n -> %d\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @_CS_PATH
%4 = call i64 @confstr(i32 %3, i8* %2, i64 128)
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = load i32, i32* @_CS_GNU_LIBC_VERSION
%7 = call i64 @confstr(i32 %6, i8* %2, i64 128)
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = load i32, i32* @_CS_GNU_LIBPTHREAD_VERSION
%10 = call i64 @confstr(i32 %9, i8* %2, i64 128)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = load i32, i32* @_CS_PATH
%13 = call i64 @confstr(i32 %12, i8* null, i64 0)
%14 = call i8* @malloc(i64 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %0
%19 = load i32, i32* @_CS_PATH
%20 = call i64 @confstr(i32 %19, i8* %14, i64 %13)
%21 = trunc i64 %13 to i32
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %14, i32 %21)
ret i32 0
}