#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 /*<<< orphan*/ _CS_PATH;
size_t confstr(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ exit(int);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *pathbuf;
  size_t sz;
  printf("configuration test\n");
  sz = confstr(_CS_PATH, NULL, (size_t)0);
  if ((pathbuf = malloc(sz)) == NULL) {
    printf("no mem\n");
    exit(1);
  }
  confstr(_CS_PATH, pathbuf, sz);
  printf("_CS_PATH=%s\n", pathbuf);
  exit(0);
}


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)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <confstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ac <main+0x6c>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <confstr@plt>
mov    -0x18(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e80(%rip),%r15
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
jne    119a <main+0x4a>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%rbx
mov    (%r15),%edi
mov    %rax,%rsi
mov    %r14,%rdx
call   1060 <confstr@plt>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"configuration test\0A\00"
@_CS_PATH = global i32 0
@.str.1 = [8 x i8] c"no mem\0A\00"
@.str.2 = [13 x i8] c"_CS_PATH=%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @_CS_PATH
%10 = call i64 @confstr(i32 %9, i8* null, i64 0)
store i64 %10, i64* %7
%11 = load i64, i64* %7
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* @_CS_PATH
%19 = load i8*, i8** %6
%20 = load i64, i64* %7
%21 = call i64 @confstr(i32 %18, i8* %19, i64 %20)
%22 = load i8*, i8** %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@_CS_PATH = global i32 0
@.str.2 = [13 x i8] c"_CS_PATH=%s\0A\00"
@str = [19 x i8] c"configuration test\00"
@str.3 = [7 x i8] c"no mem\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @_CS_PATH
%5 = tail call i64 @confstr(i32 %4, i8* null, i64 0)
%6 = tail call i8* @malloc(i64 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.3, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i32, i32* @_CS_PATH
%13 = tail call i64 @confstr(i32 %12, i8* %6, i64 %5)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%15 = tail call i32 @exit(i32 0)
unreachable
}