#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int strlen(char *);
char *system_output(char *);
void test_command(char *command) {
  char *result = system_output(command);
  int max = 160;
  if (result && strlen(result) > max) {
    result[max - 4] = '.';
    result[max - 3] = '.';
    result[max - 2] = '.';
    result[max - 1] = 0;
  }
  printf("--->%s executed\noutput=[%s]\n\n", command, result);
  free(result);
}


x86 assembly (clang, -O0):
<test_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <system_output@plt>
mov    %rax,-0x10(%rbp)
movl   $0xa0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c1 <test_command+0x81>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x14(%rbp),%eax
jle    11c1 <test_command+0x81>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_command>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <system_output@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116d <test_command+0x2d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0xa1,%eax
jl     116d <test_command+0x2d>
movl   $0x2e2e2e,0x9c(%rbx)
lea    0xe8c(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"--->%s executed\0Aoutput=[%s]\0A\0A\00"
define void @test_command(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @system_output(i8* %5)
store i8* %6, i8** %3
store i32 160, i32* %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %35
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = load i32, i32* %4
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 46, i8* %19
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8 46, i8* %24
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8 46, i8* %29
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
store i8 0, i8* %34
br label %35
35: ; preds = %14, %9, %1
%36 = load i8*, i8** %2
%37 = load i8*, i8** %3
%38 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %36, i8* %37)
%39 = load i8*, i8** %3
%40 = call i32 @free(i8* %39)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"--->%s executed\0Aoutput=[%s]\0A\0A\00"
define void @test_command(i8* %0) {
%2 = tail call i8* @system_output(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 160
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %2, i64 156
store i8 46, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 157
store i8 46, i8* %9
%10 = getelementptr inbounds i8, i8* %2, i64 158
store i8 46, i8* %10
%11 = getelementptr inbounds i8, i8* %2, i64 159
store i8 0, i8* %11
br label %12
12: ; preds = %7, %4, %1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %2)
%14 = tail call i32 @free(i8* %2)
ret void
}