#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 UCHAR_MAX;
int strcoll(char *, char *);
int __collate_range_cmp(int c1, int c2) {
  static char s1[2], s2[2];
  int ret;
  c1 &= UCHAR_MAX;
  c2 &= UCHAR_MAX;
  if (c1 == c2)
    return (0);
  s1[0] = c1;
  s2[0] = c2;
  if ((ret = strcoll(s1, s2)) != 0)
    return (ret);
  return (c1 - c2);
}


x86 assembly (clang, -O0):
<__collate_range_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ecb(%rip),%rax
mov    (%rax),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2ebc(%rip),%rax
mov    (%rax),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1154 <__collate_range_cmp+0x44>
movl   $0x0,-0x4(%rbp)
jmp    1199 <__collate_range_cmp+0x89>
mov    -0x8(%rbp),%eax
mov    %al,0x2ecf(%rip)
mov    -0xc(%rbp),%eax
mov    %al,0x2ec8(%rip)
lea    0x2ebf(%rip),%rdi
lea    0x2eba(%rip),%rsi
call   1030 <strcoll@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     1190 <__collate_range_cmp+0x80>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <__collate_range_cmp+0x89>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__collate_range_cmp>:
push   %rbx
mov    0x2ed8(%rip),%rax
mov    (%rax),%eax
and    %eax,%edi
and    %eax,%esi
xor    %eax,%eax
mov    %edi,%ebx
sub    %esi,%ebx
je     114e <__collate_range_cmp+0x3e>
mov    %dil,0x2eff(%rip)
lea    0x2ef8(%rip),%rdi
mov    %sil,0x2ef3(%rip)
lea    0x2eec(%rip),%rsi
call   1030 <strcoll@plt>
test   %eax,%eax
cmovne %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__collate_range_cmp.s1 = internal global [2 x i8] zeroinitializer
@__collate_range_cmp.s2 = internal global [2 x i8] zeroinitializer
@UCHAR_MAX = global i32 0
define i32 @__collate_range_cmp(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* @UCHAR_MAX
%8 = load i32, i32* %4
%9 = and i32 %8, %7
store i32 %9, i32* %4
%10 = load i32, i32* @UCHAR_MAX
%11 = load i32, i32* %5
%12 = and i32 %11, %10
store i32 %12, i32* %5
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 0, i32* %3
br label %30
17: ; preds = %2
%18 = load i32, i32* %4
%19 = trunc i32 %18 to i8
store i8 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s1, i64 0, i64 0)
%20 = load i32, i32* %5
%21 = trunc i32 %20 to i8
store i8 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s2, i64 0, i64 0)
%22 = call i32 @strcoll(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s2, i64 0, i64 0))
store i32 %22, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %30
26: ; preds = %17
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = sub nsw i32 %27, %28
store i32 %29, i32* %3
br label %30
30: ; preds = %26, %24, %16
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@__collate_range_cmp.s1 = internal global [2 x i8] zeroinitializer
@__collate_range_cmp.s2 = internal global [2 x i8] zeroinitializer
@UCHAR_MAX = global i32 0
define i32 @__collate_range_cmp(i32 %0, i32 %1) {
%3 = load i32, i32* @UCHAR_MAX
%4 = and i32 %3, %0
%5 = and i32 %3, %1
%6 = icmp eq i32 %4, %5
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = trunc i32 %4 to i8
store i8 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s1, i64 0, i64 0)
%9 = trunc i32 %5 to i8
store i8 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s2, i64 0, i64 0)
%10 = tail call i32 @strcoll(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__collate_range_cmp.s2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = sub nsw i32 %4, %5
%13 = select i1 %11, i32 %12, i32 %10
br label %14
14: ; preds = %7, %2
%15 = phi i32 [ 0, %2 ], [ %13, %7 ]
ret i32 %15
}