#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 momentSuits(int, int, int, int **);
int /*<<< orphan*/ printArgs(int, int, int, int, int **);
int /*<<< orphan*/ printf(char *, ...);
int **readArgs(int *, int *, int *, int *, int, char **);
int main(int argc, char *argv[]) {
  int p, q, l, r, loop, result;
  int **schedules;
  if (1 == 0)
    printf("\nP7 - Chat Online:\n");
  schedules = readArgs(&p, &q, &l, &r, argc, argv);
  if (1 == 0)
    printArgs(p, q, l, r, schedules);
  if (p < 1 || p > 50 || q < 1 || q > 50 || l < 0 || l > 1000 || r < 0 ||
      r > 1000) {
    printf("Invalid schedules. Aborting...\n");
    printf("\n--------------------\n");
    return 1;
  }
  if (1 == 0)
    printf("\nProblem Solution:\n");
  result = 0;
  for (loop = l; loop <= r; loop++) {
    if (momentSuits(loop, p, q, schedules) == 1)
      result++;
  }
  printf("%d", result);
  if (1 == 0)
    printf("\n--------------------\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <readArgs@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x32,-0x14(%rbp)
jg     11bd <main+0x8d>
cmpl   $0x1,-0x18(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x32,-0x18(%rbp)
jg     11bd <main+0x8d>
cmpl   $0x0,-0x1c(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x3e8,-0x1c(%rbp)
jg     11bd <main+0x8d>
cmpl   $0x0,-0x20(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x3e8,-0x20(%rbp)
jle    11e5 <main+0xb5>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x11d>
movl   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1235 <main+0x105>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1040 <momentSuits@plt>
cmp    $0x1,%eax
jne    1222 <main+0xf2>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1227 <main+0xf7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f2 <main+0xc2>
mov    -0x28(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r9
mov    %edi,%r8d
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1060 <readArgs@plt>
mov    %rax,%r15
mov    0x10(%rsp),%esi
lea    -0x33(%rsi),%eax
cmp    $0xffffffce,%eax
jb     11c2 <main+0x82>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    11c2 <main+0x82>
cmp    $0x32,%edx
jg     11c2 <main+0x82>
mov    0x14(%rsp),%ebp
test   %ebp,%ebp
js     11c2 <main+0x82>
cmp    $0x3e8,%ebp
jg     11c2 <main+0x82>
mov    0x8(%rsp),%eax
test   %eax,%eax
js     11c2 <main+0x82>
cmp    $0x3e8,%eax
jg     11c2 <main+0x82>
xor    %r14d,%r14d
mov    $0x0,%ebx
cmp    %eax,%ebp
jbe    11ee <main+0xae>
lea    0xe49(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e0 <main+0xa0>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
mov    %r15,%rcx
call   1050 <momentSuits@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
cmp    0x8(%rsp),%ebp
jge    11b0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %ebp,%edi
mov    %r15,%rcx
call   1050 <momentSuits@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebx
cmp    0x8(%rsp),%ebp
jl     1210 <main+0xd0>
jmp    11b0 <main+0x70>

LLVM IR (-O0):
@.str = [32 x i8] c"Invalid schedules. Aborting...\0A\00"
@.str.1 = [23 x i8] c"\0A--------------------\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32** @readArgs(i32* %6, i32* %7, i32* %8, i32* %9, i32 %13, i8** %14)
store i32** %15, i32*** %12
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 1
br i1 %17, label %39, label %18
18: ; preds = %2
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 50
br i1 %20, label %39, label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 1
br i1 %23, label %39, label %24
24: ; preds = %21
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 50
br i1 %26, label %39, label %27
27: ; preds = %24
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %27
%31 = load i32, i32* %8
%32 = icmp sgt i32 %31, 1000
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load i32, i32* %9
%35 = icmp slt i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* %9
%38 = icmp sgt i32 %37, 1000
br i1 %38, label %39, label %42
39: ; preds = %36, %33, %30, %27, %24, %21, %18, %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %65
42: ; preds = %36
store i32 0, i32* %11
%43 = load i32, i32* %8
store i32 %43, i32* %10
br label %44
44: ; preds = %59, %42
%45 = load i32, i32* %10
%46 = load i32, i32* %9
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %62
48: ; preds = %44
%49 = load i32, i32* %10
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = load i32**, i32*** %12
%53 = call i32 @momentSuits(i32 %49, i32 %50, i32 %51, i32** %52)
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %58
55: ; preds = %48
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %58
58: ; preds = %55, %48
br label %59
59: ; preds = %58
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %44
62: ; preds = %44
%63 = load i32, i32* %11
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63)
store i32 0, i32* %3
br label %65
65: ; preds = %62, %39
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [31 x i8] c"Invalid schedules. Aborting...\00"
@str.3 = [22 x i8] c"\0A--------------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32** @readArgs(i32* %3, i32* %4, i32* %5, i32* %6, i32 %0, i8** %1)
%12 = load i32, i32* %3
%13 = add i32 %12, -51
%14 = icmp ult i32 %13, -50
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 1
%17 = select i1 %14, i1 true, i1 %16
%18 = icmp sgt i32 %15, 50
%19 = select i1 %17, i1 true, i1 %18
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 0
%22 = select i1 %19, i1 true, i1 %21
%23 = icmp sgt i32 %20, 1000
%24 = select i1 %22, i1 true, i1 %23
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
%27 = select i1 %24, i1 true, i1 %26
%28 = icmp sgt i32 %25, 1000
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %38, label %30
30: ; preds = %2
%31 = icmp ugt i32 %20, %25
br i1 %31, label %53, label %32
32: ; preds = %30
%33 = call i32 @momentSuits(i32 %20, i32 %12, i32 %15, i32** %11)
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = load i32, i32* %6
%37 = icmp slt i32 %20, %36
br i1 %37, label %41, label %53
38: ; preds = %2
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
br label %56
41: ; preds = %32, %41
%42 = phi i32 [ %50, %41 ], [ %35, %32 ]
%43 = phi i32 [ %44, %41 ], [ %20, %32 ]
%44 = add nsw i32 %43, 1
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = call i32 @momentSuits(i32 %44, i32 %45, i32 %46, i32** %11)
%48 = icmp eq i32 %47, 1
%49 = zext i1 %48 to i32
%50 = add nuw nsw i32 %42, %49
%51 = load i32, i32* %6
%52 = icmp slt i32 %44, %51
br i1 %52, label %41, label %53
53: ; preds = %41, %32, %30
%54 = phi i32 [ 0, %30 ], [ %35, %32 ], [ %50, %41 ]
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %38
%57 = phi i32 [ 1, %38 ], [ 0, %53 ]
ret i32 %57
}