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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
scalar_t__ popen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *executeCommand(char *command, char *buff) {
  FILE *fpipe;
  char path[1024];
  if (!(fpipe = (FILE *)popen(command, "r"))) {
    printf("Error : with pipe");
    exit(1);
  }
  while (fgets(path, sizeof(path) - 1, fpipe) != NULL) {
    strcat(buff, path);
  }
  pclose(fpipe);
  return buff;
}


x86 assembly (clang, -O0):
<executeCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a7 <executeCommand+0x47>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11ac <executeCommand+0x4c>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11e0 <executeCommand+0x80>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1070 <strcat@plt>
jmp    11ac <executeCommand+0x4c>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x10(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeCommand>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
lea    0xe8a(%rip),%rsi
call   1060 <popen@plt>
test   %rax,%rax
je     11d8 <executeCommand+0x78>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x3ff,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c0 <executeCommand+0x60>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <executeCommand+0x40>
mov    %r15,%rdi
call   1040 <pclose@plt>
mov    %r14,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"Error : with pipe\00"
define i8* @executeCommand(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
br label %15
15: ; preds = %20, %14
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %5
%18 = call i32* @fgets(i8* %16, i32 1023, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = call i32 @strcat(i8* %21, i8* %22)
br label %15
24: ; preds = %15
%25 = load i32*, i32** %5
%26 = call i32 @pclose(i32* %25)
%27 = load i8*, i8** %4
ret i8* %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"Error : with pipe\00"
define i8* @executeCommand(i8* %0, i8* returned %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @popen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = inttoptr i64 %5 to i32*
%7 = icmp eq i64 %5, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32* @fgets(i8* %4, i32 1023, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %18, label %14
11: ; preds = %2
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8, %14
%15 = call i32 @strcat(i8* %1, i8* %4)
%16 = call i32* @fgets(i8* %4, i32 1023, i32* %6)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %14
18: ; preds = %14, %8
%19 = call i32 @pclose(i32* %6)
ret i8* %1
}