#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() {
  int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
  while (1) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == 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)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1186 <main+0x56>
jmp    1218 <main+0xe8>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11af <main+0x7f>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11af <main+0x7f>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    1213 <main+0xe3>
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
sub    -0x14(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11f1 <main+0xc1>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11f1 <main+0xc1>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1202 <main+0xd2>
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
jmp    120e <main+0xde>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
jmp    1213 <main+0xe3>
jmp    115b <main+0x2b>
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
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe9b(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
test   %edi,%edi
je     122f <main+0xff>
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0xe69(%rip),%r14
jmp    11d8 <main+0xa8>
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rdi
call   1030 <puts@plt>
lea    0xe41(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
test   %edi,%edi
je     122f <main+0xff>
sub    0x14(%rsp),%edi
jne    11ef <main+0xbf>
mov    0xc(%rsp),%eax
lea    0xe27(%rip),%rcx
cmp    0x8(%rsp),%eax
je     11b0 <main+0x80>
call   1040 <abs@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%edi
sub    0x8(%rsp),%edi
call   1040 <abs@plt>
mov    %r14,%rcx
cmp    %rax,%rbp
je     11b0 <main+0x80>
mov    0x10(%rsp),%eax
mov    %r14,%rcx
cmp    0x14(%rsp),%eax
je     11b0 <main+0x80>
mov    0xc(%rsp),%eax
mov    %r14,%rcx
cmp    0x8(%rsp),%eax
je     11b0 <main+0x80>
lea    0xddf(%rip),%rcx
jmp    11b0 <main+0x80>
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
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %0, %44
%7 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %4, i32* %3, i32* %5)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %45
11: ; preds = %6
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %44
21: ; preds = %15, %11
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = sub nsw i32 %22, %23
%25 = call i64 @abs(i32 %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = sub nsw i32 %26, %27
%29 = call i64 @abs(i32 %28)
%30 = icmp eq i64 %25, %29
br i1 %30, label %39, label %31
31: ; preds = %21
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = icmp eq i32 %32, %33
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35, %31, %21
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %43
41: ; preds = %35
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %39
br label %44
44: ; preds = %43, %19
br label %6
45: ; preds = %10
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*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %3, i32* %2, i32* %4)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %43, label %12
12: ; preds = %0, %37
%13 = phi i32 [ %41, %37 ], [ %10, %0 ]
%14 = load i32, i32* %2
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp eq i32 %17, %18
br i1 %19, label %37, label %20
20: ; preds = %16, %12
%21 = sub nsw i32 %13, %14
%22 = call i64 @abs(i32 %21)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = call i64 @abs(i32 %25)
%27 = icmp eq i64 %22, %26
br i1 %27, label %37, label %28
28: ; preds = %20
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = icmp eq i32 %29, %30
br i1 %31, label %37, label %32
32: ; preds = %28
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = icmp eq i32 %33, %34
%36 = select i1 %35, 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 %37
37: ; preds = %32, %20, %28, %16
%38 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %28 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %20 ], [ %36, %32 ]
%39 = call i32 @puts(i8* dereferenceable(1) %38)
%40 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %3, i32* %2, i32* %4)
%41 = load i32, i32* %1
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %12
43: ; preds = %37, %0
ret i32 0
}