#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 mstring_get_length(char *);
char *read_file(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ system(char *);
char *get_output(char *cmd_in) {
  char cmd[mstring_get_length(cmd_in) + 15];
  snprintf(cmd, mstring_get_length(cmd_in) + 15, "%s > cmd.temp", cmd_in);
  system(cmd);
  char *buff = read_file("cmd.temp");
  system("rm -rf cmd.temp");
  return buff;
}


x86 assembly (clang, -O0):
<get_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <mstring_get_length@plt>
add    $0xf,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <mstring_get_length@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
add    $0xf,%esi
mov    -0x8(%rbp),%rcx
lea    0xe68(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <system@plt>
lea    0xe58(%rip),%rdi
call   1050 <read_file@plt>
mov    %rax,-0x20(%rbp)
lea    0xe51(%rip),%rdi
call   1030 <system@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_output>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <mstring_get_length@plt>
add    $0xf,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
call   1060 <mstring_get_length@plt>
lea    0xf(%rax),%esi
lea    0xe8b(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0xe76(%rip),%rdi
call   1050 <read_file@plt>
mov    %rax,%rbx
lea    0xe70(%rip),%rdi
call   1030 <system@plt>
mov    %rbx,%rax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%s > cmd.temp\00"
@.str.1 = [9 x i8] c"cmd.temp\00"
@.str.2 = [16 x i8] c"rm -rf cmd.temp\00"
define i8* @get_output(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @mstring_get_length(i8* %6)
%8 = add nsw i32 %7, 15
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i8, i64 %9
store i64 %9, i64* %4
%12 = load i8*, i8** %2
%13 = call i32 @mstring_get_length(i8* %12)
%14 = add nsw i32 %13, 15
%15 = load i8*, i8** %2
%16 = call i32 @snprintf(i8* %11, i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @system(i8* %11)
%18 = call i8* @read_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %5
%19 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %5
%21 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s > cmd.temp\00"
@.str.1 = [9 x i8] c"cmd.temp\00"
@.str.2 = [16 x i8] c"rm -rf cmd.temp\00"
define i8* @get_output(i8* %0) {
%2 = tail call i32 @mstring_get_length(i8* %0)
%3 = add nsw i32 %2, 15
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32 @mstring_get_length(i8* %0)
%7 = add nsw i32 %6, 15
%8 = call i32 @snprintf(i8* %5, i32 %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @system(i8* %5)
%10 = call i8* @read_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
ret i8* %10
}