#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 */
typedef scalar_t__ uint64_t;
typedef scalar_t__ int64_t;

/* Variables and functions */
int ptscmp(scalar_t__, scalar_t__);
int64_t ptsdiff(uint64_t pts1, uint64_t pts2) {
  switch (ptscmp(pts1, pts2)) {
  case 0:
    return 0;
    break;
  case 1:
  case -2:
    return (pts1 - pts2);
    break;
  case 2:
    return (pts1 + (300 * (0x0000000200000000ULL)) - pts2);
    break;
  case -1:
    return (pts1 - (pts2 + (300 * (0x0000000200000000ULL))));
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ptsdiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ptscmp@plt>
add    $0x2,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     11aa <ptsdiff+0x9a>
mov    -0x20(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x0,-0x8(%rbp)
jmp    11b2 <ptsdiff+0xa2>
mov    -0x10(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <ptsdiff+0xa2>
movabs $0x25800000000,%rax
add    -0x10(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <ptsdiff+0xa2>
mov    -0x10(%rbp),%rax
movabs $0x25800000000,%rcx
add    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <ptsdiff+0xa2>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptsdiff>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <ptscmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
add    $0x2,%ecx
cmp    $0x4,%ecx
ja     1162 <ptsdiff+0x52>
lea    0xece(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
sub    %r14,%rbx
mov    %rbx,%rax
jmp    1162 <ptsdiff+0x52>
sub    %r14,%rbx
movabs $0xfffffda800000000,%rax
fd ff ff
jmp    115f <ptsdiff+0x4f>
sub    %r14,%rbx
movabs $0x25800000000,%rax
add    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @ptsdiff(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %4
%7 = load i64, i64* %5
%8 = call i32 @ptscmp(i64 %6, i64 %7)
switch i32 %8, label %24 [
i32 0, label %9
i32 1, label %10
i32 -2, label %10
i32 2, label %14
i32 -1, label %19
]
9: ; preds = %2
store i64 0, i64* %3
br label %25
10: ; preds = %2, %2
%11 = load i64, i64* %4
%12 = load i64, i64* %5
%13 = sub nsw i64 %11, %12
store i64 %13, i64* %3
br label %25
14: ; preds = %2
%15 = load i64, i64* %4
%16 = add i64 %15, 2576980377600
%17 = load i64, i64* %5
%18 = sub i64 %16, %17
store i64 %18, i64* %3
br label %25
19: ; preds = %2
%20 = load i64, i64* %4
%21 = load i64, i64* %5
%22 = add i64 %21, 2576980377600
%23 = sub i64 %20, %22
store i64 %23, i64* %3
br label %25
24: ; preds = %2
store i64 0, i64* %3
br label %25
25: ; preds = %24, %19, %14, %10, %9
%26 = load i64, i64* %3
ret i64 %26
}

LLVM IR (-O2):
define i64 @ptsdiff(i64 %0, i64 %1) {
%3 = tail call i32 @ptscmp(i64 %0, i64 %1)
switch i32 %3, label %12 [
i32 -1, label %9
i32 1, label %4
i32 -2, label %4
i32 2, label %6
]
4: ; preds = %2, %2
%5 = sub nsw i64 %0, %1
br label %12
6: ; preds = %2
%7 = add i64 %0, 2576980377600
%8 = sub i64 %7, %1
br label %12
9: ; preds = %2
%10 = add i64 %0, -2576980377600
%11 = sub i64 %10, %1
br label %12
12: ; preds = %2, %9, %6, %4
%13 = phi i64 [ %11, %9 ], [ %8, %6 ], [ %5, %4 ], [ 0, %2 ]
ret i64 %13
}