#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 findCycleLength(int, int, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main(void) {
  int Z, L, I, M, caseId;
  caseId = 1;
  while (1) {
    scanf("%d %d %d %d", &Z, &I, &M, &L);
    if (Z == 0 && I == 0 && M == 0 && L == 0)
      break;
    printf("Case %d: %d\n", caseId, findCycleLength(Z, I, L, M));
    caseId++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    118f <main+0x5f>
cmpl   $0x0,-0x10(%rbp)
jne    118f <main+0x5f>
cmpl   $0x0,-0x14(%rbp)
jne    118f <main+0x5f>
cmpl   $0x0,-0xc(%rbp)
jne    118f <main+0x5f>
jmp    11c5 <main+0x95>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <findCycleLength@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <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,%ebx
lea    0x14(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
lea    0x10(%rsp),%rbp
lea    0xeae(%rip),%r14
jmp    1174 <main+0x44>
call   1030 <findCycleLength@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%ebx
lea    0xe85(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1050 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
test   %edi,%edi
jne    1160 <main+0x30>
test   %esi,%esi
jne    1160 <main+0x30>
test   %ecx,%ecx
jne    1160 <main+0x30>
test   %edx,%edx
jne    1160 <main+0x30>
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 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %6
br label %7
7: ; preds = %0, %21
%8 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %4, i32* %5, i32* %3)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
br label %31
21: ; preds = %17, %14, %11, %7
%22 = load i32, i32* %6
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = call i32 @findCycleLength(i32 %23, i32 %24, i32 %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %7
31: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d %d %d %d\00"
@.str.1 = [13 x i8] c"Case %d: %d\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 = %23, %0
%10 = phi i32 [ 1, %0 ], [ %26, %23 ]
%11 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %3, i32* %4, i32* %2)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 0
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
%16 = select i1 %13, i1 %15, i1 false
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
%19 = select i1 %16, i1 %18, i1 false
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %27, label %23
23: ; preds = %9
%24 = call i32 @findCycleLength(i32 %12, i32 %14, i32 %20, i32 %17)
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %24)
%26 = add nuw nsw i32 %10, 1
br label %9
27: ; preds = %9
ret i32 0
}