#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 *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *const);
char const *getVersion(char const *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);
  if (!lTmp || !(lTmp = strchr(lBuff, ':')))
    return 0;
  lTmp++;
  return lTmp;
}


x86 assembly (clang, -O0):
<getVersion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%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   1050 <pclose@plt>
cmpq   $0x0,-0x420(%rbp)
je     1207 <getVersion+0xa7>
lea    0x2e74(%rip),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x420(%rbp)
cmp    $0x0,%rax
jne    1214 <getVersion+0xb4>
movq   $0x0,-0x8(%rbp)
jmp    1231 <getVersion+0xd1>
mov    -0x420(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%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   1050 <pclose@plt>
test   %r14,%r14
je     11de <getVersion+0x7e>
lea    0x2e9c(%rip),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
add    $0x1,%rax
test   %rcx,%rcx
cmove  %rcx,%rax
jmp    11e0 <getVersion+0x80>
xor    %eax,%eax
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"
define i8* @getVersion(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32* @popen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = call i8* @fgets(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getVersion.lBuff, i64 0, i64 0), i32 1024, i32* %14)
store i8* %15, i8** %6
%16 = load i32*, i32** %5
%17 = call i32 @pclose(i32* %16)
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = call i8* @strchr(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getVersion.lBuff, i64 0, i64 0), i8 signext 58)
store i8* %21, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %20, %1
store i8* null, i8** %2
br label %28
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
%27 = load i8*, i8** %6
store i8* %27, i8** %2
br label %28
28: ; preds = %24, %23
%29 = load i8*, i8** %2
ret i8* %29
}

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"
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 = icmp eq i8* %7, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @getVersion.lBuff, i64 0, i64 0), i8 signext 58)
%12 = icmp eq i8* %11, null
%13 = getelementptr inbounds i8, i8* %11, i64 1
%14 = select i1 %12, i8* null, i8* %13
br label %15
15: ; preds = %10, %1
%16 = phi i8* [ null, %1 ], [ %14, %10 ]
ret i8* %16
}