#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);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main(void) {
  int T, p, e, i, d, ans;
  for (T = 1;; T++) {
    scanf("%d%d%d%d", &p, &e, &i, &d);
    if (p == -1)
      break;
    ans = 5544 * p + 14421 * e + 1288 * i - d + 21252;
    printf("Case %d: the next triple peak occurs in %d days.\n", T,
           (ans - 1) % 21252 + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec3(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1161 <main+0x41>
jmp    11b3 <main+0x93>
imul   $0x15a8,-0xc(%rbp),%eax
imul   $0x3855,-0x10(%rbp),%ecx
add    %ecx,%eax
imul   $0x508,-0x14(%rbp),%ecx
add    %ecx,%eax
sub    -0x18(%rbp),%eax
add    $0x5304,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    $0x5304,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0xffffffff,%eax
je     11f3 <main+0xd3>
mov    $0x1,%ebx
lea    0xe99(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%r14
nopl   0x0(%rax,%rax,1)
imul   $0x3855,0x14(%rsp),%ecx
imul   $0x15a8,%eax,%eax
add    %eax,%ecx
imul   $0x508,0x10(%rsp),%eax
add    %ecx,%eax
sub    0xc(%rsp),%eax
add    $0x5303,%eax
movslq %eax,%rdx
imul   $0x31571165,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x5304,%eax,%eax
sub    %eax,%edx
add    $0x1,%edx
lea    0xe3d(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0xffffffff,%eax
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d%d%d%d\00"
@.str.1 = [50 x i8] c"Case %d: the next triple peak occurs in %d days.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %8
8: ; preds = %31, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %8
br label %34
13: ; preds = %8
%14 = load i32, i32* %3
%15 = mul nsw i32 5544, %14
%16 = load i32, i32* %4
%17 = mul nsw i32 14421, %16
%18 = add nsw i32 %15, %17
%19 = load i32, i32* %5
%20 = mul nsw i32 1288, %19
%21 = add nsw i32 %18, %20
%22 = load i32, i32* %6
%23 = sub nsw i32 %21, %22
%24 = add nsw i32 %23, 21252
store i32 %24, i32* %7
%25 = load i32, i32* %2
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = srem i32 %27, 21252
%29 = add nsw i32 %28, 1
%30 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %29)
br label %31
31: ; preds = %13
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %8
34: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d%d%d%d\00"
@.str.1 = [50 x i8] c"Case %d: the next triple peak occurs in %d days.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, -1
br i1 %11, label %32, label %12
12: ; preds = %0, %12
%13 = phi i32 [ %30, %12 ], [ %10, %0 ]
%14 = phi i32 [ %28, %12 ], [ 1, %0 ]
%15 = mul nsw i32 %13, 5544
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 14421
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 1288
%20 = load i32, i32* %4
%21 = add i32 %15, 21251
%22 = add i32 %21, %17
%23 = add i32 %22, %19
%24 = sub i32 %23, %20
%25 = srem i32 %24, 21252
%26 = add nsw i32 %25, 1
%27 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %26)
%28 = add nuw nsw i32 %14, 1
%29 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %12
32: ; preds = %12, %0
ret i32 0
}