#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];
  char instruccion[512];
  while (0 == 0) {
    printf("German'sConsole$ ");
    fgets(instruccion, 512, stdin);
    if (!(in = popen(instruccion, "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    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b8 <main+0x68>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11bd <main+0x6d>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11f6 <main+0xa6>
lea    -0x210(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x6d>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
jmp    1162 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <popen@plt>
test   %rax,%rax
je     1230 <main+0xe0>
mov    %rax,%rbp
lea    0x200(%rsp),%rbx
lea    0xe4b(%rip),%r14
mov    %rsp,%r15
lea    0xe53(%rip),%r12
lea    0xe4e(%rip),%r13
jmp    11dd <main+0x8d>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x80>
mov    %rbp,%rdi
call   1040 <pclose@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rdx
mov    %r15,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <popen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11dd <main+0x8d>
mov    $0x1,%edi
call   1070 <exit@plt>

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

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