#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 EXIT_SUCCESS;
int /*<<< orphan*/ _CS_GNU_LIBC_VERSION;
size_t confstr(int /*<<< orphan*/, char *, size_t);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char *buf;
  size_t n;
  n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t)0);
  buf = malloc(n);
  confstr(_CS_GNU_LIBC_VERSION, buf, n);
  printf("%s\n", buf);
  return (EXIT_SUCCESS);
}


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)
mov    0x2e9b(%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)
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <confstr@plt>
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2eac(%rip),%r15
mov    (%r15),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <confstr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    (%r15),%edi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1050 <confstr@plt>
lea    0xe95(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@_CS_GNU_LIBC_VERSION = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
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 = load i32, i32* @_CS_GNU_LIBC_VERSION
%9 = call i64 @confstr(i32 %8, i8* null, i64 0)
store i64 %9, i64* %7
%10 = load i64, i64* %7
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %6
%12 = load i32, i32* @_CS_GNU_LIBC_VERSION
%13 = load i8*, i8** %6
%14 = load i64, i64* %7
%15 = call i64 @confstr(i32 %12, i8* %13, i64 %14)
%16 = load i8*, i8** %6
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

LLVM IR (-O2):
@_CS_GNU_LIBC_VERSION = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @_CS_GNU_LIBC_VERSION
%4 = tail call i64 @confstr(i32 %3, i8* null, i64 0)
%5 = tail call i8* @malloc(i64 %4)
%6 = load i32, i32* @_CS_GNU_LIBC_VERSION
%7 = tail call i64 @confstr(i32 %6, i8* %5, i64 %4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}