#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 /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
void experiment() {
  int d, m;
  scanf("%d %d", &d, &m);
  int arr[m];
  for (int i = 0; i < m; i++)
    scanf("%d", arr + i);
  int current_day = 0, current_month = 0, count = 0;
  while (d) {
    if (arr[current_month] > 12 && ((current_day + 12) % 7 == 5))
      count++;
    d -= arr[current_month];
    current_day = (current_day + arr[current_month]) % 7;
    current_month++;
  }
  printf("%d\n", count);
}


x86 assembly (clang, -O0):
<experiment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a3 <experiment+0x83>
mov    -0x30(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <experiment+0x4c>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     122a <experiment+0x10a>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0xc,(%rax,%rcx,4)
jle    11f4 <experiment+0xd4>
mov    -0x20(%rbp),%eax
add    $0xc,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x5,%edx
jne    11f4 <experiment+0xd4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rcx
movslq -0x24(%rbp),%rax
mov    (%rcx,%rax,4),%edx
mov    -0x4(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%eax
movslq -0x24(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b8 <experiment+0x98>
mov    -0x28(%rbp),%esi
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<experiment>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
xor    %r14d,%r14d
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    119e <experiment+0x7e>
lea    0xe90(%rip),%r15
mov    %r13,%rbx
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1180 <experiment+0x60>
mov    -0x30(%rbp),%eax
test   %eax,%eax
je     122b <experiment+0x10b>
xor    %r14d,%r14d
xor    %ecx,%ecx
jmp    11df <experiment+0xbf>
add    %edx,%ecx
movslq %ecx,%rsi
imul   $0xffffffff92492493,%rsi,%rcx
shr    $0x20,%rcx
add    %esi,%ecx
mov    %ecx,%edi
shr    $0x1f,%edi
sar    $0x2,%ecx
add    %edi,%ecx
lea    0x0(,%rcx,8),%edi
sub    %edi,%ecx
add    %esi,%ecx
add    $0x4,%r13
sub    %edx,%eax
je     1224 <experiment+0x104>
mov    0x0(%r13),%edx
cmp    $0xd,%edx
jl     11b0 <experiment+0x90>
lea    0xc(%rcx),%esi
movslq %esi,%rsi
imul   $0xffffffff92492493,%rsi,%rsi
shr    $0x20,%rsi
add    %ecx,%esi
add    $0xc,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x2,%esi
add    %edi,%esi
lea    0x0(,%rsi,8),%edi
sub    %edi,%esi
add    %ecx,%esi
add    $0xc,%esi
xor    %edi,%edi
cmp    $0x5,%esi
sete   %dil
add    %edi,%r14d
jmp    11b0 <experiment+0x90>
movl   $0x0,-0x30(%rbp)
lea    0xdd4(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define void @experiment() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %9, i64 %13
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %45, label %23
23: ; preds = %20, %37
%24 = phi i64 [ %42, %37 ], [ 0, %20 ]
%25 = phi i32 [ %38, %37 ], [ 0, %20 ]
%26 = phi i32 [ %41, %37 ], [ 0, %20 ]
%27 = phi i32 [ %39, %37 ], [ %21, %20 ]
%28 = getelementptr inbounds i32, i32* %9, i64 %24
%29 = load i32, i32* %28
%30 = icmp sgt i32 %29, 12
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = add nsw i32 %26, 12
%33 = srem i32 %32, 7
%34 = icmp eq i32 %33, 5
%35 = zext i1 %34 to i32
%36 = add nsw i32 %25, %35
br label %37
37: ; preds = %31, %23
%38 = phi i32 [ %25, %23 ], [ %36, %31 ]
%39 = sub nsw i32 %27, %29
%40 = add nsw i32 %29, %26
%41 = srem i32 %40, 7
%42 = add nuw i64 %24, 1
%43 = icmp eq i32 %39, 0
br i1 %43, label %44, label %23
44: ; preds = %37
store i32 0, i32* %1
br label %45
45: ; preds = %44, %20
%46 = phi i32 [ %38, %44 ], [ 0, %20 ]
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %46)
ret void
}