#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int);
scalar_t__ scanf(char *, int *, int *, int *, int *);
int solve(int, int, int, int);
int main() {
  int z, i, m, l;
  int index;
  index = 1;
  while (scanf("%d%d%d%d", &z, &i, &m, &l) != EOF) {
    if (z == 0 && i == 0 && m == 0 && l == 0)
      break;
    solve(z, i, m, l);
    printf("Case %d: %d\n", index++, solve(z, i, m, l));
  }
  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    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <scanf@plt>
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%rax
je     11e3 <main+0xb3>
cmpl   $0x0,-0x8(%rbp)
jne    119f <main+0x6f>
cmpl   $0x0,-0xc(%rbp)
jne    119f <main+0x6f>
cmpl   $0x0,-0x10(%rbp)
jne    119f <main+0x6f>
cmpl   $0x0,-0x14(%rbp)
jne    119f <main+0x6f>
jmp    11e3 <main+0xb3>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <solve@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <solve@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
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
lea    0xebb(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <scanf@plt>
mov    0x2e83(%rip),%r15
cmp    (%r15),%rax
je     1201 <main+0xd1>
mov    $0x1,%r14d
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%rbp
jmp    11e1 <main+0xb1>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <solve@plt>
lea    0x1(%r14),%r12d
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
call   1030 <solve@plt>
lea    0xe54(%rip),%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    0x14(%rsp),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1050 <scanf@plt>
mov    %r12d,%r14d
cmp    (%r15),%rax
je     1201 <main+0xd1>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
test   %edi,%edi
jne    1190 <main+0x60>
test   %esi,%esi
jne    1190 <main+0x60>
test   %edx,%edx
jne    1190 <main+0x60>
test   %ecx,%ecx
jne    1190 <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"
@EOF = global i64 0
@.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 = %24, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %38
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
br label %38
24: ; preds = %20, %17, %14, %11
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @solve(i32 %25, i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = call i32 @solve(i32 %32, i32 %33, i32 %34, i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %36)
br label %7
38: ; preds = %23, %7
ret i32 0
}

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