#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*/ assert(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_shell_command_with_output(char *, char *);
scalar_t__ strcmp(char *, char *);
void test_run_shell_command_with_output() {
  char *commandstr = "echo 'foo'";
  char output[2048];
  printf("test_run_shell_command_with_output...");
  run_shell_command_with_output(commandstr, output);
  assert(strcmp(output, "foo") == 0);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_run_shell_command_with_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1060 <run_shell_command_with_output@plt>
lea    -0x810(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_run_shell_command_with_output>:
push   %rbx
sub    $0x800,%rsp
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <run_shell_command_with_output@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
add    $0x800,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"echo 'foo'\00"
@.str.1 = [38 x i8] c"test_run_shell_command_with_output...\00"
@.str.2 = [4 x i8] c"foo\00"
@.str.3 = [4 x i8] c"Ok\0A\00"
define void @test_run_shell_command_with_output() {
%1 = alloca i8*
%2 = alloca [2048 x i8]
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%4 = load i8*, i8** %1
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%6 = call i32 @run_shell_command_with_output(i8* %4, i8* %5)
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"echo 'foo'\00"
@.str.1 = [38 x i8] c"test_run_shell_command_with_output...\00"
@.str.2 = [4 x i8] c"foo\00"
@str = [3 x i8] c"Ok\00"
define void @test_run_shell_command_with_output() {
%1 = alloca [2048 x i8]
%2 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @run_shell_command_with_output(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}