#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 getClockwiseAngle(int, int);
int getTotalDegDialTurned(int initPos, int fstPos, int sndPos, int thdPos) {
  int totalDeg;
  totalDeg = 360 + 360;
  totalDeg += 360 - getClockwiseAngle(initPos, fstPos);
  totalDeg += 360;
  totalDeg += getClockwiseAngle(fstPos, sndPos);
  totalDeg += 360 - getClockwiseAngle(sndPos, thdPos);
  return totalDeg;
}


x86 assembly (clang, -O0):
<getTotalDegDialTurned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x2d0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <getClockwiseAngle@plt>
mov    %eax,%ecx
mov    $0x168,%eax
sub    %ecx,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x168,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <getClockwiseAngle@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <getClockwiseAngle@plt>
mov    %eax,%ecx
mov    $0x168,%eax
sub    %ecx,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTotalDegDialTurned>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
call   1030 <getClockwiseAngle@plt>
mov    %eax,%r15d
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <getClockwiseAngle@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <getClockwiseAngle@plt>
add    %r15d,%eax
neg    %eax
add    %ebx,%eax
add    $0x708,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getTotalDegDialTurned(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 720, i32* %9
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @getClockwiseAngle(i32 %10, i32 %11)
%13 = sub nsw i32 360, %12
%14 = load i32, i32* %9
%15 = add nsw i32 %14, %13
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 360
store i32 %17, i32* %9
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 @getClockwiseAngle(i32 %18, i32 %19)
%21 = load i32, i32* %9
%22 = add nsw i32 %21, %20
store i32 %22, i32* %9
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @getClockwiseAngle(i32 %23, i32 %24)
%26 = sub nsw i32 360, %25
%27 = load i32, i32* %9
%28 = add nsw i32 %27, %26
store i32 %28, i32* %9
%29 = load i32, i32* %9
ret i32 %29
}

LLVM IR (-O2):
define i32 @getTotalDegDialTurned(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @getClockwiseAngle(i32 %0, i32 %1)
%6 = tail call i32 @getClockwiseAngle(i32 %1, i32 %2)
%7 = tail call i32 @getClockwiseAngle(i32 %2, i32 %3)
%8 = add i32 %6, 1800
%9 = add i32 %5, %7
%10 = sub i32 %8, %9
ret i32 %10
}