#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 getTotalDegDialTurned(int, int, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main(void) {
  int initPos, fstPos, sndPos, thdPos;
  while (1) {
    scanf("%d %d %d %d", &initPos, &fstPos, &sndPos, &thdPos);
    if (!(initPos || fstPos || sndPos || thdPos)) {
      break;
    }
    printf("%d\n", getTotalDegDialTurned(initPos, fstPos, sndPos, thdPos));
  }
  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    11ac <main+0x7c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <getTotalDegDialTurned@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
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    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0xeac(%rip),%rbp
jmp    117f <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <getTotalDegDialTurned@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <printf@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    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
test   %edi,%edi
jne    1170 <main+0x40>
test   %esi,%esi
jne    1170 <main+0x40>
test   %edx,%edx
jne    1170 <main+0x40>
test   %ecx,%ecx
jne    1170 <main+0x40>
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 = [4 x i8] c"%d\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, %20
%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 ne i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
br label %27
20: ; preds = %16, %13, %10, %6
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 @getTotalDegDialTurned(i32 %21, i32 %22, i32 %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %6
27: ; preds = %19
ret i32 0
}

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