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

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ stderr;
int streaming(char *, char *, int /*<<< orphan*/);
char *strtok(char *, char *);
int main() {
  int ret = 0;
  char *temp1 = NULL;
  char *temp2 = NULL;
  char *temp3 = NULL;
  char lineBuf[500];
  memset(lineBuf, '\0', 500);
  FILE *fp;
  if ((fp = fopen("./playlist.txt", "r")) == NULL) {
    fprintf(stderr, "Cannot open the target file.\n");
    return 1;
  } else {
    while (fgets(lineBuf, sizeof(lineBuf), fp)) {
      temp1 = strtok(lineBuf, "#");
      temp2 = strtok(NULL, "#");
      temp3 = strtok(NULL, "#");
      if (temp1 == NULL || temp2 == NULL || temp3 == NULL) {
        fprintf(stderr, "Grammer error in pgmlist.\n");
        return 1;
      }
      ret = streaming(temp1, temp2, atoi(temp3));
      if (ret != 0) {
        fprintf(stderr, "Something error while streaming.\n");
        return 1;
      }
      temp1 = temp2 = temp3 = NULL;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1030 <memset@plt>
lea    0xe45(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
jne    11f9 <main+0x89>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132c <main+0x1bc>
jmp    11fe <main+0x8e>
lea    -0x220(%rbp),%rdi
mov    -0x228(%rbp),%rdx
mov    $0x1f4,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1320 <main+0x1b0>
lea    -0x220(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xded(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd9(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1280 <main+0x110>
cmpq   $0x0,-0x18(%rbp)
je     1280 <main+0x110>
cmpq   $0x0,-0x20(%rbp)
jne    12a1 <main+0x131>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132c <main+0x1bc>
mov    -0x10(%rbp),%rax
mov    %rax,-0x238(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <atoi@plt>
mov    -0x238(%rbp),%rdi
mov    -0x230(%rbp),%rsi
mov    %eax,%edx
call   1060 <streaming@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1303 <main+0x193>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132c <main+0x1bc>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
jmp    11fe <main+0x8e>
jmp    1325 <main+0x1b5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1030 <memset@plt>
lea    0xe69(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     122b <main+0xbb>
mov    %rax,%r13
mov    %rsp,%r12
lea    0xe76(%rip),%rbx
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x1f4,%esi
mov    %r13,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     124f <main+0xdf>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rbp,%rbp
je     1234 <main+0xc4>
test   %r14,%r14
je     1234 <main+0xc4>
test   %rax,%rax
je     1234 <main+0xc4>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <streaming@plt>
test   %eax,%eax
je     11c0 <main+0x50>
lea    0xe23(%rip),%rsi
jmp    123b <main+0xcb>
lea    0xddf(%rip),%rsi
jmp    123b <main+0xcb>
lea    0xdf6(%rip),%rsi
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1050 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"./playlist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Cannot open the target file.\0A\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [27 x i8] c"Grammer error in pgmlist.\0A\00"
@.str.5 = [34 x i8] c"Something error while streaming.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [500 x i8]
%7 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i8 signext 0, i32 500)
%10 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %51
15: ; preds = %0
br label %16
16: ; preds = %48, %15
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%18 = load i32*, i32** %7
%19 = call i64 @fgets(i8* %17, i32 500, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %16
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %23, i8** %3
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %24, i8** %4
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %25, i8** %5
%26 = load i8*, i8** %3
%27 = icmp eq i8* %26, null
br i1 %27, label %34, label %28
28: ; preds = %21
%29 = load i8*, i8** %4
%30 = icmp eq i8* %29, null
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %31, %28, %21
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %51
37: ; preds = %31
%38 = load i8*, i8** %3
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = call i32 @atoi(i8* %40)
%42 = call i32 @streaming(i8* %38, i8* %39, i32 %41)
store i32 %42, i32* %2
%43 = load i32, i32* %2
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %51
48: ; preds = %37
store i8* null, i8** %5
store i8* null, i8** %4
store i8* null, i8** %3
br label %16
49: ; preds = %16
br label %50
50: ; preds = %49
store i32 0, i32* %1
br label %51
51: ; preds = %50, %45, %34, %12
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [15 x i8] c"./playlist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Cannot open the target file.\0A\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [27 x i8] c"Grammer error in pgmlist.\0A\00"
@.str.5 = [34 x i8] c"Something error while streaming.\0A\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i8 signext 0, i32 500)
%4 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %22, label %6
6: ; preds = %0, %18
%7 = call i64 @fgets(i8* %2, i32 500, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %26, label %9
9: ; preds = %6
%10 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i8* %10, null
%14 = icmp eq i8* %11, null
%15 = select i1 %13, i1 true, i1 %14
%16 = icmp eq i8* %12, null
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %22, label %18
18: ; preds = %9
%19 = call i32 @atoi(i8* %12)
%20 = call i32 @streaming(i8* %10, i8* %11, i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %6, label %22
22: ; preds = %18, %9, %0
%23 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), %18 ]
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* %23)
br label %26
26: ; preds = %6, %22
%27 = phi i32 [ 1, %22 ], [ 0, %6 ]
ret i32 %27
}