#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() {
  int p;
  int e;
  int i;
  int d;
  int count = 1;
  int k;
  while (1) {
    scanf("%d %d %d %d", &p, &e, &i, &d);
    if (p == -1 && e == -1 && i == -1 && d == -1) {
      break;
    }
    for (k = d + 1; k <= 21252 + d; k++) {
      if ((k - p) % 23 == 0 && (k - e) % 28 == 0 && (k - i) % 33 == 0)
        break;
    }
    printf("Case %d: the next triple peak occurs in %d days.\n", count, k - d);
    count++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    117f <main+0x5f>
cmpl   $0xffffffff,-0xc(%rbp)
jne    117f <main+0x5f>
cmpl   $0xffffffff,-0x10(%rbp)
jne    117f <main+0x5f>
cmpl   $0xffffffff,-0x14(%rbp)
jne    117f <main+0x5f>
jmp    121c <main+0xfc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x5304,%ecx
cmp    %ecx,%eax
jg     11f9 <main+0xd9>
mov    -0x1c(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x17,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e6 <main+0xc6>
mov    -0x1c(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e6 <main+0xc6>
mov    -0x1c(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x21,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e6 <main+0xc6>
jmp    11f9 <main+0xd9>
jmp    11eb <main+0xcb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1188 <main+0x68>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
sub    -0x14(%rbp),%edx
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%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
mov    $0x1,%r15d
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
jmp    1168 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edx
sub    %r8d,%edx
lea    0xeb0(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
add    $0x1,%r15d
lea    0xe91(%rip),%rdi
lea    0x14(%rsp),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1040 <scanf@plt>
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%r8d
cmp    $0xffffffff,%ecx
jne    11a8 <main+0x88>
cmp    $0xffffffff,%esi
jne    11a8 <main+0x88>
cmp    $0xffffffff,%edi
jne    11a8 <main+0x88>
cmp    $0xffffffff,%r8d
je     1224 <main+0x104>
lea    0x5304(%r8),%ebp
lea    0x1(%r8),%edx
cmp    %edx,%ebp
mov    %edx,%ebx
cmovg  %ebp,%ebx
add    $0x1,%ebx
neg    %ecx
neg    %esi
neg    %edi
jmp    11dd <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rdx),%eax
cmp    %ebp,%edx
mov    %eax,%edx
jge    1150 <main+0x30>
lea    (%rcx,%rdx,1),%eax
imul   $0xe9bd37a7,%eax,%eax
add    $0x590b216,%eax
cmp    $0xb21642c,%eax
ja     11d0 <main+0xb0>
lea    (%rsi,%rdx,1),%eax
imul   $0xb6db6db7,%eax,%eax
add    $0x12492490,%eax
ror    $0x2,%eax
cmp    $0x9249248,%eax
ja     11d0 <main+0xb0>
lea    (%rdi,%rdx,1),%eax
imul   $0x3e0f83e1,%eax,%eax
add    $0x3e0f83e,%eax
cmp    $0x7c1f07d,%eax
jae    11d0 <main+0xb0>
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 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* %6
br label %8
8: ; preds = %0, %53
%9 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %18
br label %61
22: ; preds = %18, %15, %12, %8
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %25
25: ; preds = %50, %22
%26 = load i32, i32* %7
%27 = load i32, i32* %5
%28 = add nsw i32 21252, %27
%29 = icmp sle i32 %26, %28
br i1 %29, label %30, label %53
30: ; preds = %25
%31 = load i32, i32* %7
%32 = load i32, i32* %2
%33 = sub nsw i32 %31, %32
%34 = srem i32 %33, 23
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %49
36: ; preds = %30
%37 = load i32, i32* %7
%38 = load i32, i32* %3
%39 = sub nsw i32 %37, %38
%40 = srem i32 %39, 28
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %36
%43 = load i32, i32* %7
%44 = load i32, i32* %4
%45 = sub nsw i32 %43, %44
%46 = srem i32 %45, 33
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %42
br label %53
49: ; preds = %42, %36, %30
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %25
53: ; preds = %48, %25
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = load i32, i32* %5
%57 = sub nsw i32 %55, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %57)
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %8
61: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [12 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*
br label %9
9: ; preds = %44, %0
%10 = phi i32 [ 1, %0 ], [ %48, %44 ]
%11 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, -1
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, -1
%16 = select i1 %13, i1 %15, i1 false
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, -1
%19 = select i1 %16, i1 %18, i1 false
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, -1
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %49, label %23
23: ; preds = %9
%24 = add i32 %20, 21252
%25 = add i32 %20, 1
%26 = call i32 @llvm.smax.i32(i32 %24, i32 %25)
%27 = add i32 %26, 1
br label %28
28: ; preds = %23, %41
%29 = phi i32 [ %25, %23 ], [ %42, %41 ]
%30 = sub nsw i32 %29, %12
%31 = srem i32 %30, 23
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %28
%34 = sub nsw i32 %29, %14
%35 = srem i32 %34, 28
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = sub nsw i32 %29, %17
%39 = srem i32 %38, 33
%40 = icmp eq i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %28, %33, %37
%42 = add nsw i32 %29, 1
%43 = icmp slt i32 %29, %24
br i1 %43, label %28, label %44
44: ; preds = %37, %41
%45 = phi i32 [ %29, %37 ], [ %27, %41 ]
%46 = sub nsw i32 %45, %20
%47 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %46)
%48 = add nuw nsw i32 %10, 1
br label %9
49: ; preds = %9
ret i32 0
}