#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 scalar_t__ pid_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pipe(int *);
int read(int, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int fd[2];
  pid_t pid;
  pipe(fd);
  pid = fork();
  if (pid == 0) {
    dup2(fd[0], 0);
    close(fd[1]);
    execl("/usr/local/bin/mplayer", "player", "-", NULL);
    exit(0);
  }
  char buf[512];
  int ret;
  int file;
  file = open("/root/桌面/video/arm5", O_RDONLY);
  close(fd[0]);
  while (1) {
    ret = read(file, buf, sizeof(buf));
    if (ret == 0) {
      break;
    }
    write(fd[1], buf, ret);
  }
  close(fd[1]);
  close(file);
  wait(NULL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <pipe@plt>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1208 <main+0x68>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
lea    0xe16(%rip),%rdi
lea    0xe1f(%rip),%rsi
lea    0xe1f(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10a0 <execl@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
lea    0xe01(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x228(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x228(%rbp),%edi
lea    -0x220(%rbp),%rsi
mov    $0x200,%edx
call   1070 <read@plt>
mov    %eax,-0x224(%rbp)
cmpl   $0x0,-0x224(%rbp)
jne    125a <main+0xba>
jmp    1274 <main+0xd4>
mov    -0x8(%rbp),%edi
lea    -0x220(%rbp),%rsi
mov    -0x224(%rbp),%edx
call   1030 <write@plt>
jmp    122b <main+0x8b>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0x228(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <wait@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x218,%rsp
lea    0x8(%rsp),%rdi
call   1060 <pipe@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
je     1244 <main+0xa4>
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
lea    0xe46(%rip),%rdi
call   1080 <open@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%edi
call   1050 <close@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x200,%edx
call   1070 <read@plt>
test   %eax,%eax
je     1221 <main+0x81>
lea    0x10(%rsp),%rbx
nopl   (%rax)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1070 <read@plt>
test   %eax,%eax
jne    1200 <main+0x60>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rsp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
lea    0xda1(%rip),%rdi
lea    0xdaa(%rip),%rsi
lea    0xdaa(%rip),%rdx
xor    %ecx,%ecx
call   10a0 <execl@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"/usr/local/bin/mplayer\00"
@.str.1 = [7 x i8] c"player\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [24 x i8] c"/root/\E6\A1\8C\E9\9D\A2/video/arm5\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i64
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%8 = call i32 @pipe(i32* %7)
%9 = call i64 (...) @fork()
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %0
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%14 = load i32, i32* %13
%15 = call i32 @dup2(i32 %14, i32 0)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 @close(i32 %17)
%19 = call i32 @execl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* null)
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %0
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %22)
store i32 %23, i32* %6
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %24
%26 = call i32 @close(i32 %25)
br label %27
27: ; preds = %21, %34
%28 = load i32, i32* %6
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%30 = call i32 @read(i32 %28, i8* %29, i32 512)
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
br label %40
34: ; preds = %27
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%38 = load i32, i32* %5
%39 = call i32 @write(i32 %36, i8* %37, i32 %38)
br label %27
40: ; preds = %33
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* %6
%45 = call i32 @close(i32 %44)
%46 = call i32 @wait(i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"/usr/local/bin/mplayer\00"
@.str.1 = [7 x i8] c"player\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [24 x i8] c"/root/\E6\A1\8C\E9\9D\A2/video/arm5\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [512 x i8]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%5 = call i32 @pipe(i32* %4)
%6 = call i64 (...) @fork()
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = load i32, i32* %4
%10 = call i32 @dup2(i32 %9, i32 0)
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%12 = load i32, i32* %11
%13 = call i32 @close(i32 %12)
%14 = call i32 @execl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* null)
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %0
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %4
%21 = call i32 @close(i32 %20)
%22 = call i32 @read(i32 %19, i8* %17, i32 512)
%23 = icmp eq i32 %22, 0
br i1 %23, label %32, label %24
24: ; preds = %16
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %26
26: ; preds = %24, %26
%27 = phi i32 [ %22, %24 ], [ %30, %26 ]
%28 = load i32, i32* %25
%29 = call i32 @write(i32 %28, i8* %17, i32 %27)
%30 = call i32 @read(i32 %19, i8* %17, i32 512)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %26
32: ; preds = %26, %16
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%34 = load i32, i32* %33
%35 = call i32 @close(i32 %34)
%36 = call i32 @close(i32 %19)
%37 = call i32 @wait(i32* null)
ret i32 0
}