#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*/ lBuff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strcspn(char *, char *);
char *getVersion(char const *aExecutable) {
  static char lBuff[1024];
  char lTestedString[1024];
  FILE *lIn;
  char *lTmp;
  strcpy(lTestedString, aExecutable);
  strcat(lTestedString, " --version");
  lIn = popen(lTestedString, "r");
  lTmp = fgets(lBuff, sizeof(lBuff), lIn);
  pclose(lIn);
  lTmp += strcspn(lTmp, "0123456789");
  return lTmp;
}


x86 assembly (clang, -O0):
<getVersion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rdx
lea    0x2ea6(%rip),%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x420(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1050 <strcspn@plt>
mov    %eax,%ecx
mov    -0x420(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getVersion>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
mov    %rax,%rbx
lea    0x2ec0(%rip),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <pclose@plt>
lea    0xe4e(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcspn@plt>
cltq
add    %r14,%rax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@getVersion.lBuff = internal global [1024 x i8] zeroinitializer
@.str = [11 x i8] c" --version\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"0123456789\00"
define i8* @getVersion(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = call i32* @popen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = call i8* @fgets(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getVersion.lBuff, i64 0, i64 0), i32 1024, i32* %13)
store i8* %14, i8** %5
%15 = load i32*, i32** %4
%16 = call i32 @pclose(i32* %15)
%17 = load i8*, i8** %5
%18 = call i32 @strcspn(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** %5
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %5
%22 = load i8*, i8** %5
ret i8* %22
}

LLVM IR (-O2):
@getVersion.lBuff = internal global [1024 x i8] zeroinitializer
@.str = [11 x i8] c" --version\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"0123456789\00"
define i8* @getVersion(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i8* @fgets(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getVersion.lBuff, i64 0, i64 0), i32 1024, i32* %6)
%8 = call i32 @pclose(i32* %6)
%9 = call i32 @strcspn(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
ret i8* %11
}