#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*/ FILE;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
size_t sscanf(char *, char *, int *, int *, int *, int *, int *, int *, int *,
              int *, char *);
char *strstr(char *, char *);
void parse_ass(char *filename) {
  char l[BUFSIZ];
  char p[128];
  int start[4], end[4];
  FILE *fh;
  if ((fh = fopen(filename, "r")) == NULL) {
    perror("Error opening input ASS file");
    exit(1);
  }
  int i = 0;
  while (fgets(l, BUFSIZ - 1, fh) != NULL) {
    i++;
    if (l[0] == 0 || l[0] == '\n' || l[0] == '\r')
      continue;
    size_t x =
        sscanf(l, "Dialogue: %*d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s[127]",
               &start[0], &start[1], &start[2], &start[3], &end[0], &end[1],
               &end[2], &end[3], p);
    if (x == 9) {
      char *subchar_start = strstr(p, ",");
      if (subchar_start == NULL) {
        printf("Error while parsing ASS in line %d - no ',' found after end "
               "timestamp.",
               i);
        exit(1);
      }
      subchar_start++;
      if (subchar_start[0] == '!') {
        printf("%d forced!\n", i);
      }
    }
  }
  fclose(fh);
}


x86 assembly (clang, -O0):
<parse_ass>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xf0,%rsp
mov    %rdi,-0x18(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    11f8 <parse_ass+0x78>
lea    0xe19(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0xdc(%rbp)
mov    -0xf8(%rbp),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
sub    $0x1,%esi
mov    -0xd8(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     139c <parse_ass+0x21c>
mov    -0xf8(%rbp),%rax
mov    -0xdc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xdc(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1273 <parse_ass+0xf3>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1273 <parse_ass+0xf3>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1278 <parse_ass+0xf8>
jmp    1202 <parse_ass+0x82>
mov    -0xf8(%rbp),%rdi
lea    -0xc0(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
add    $0x4,%rcx
lea    -0xc0(%rbp),%r8
add    $0x8,%r8
lea    -0xc0(%rbp),%r9
add    $0xc,%r9
lea    -0xd0(%rbp),%r14
lea    -0xd0(%rbp),%rbx
add    $0x4,%rbx
lea    -0xd0(%rbp),%r11
add    $0x8,%r11
lea    -0xd0(%rbp),%r10
add    $0xc,%r10
lea    -0xb0(%rbp),%rax
lea    0xd42(%rip),%rsi
sub    $0x30,%rsp
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1060 <sscanf@plt>
add    $0x30,%rsp
mov    %rax,-0xe8(%rbp)
cmpq   $0x9,-0xe8(%rbp)
09
jne    1397 <parse_ass+0x217>
lea    -0xb0(%rbp),%rdi
lea    0xd34(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0xf0(%rbp)
cmpq   $0x0,-0xf0(%rbp)
jne    135b <parse_ass+0x1db>
mov    -0xdc(%rbp),%esi
lea    0xd0f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    1392 <parse_ass+0x212>
mov    -0xdc(%rbp),%esi
lea    0xd15(%rip),%rdi
call   1040 <printf@plt>
jmp    1397 <parse_ass+0x217>
jmp    1202 <parse_ass+0x82>
mov    -0xd8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_ass>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    0x2e45(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe4a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12c9 <parse_ass+0x149>
mov    %rax,%r14
mov    (%r15),%esi
add    $0xffffffff,%esi
mov    %r12,%rdi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     129a <parse_ass+0x11a>
mov    $0x1,%ebx
mov    $0x2401,%r13d
jmp    120d <parse_ass+0x8d>
xchg   %ax,%ax
mov    (%r15),%esi
add    $0xffffffff,%esi
mov    %r12,%rdi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebx
test   %rax,%rax
je     129a <parse_ass+0x11a>
movzbl (%r12),%eax
cmp    $0xd,%rax
ja     121e <parse_ass+0x9e>
bt     %rax,%r13
jb     11f0 <parse_ass+0x70>
sub    $0x8,%rsp
mov    %r12,%rdi
lea    0xdf3(%rip),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
lea    -0x48(%rbp),%r8
lea    -0x44(%rbp),%r9
lea    -0xd0(%rbp),%rax
push   %rax
lea    -0x34(%rbp),%rax
push   %rax
lea    -0x38(%rbp),%rax
push   %rax
lea    -0x3c(%rbp),%rax
push   %rax
lea    -0x40(%rbp),%rax
push   %rax
call   1070 <sscanf@plt>
add    $0x30,%rsp
cmp    $0x9,%rax
jne    11f0 <parse_ass+0x70>
lea    -0xd0(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12b1 <parse_ass+0x131>
cmpb   $0x21,0x1(%rax)
jne    11f0 <parse_ass+0x70>
lea    0xe12(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
jmp    11f0 <parse_ass+0x70>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda1(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xd32(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [29 x i8] c"Error opening input ASS file\00"
@.str.2 = [58 x i8] c"Dialogue: %*d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s[127]\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [71 x i8] c"Error while parsing ASS in line %d - no ',' found after end timestamp.\00"
@.str.5 = [12 x i8] c"%d forced!\0A\00"
define void @parse_ass(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [128 x i8]
%6 = alloca [4 x i32]
%7 = alloca [4 x i32]
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i8*
store i8* %0, i8** %2
%12 = load i32, i32* @BUFSIZ
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %3
%15 = alloca i8, i64 %13
store i64 %13, i64* %4
%16 = load i8*, i8** %2
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %1
%20 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
store i32 0, i32* %9
br label %23
23: ; preds = %81, %46, %22
%24 = load i32, i32* @BUFSIZ
%25 = sub nsw i32 %24, 1
%26 = load i32*, i32** %8
%27 = call i32* @fgets(i8* %15, i32 %25, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %82
29: ; preds = %23
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
%32 = getelementptr inbounds i8, i8* %15, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %46, label %36
36: ; preds = %29
%37 = getelementptr inbounds i8, i8* %15, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = getelementptr inbounds i8, i8* %15, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 13
br i1 %45, label %46, label %47
46: ; preds = %41, %36, %29
br label %23
47: ; preds = %41
%48 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 1
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 2
%51 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 3
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 1
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 2
%55 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 3
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%57 = call i64 @sscanf(i8* %15, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32* %48, i32* %49, i32* %50, i32* %51, i32* %52, i32* %53, i32* %54, i32* %55, i8* %56)
store i64 %57, i64* %10
%58 = load i64, i64* %10
%59 = icmp eq i64 %58, 9
br i1 %59, label %60, label %81
60: ; preds = %47
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%62 = call i8* @strstr(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %62, i8** %11
%63 = load i8*, i8** %11
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %69
65: ; preds = %60
%66 = load i32, i32* %9
%67 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i32 %66)
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %60
%70 = load i8*, i8** %11
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %11
%72 = load i8*, i8** %11
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 33
br i1 %76, label %77, label %80
77: ; preds = %69
%78 = load i32, i32* %9
%79 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %77, %69
br label %81
81: ; preds = %80, %47
br label %23
82: ; preds = %23
%83 = load i32*, i32** %8
%84 = call i32 @fclose(i32* %83)
%85 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [29 x i8] c"Error opening input ASS file\00"
@.str.2 = [58 x i8] c"Dialogue: %*d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s[127]\00"
@.str.4 = [71 x i8] c"Error while parsing ASS in line %d - no ',' found after end timestamp.\00"
@.str.5 = [12 x i8] c"%d forced!\0A\00"
define void @parse_ass(i8* nocapture %0) {
%2 = alloca [128 x i8]
%3 = alloca [4 x i32]
%4 = alloca [4 x i32]
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = bitcast [4 x i32]* %3 to i8*
%10 = bitcast [4 x i32]* %4 to i8*
%11 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %27, label %13
13: ; preds = %1
%14 = load i32, i32* @BUFSIZ
%15 = add nsw i32 %14, -1
%16 = call i32* @fgets(i8* %7, i32 %15, i32* %11)
%17 = icmp eq i32* %16, null
br i1 %17, label %54, label %18
18: ; preds = %13
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
br label %30
27: ; preds = %1
%28 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %18, %34
%31 = phi i32 [ 0, %18 ], [ %32, %34 ]
%32 = add nuw nsw i32 %31, 1
%33 = load i8, i8* %7
switch i8 %33, label %39 [
i8 0, label %34
i8 10, label %34
i8 13, label %34
]
34: ; preds = %39, %52, %48, %30, %30, %30
%35 = load i32, i32* @BUFSIZ
%36 = add nsw i32 %35, -1
%37 = call i32* @fgets(i8* %7, i32 %36, i32* %11)
%38 = icmp eq i32* %37, null
br i1 %38, label %54, label %30
39: ; preds = %30
%40 = call i64 @sscanf(i8* %7, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32* %19, i32* %20, i32* %21, i32* %22, i32* %23, i32* %24, i32* %25, i32* %26, i8* %8)
%41 = icmp eq i64 %40, 9
br i1 %41, label %42, label %34
42: ; preds = %39
%43 = call i8* @strchr(i8* %8, i32 44)
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %42
%49 = getelementptr inbounds i8, i8* %43, i64 1
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 33
br i1 %51, label %52, label %34
52: ; preds = %48
%53 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
54: ; preds = %34, %13
%55 = call i32 @fclose(i32* %11)
ret void
}