#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*/ close(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ perror_exit(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ read(int, char *, int);
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, int);
int main() {
  int pipes[2];
  char buf[1024];
  if (pipe(pipes) < 0)
    perror_exit("pipe");
  if (write(pipes[1], "sistemas es lo más", sizeof("sistemas es lo más")) < 0)
    perror("escribiendo datos");
  if (read(pipes[0], buf, 1024) < 0)
    perror_exit("leyendo datos");
  printf("[+] Caracteres de la frase \"%s\": %d\n", buf, (int)strlen(buf));
  close(pipes[0]);
  close(pipes[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    11b1 <main+0x31>
lea    0xe54(%rip),%rdi
call   10a0 <perror_exit@plt>
mov    -0x8(%rbp),%edi
lea    0xe4a(%rip),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11db <main+0x5b>
lea    0xe43(%rip),%rdi
call   1090 <perror@plt>
mov    -0xc(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jge    1205 <main+0x85>
lea    0xe2b(%rip),%rdi
call   10a0 <perror_exit@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
jns    11a3 <main+0x23>
lea    0xe62(%rip),%rdi
call   10a0 <perror_exit@plt>
mov    0xc(%rsp),%edi
lea    0xe57(%rip),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
test   %rax,%rax
js     121c <main+0x9c>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
test   %rax,%rax
jns    11e1 <main+0x61>
lea    0xe4f(%rip),%rdi
call   10a0 <perror_exit@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe44(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <printf@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
ret
lea    0xdf6(%rip),%rdi
call   1090 <perror@plt>
jmp    11bd <main+0x3d>

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [20 x i8] c"sistemas es lo m\C3\A1s\00"
@.str.2 = [18 x i8] c"escribiendo datos\00"
@.str.3 = [14 x i8] c"leyendo datos\00"
@.str.4 = [37 x i8] c"[+] Caracteres de la frase \22%s\22: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [1024 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%5 = call i64 @pipe(i32* %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror_exit(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i64 @write(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 20)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i64 @read(i32 %18, i8* %19, i32 1024)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @perror_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%27 = call i64 @strlen(i8* %26)
%28 = trunc i64 %27 to i32
%29 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %25, i32 %28)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%31 = load i32, i32* %30
%32 = call i32 @close(i32 %31)
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%34 = load i32, i32* %33
%35 = call i32 @close(i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [20 x i8] c"sistemas es lo m\C3\A1s\00"
@.str.2 = [18 x i8] c"escribiendo datos\00"
@.str.3 = [14 x i8] c"leyendo datos\00"
@.str.4 = [37 x i8] c"[+] Caracteres de la frase \22%s\22: %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [1024 x i8]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%6 = call i64 @pipe(i32* %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror_exit(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%12 = load i32, i32* %11
%13 = call i64 @write(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 20)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
%18 = load i32, i32* %5
%19 = call i64 @read(i32 %18, i8* %4, i32 1024)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @perror_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = call i64 @strlen(i8* %4)
%25 = trunc i64 %24 to i32
%26 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %25)
%27 = load i32, i32* %5
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %11
%30 = call i32 @close(i32 %29)
ret i32 0
}