#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__ abs(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main() {
  while (1) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0)
      break;
    if (x1 == x2 && y1 == y2)
      printf("0\n");
    else if (abs(x1 - x2) == abs(y1 - y2) || ((x1 == x2) || (y1 == y2)))
      printf("1\n");
    else
      printf("2\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1188 <main+0x58>
cmpl   $0x0,-0xc(%rbp)
jne    1188 <main+0x58>
cmpl   $0x0,-0x10(%rbp)
jne    1188 <main+0x58>
cmpl   $0x0,-0x14(%rbp)
jne    1188 <main+0x58>
jmp    121a <main+0xea>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11b1 <main+0x81>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11b1 <main+0x81>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x14(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11f3 <main+0xc3>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11f3 <main+0xc3>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1204 <main+0xd4>
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
jmp    1210 <main+0xe0>
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
jmp    113f <main+0xf>
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),%r14
lea    0x14(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbx
jmp    1168 <main+0x38>
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1050 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%ecx
mov    0x8(%rsp),%edx
test   %edi,%edi
jne    119c <main+0x6c>
test   %eax,%eax
jne    119c <main+0x6c>
test   %ecx,%ecx
jne    119c <main+0x6c>
test   %edx,%edx
je     11fc <main+0xcc>
sub    %ecx,%edi
jne    11ab <main+0x7b>
lea    0xe69(%rip),%rcx
cmp    %edx,%eax
je     1160 <main+0x30>
call   1040 <abs@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%edi
sub    0x8(%rsp),%edi
call   1040 <abs@plt>
lea    0xe47(%rip),%rcx
cmp    %rax,%rbp
je     1160 <main+0x30>
mov    0x14(%rsp),%eax
lea    0xe37(%rip),%rcx
cmp    0x10(%rsp),%eax
je     1160 <main+0x30>
mov    0xc(%rsp),%eax
cmp    0x8(%rsp),%eax
lea    0xe20(%rip),%rcx
lea    0xe1b(%rip),%rax
cmove  %rax,%rcx
jmp    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 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [3 x i8] c"2\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %53
%7 = 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)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
br label %54
20: ; preds = %16, %13, %10, %6
%21 = load i32, i32* %2
%22 = load i32, i32* %4
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %53
30: ; preds = %24, %20
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = sub nsw i32 %31, %32
%34 = call i64 @abs(i32 %33)
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = sub nsw i32 %35, %36
%38 = call i64 @abs(i32 %37)
%39 = icmp eq i64 %34, %38
br i1 %39, label %48, label %40
40: ; preds = %30
%41 = load i32, i32* %2
%42 = load i32, i32* %4
%43 = icmp eq i32 %41, %42
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i32, i32* %3
%46 = load i32, i32* %5
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44, %40, %30
%49 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %52
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
br label %53
53: ; preds = %52, %28
br label %6
54: ; preds = %19
ret i32 0
}

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