#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 /*<<< orphan*/ assert(int);
int from_synchsafe(int);
int is_synchsafe(int);
int to_synchsafe(int);
void check_synchsafe(void) {
  assert(to_synchsafe(0x0FFFFFFF) == 0x7F7F7F7F);
  assert(from_synchsafe(0x7F7F7F7F) == 0x0FFFFFFF);
  assert(to_synchsafe(0) == 0);
  assert(from_synchsafe(0) == 0);
  assert(to_synchsafe(0x00204080) == 0x01010100);
  assert(from_synchsafe(0x01010100) == 0x00204080);
  assert(is_synchsafe(0x7F7F7F7F));
  assert(!is_synchsafe(0x80000000));
}


x86 assembly (clang, -O0):
<check_synchsafe>:
push   %rbp
mov    %rsp,%rbp
mov    $0xfffffff,%edi
call   1060 <to_synchsafe@plt>
cmp    $0x7f7f7f7f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x7f7f7f7f,%edi
call   1050 <from_synchsafe@plt>
cmp    $0xfffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %edi,%edi
call   1060 <to_synchsafe@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %edi,%edi
call   1050 <from_synchsafe@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x204080,%edi
call   1060 <to_synchsafe@plt>
cmp    $0x1010100,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x1010100,%edi
call   1050 <from_synchsafe@plt>
cmp    $0x204080,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x7f7f7f7f,%edi
call   1030 <is_synchsafe@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x80000000,%edi
call   1030 <is_synchsafe@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_synchsafe>:
push   %rax
mov    $0xfffffff,%edi
call   1060 <to_synchsafe@plt>
xor    %edi,%edi
cmp    $0x7f7f7f7f,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x7f7f7f7f,%edi
call   1050 <from_synchsafe@plt>
xor    %edi,%edi
cmp    $0xfffffff,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
call   1060 <to_synchsafe@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
call   1050 <from_synchsafe@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x204080,%edi
call   1060 <to_synchsafe@plt>
xor    %edi,%edi
cmp    $0x1010100,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x1010100,%edi
call   1050 <from_synchsafe@plt>
xor    %edi,%edi
cmp    $0x204080,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x7f7f7f7f,%edi
call   1030 <is_synchsafe@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x80000000,%edi
call   1030 <is_synchsafe@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
pop    %rax
jmp    1040 <assert@plt>

LLVM IR (-O0):
define void @check_synchsafe() {
%1 = call i32 @to_synchsafe(i32 268435455)
%2 = icmp eq i32 %1, 2139062143
%3 = zext i1 %2 to i32
%4 = call i32 @assert(i32 %3)
%5 = call i32 @from_synchsafe(i32 2139062143)
%6 = icmp eq i32 %5, 268435455
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @to_synchsafe(i32 0)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @from_synchsafe(i32 0)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @to_synchsafe(i32 2113664)
%18 = icmp eq i32 %17, 16843008
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @from_synchsafe(i32 16843008)
%22 = icmp eq i32 %21, 2113664
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 @is_synchsafe(i32 2139062143)
%26 = call i32 @assert(i32 %25)
%27 = call i32 @is_synchsafe(i32 -2147483648)
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret void
}

LLVM IR (-O2):
define void @check_synchsafe() {
%1 = tail call i32 @to_synchsafe(i32 268435455)
%2 = icmp eq i32 %1, 2139062143
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @from_synchsafe(i32 2139062143)
%6 = icmp eq i32 %5, 268435455
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @to_synchsafe(i32 0)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @from_synchsafe(i32 0)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @to_synchsafe(i32 2113664)
%18 = icmp eq i32 %17, 16843008
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @from_synchsafe(i32 16843008)
%22 = icmp eq i32 %21, 2113664
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @is_synchsafe(i32 2139062143)
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @is_synchsafe(i32 -2147483648)
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
ret void
}