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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ media_play_run(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ remove(char const *);
int strlen(char *);
int file_read_play(const char *fname) {
  FILE *fp;
  char buf[160] = {
      0,
  };
  char *pb;
  int len;
  fp = fopen(fname, "r");
  if (!fp) {
    printf("Can't open the file(%s) for read.\n", fname);
    return -1;
  }
  do {
    pb = fgets(buf, 160, fp);
    if (!pb)
      break;
    len = strlen(buf);
    buf[len - 1] = '\0';
    media_play_run(buf);
    memset(buf, 0, sizeof(buf));
  } while (!feof(fp));
  fclose(fp);
  if (remove(fname)) {
    printf("Can't remove the file(%s).\n", fname);
    return -2;
  } else {
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_read_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1080 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ed <file_read_play+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c2 <file_read_play+0x132>
jmp    11f2 <file_read_play+0x62>
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xa0,%esi
call   1090 <fgets@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    1221 <file_read_play+0x91>
jmp    127e <file_read_play+0xee>
lea    -0xc0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    -0xc0(%rbp),%rdi
call   1030 <media_play_run@plt>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1080 <memset@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f2 <file_read_play+0x62>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <remove@plt>
cmp    $0x0,%rax
je     12b6 <file_read_play+0x126>
mov    -0x10(%rbp),%rsi
lea    0xd80(%rip),%rdi
call   1070 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12c2 <file_read_play+0x132>
jmp    12bb <file_read_play+0x12b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_read_play>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe20(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1262 <file_read_play+0xd2>
mov    %rax,%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa0,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1237 <file_read_play+0xa7>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1030 <media_play_run@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1080 <memset@plt>
mov    %r15,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     11f0 <file_read_play+0x60>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1040 <remove@plt>
test   %rax,%rax
je     1278 <file_read_play+0xe8>
lea    0xdd2(%rip),%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
mov    $0xfffffffe,%eax
jmp    127a <file_read_play+0xea>
lea    0xd99(%rip),%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
mov    $0xffffffff,%eax
jmp    127a <file_read_play+0xea>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [35 x i8] c"Can't open the file(%s) for read.\0A\00"
@.str.2 = [28 x i8] c"Can't remove the file(%s).\0A\00"
define i32 @file_read_play(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [160 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = bitcast [160 x i8]* %5 to i8*
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 -1, i32* %2
br label %51
16: ; preds = %1
br label %17
17: ; preds = %35, %16
%18 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %4
%20 = call i8* @fgets(i8* %18, i32 160, i32* %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %17
br label %40
24: ; preds = %17
%25 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%32 = call i32 @media_play_run(i8* %31)
%33 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%34 = call i32 @memset(i8* %33, i32 0, i32 160)
br label %35
35: ; preds = %24
%36 = load i32*, i32** %4
%37 = call i32 @feof(i32* %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
br i1 %39, label %17, label %40
40: ; preds = %35, %23
%41 = load i32*, i32** %4
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %3
%44 = call i64 @remove(i8* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load i8*, i8** %3
%48 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %47)
store i32 -2, i32* %2
br label %51
49: ; preds = %40
br label %50
50: ; preds = %49
store i32 0, i32* %2
br label %51
51: ; preds = %50, %46, %13
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [35 x i8] c"Can't open the file(%s) for read.\0A\00"
@.str.2 = [28 x i8] c"Can't remove the file(%s).\0A\00"
define i32 @file_read_play(i8* %0) {
%2 = alloca [160 x i8]
%3 = getelementptr inbounds [160 x i8], [160 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %26
8: ; preds = %1, %11
%9 = call i8* @fgets(i8* %3, i32 160, i32* %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = call i32 @strlen(i8* %3)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [160 x i8], [160 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @media_play_run(i8* %3)
%17 = call i32 @memset(i8* %3, i32 0, i32 160)
%18 = call i32 @feof(i32* %4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %8, label %20
20: ; preds = %8, %11
%21 = call i32 @fclose(i32* %4)
%22 = call i64 @remove(i8* %0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %26
26: ; preds = %20, %24, %6
%27 = phi i32 [ -2, %24 ], [ -1, %6 ], [ 0, %20 ]
ret i32 %27
}