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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdin;
int main(void) {
  FILE *in;
  extern FILE *popen();
  char buff[512];
  printf("\n");
  printf("**************************** Bienvenido a la consola "
         "****************************\n");
  printf("\n");
  while (1) {
    char algo[500];
    printf(">> ");
    fgets(algo, 500, stdin);
    if (!(in = popen(algo, "r"))) {
      exit(1);
    }
    while (fgets(buff, sizeof(buff), in) != NULL) {
      printf("   %s", buff);
    }
    pclose(in);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e40(%rip),%rax
mov    (%rax),%rdx
mov    $0x1f4,%esi
call   1050 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11e2 <main+0x92>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11e7 <main+0x97>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1220 <main+0xd0>
lea    -0x210(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <main+0x97>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
jmp    118c <main+0x3c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1f4,%esi
call   1070 <fgets@plt>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <popen@plt>
test   %rax,%rax
je     1270 <main+0x100>
mov    %rax,%rbp
lea    0x200(%rsp),%rbx
lea    0xe0b(%rip),%r14
mov    %rsp,%r15
lea    0xe05(%rip),%r12
lea    0xe00(%rip),%r13
jmp    121d <main+0xad>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1210 <main+0xa0>
mov    %rbp,%rdi
call   1060 <pclose@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%rdx
mov    %r15,%rdi
mov    $0x1f4,%esi
call   1070 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <popen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    121d <main+0xad>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [83 x i8] c"**************************** Bienvenido a la consola ****************************\0A\00"
@.str.2 = [4 x i8] c">> \00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c" %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [512 x i8]
%4 = alloca [500 x i8]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %0, %27
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%11 = load i32*, i32** @stdin
%12 = call i32* @fgets(i8* %10, i32 500, i32* %11)
%13 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%14 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @popen to i32* (i8*, i8*, ...)*)(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %14, i32** %2
%15 = icmp ne i32* %14, null
br i1 %15, label %18, label %16
16: ; preds = %8
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %8
br label %19
19: ; preds = %24, %18
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = load i32*, i32** %2
%22 = call i32* @fgets(i8* %20, i32 512, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %25)
br label %19
27: ; preds = %19
%28 = load i32*, i32** %2
%29 = call i32 @pclose(i32* %28)
br label %8
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c">> \00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c" %s\00"
@str = [82 x i8] c"**************************** Bienvenido a la consola ****************************\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [500 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @putchar(i32 10)
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** @stdin
%10 = call i32* @fgets(i8* %7, i32 500, i32* %9)
%11 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @popen to i32* (i8*, i8*, ...)*)(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %0, %23
%14 = phi i32* [ %28, %23 ], [ %11, %0 ]
%15 = call i32* @fgets(i8* %3, i32 512, i32* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %23, label %19
17: ; preds = %23, %0
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%21 = call i32* @fgets(i8* %3, i32 512, i32* %14)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %19
23: ; preds = %19, %13
%24 = call i32 @pclose(i32* %14)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** @stdin
%27 = call i32* @fgets(i8* %7, i32 500, i32* %26)
%28 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @popen to i32* (i8*, i8*, ...)*)(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %17, label %13
}