#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 */
struct shmm_blk {
  int dummy;
};
struct rbnode {
  int dummy;
};

/* Variables and functions */
struct shmm_blk *_conv_shmm_from_rbn(struct rbnode *);
void *shmm_begin_addr(struct shmm_blk *);
void *shmm_end_addr(struct shmm_blk *);
long _shmm_comp_func(void *key, struct rbnode *rbn) {
  struct shmm_blk *shm = _conv_shmm_from_rbn(rbn);
  void *addr_begin = shmm_begin_addr(shm);
  void *addr_end = shmm_end_addr(shm);
  if (key < addr_begin)
    return -1;
  else if (key >= addr_end)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<_shmm_comp_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <_conv_shmm_from_rbn@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <shmm_begin_addr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <shmm_end_addr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1182 <_shmm_comp_func+0x52>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11aa <_shmm_comp_func+0x7a>
mov    -0x10(%rbp),%rax
cmp    -0x30(%rbp),%rax
jb     119d <_shmm_comp_func+0x6d>
movq   $0x1,-0x8(%rbp)
jmp    11aa <_shmm_comp_func+0x7a>
jmp    11a2 <_shmm_comp_func+0x72>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_shmm_comp_func>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <_conv_shmm_from_rbn@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <shmm_begin_addr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <shmm_end_addr@plt>
xor    %ecx,%ecx
cmp    %r14,%rax
setbe  %cl
cmp    %r14,%r15
mov    $0xffffffffffffffff,%rax
cmovbe %rcx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rbnode = type { i32 }
%struct.shmm_blk = type { i32 }
define i64 @_shmm_comp_func(i8* %0, %struct.rbnode* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca %struct.rbnode*
%6 = alloca %struct.shmm_blk*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store %struct.rbnode* %1, %struct.rbnode** %5
%9 = load %struct.rbnode*, %struct.rbnode** %5
%10 = call %struct.shmm_blk* @_conv_shmm_from_rbn(%struct.rbnode* %9)
store %struct.shmm_blk* %10, %struct.shmm_blk** %6
%11 = load %struct.shmm_blk*, %struct.shmm_blk** %6
%12 = call i8* @shmm_begin_addr(%struct.shmm_blk* %11)
store i8* %12, i8** %7
%13 = load %struct.shmm_blk*, %struct.shmm_blk** %6
%14 = call i8* @shmm_end_addr(%struct.shmm_blk* %13)
store i8* %14, i8** %8
%15 = load i8*, i8** %4
%16 = load i8*, i8** %7
%17 = icmp ult i8* %15, %16
br i1 %17, label %18, label %19
18: ; preds = %2
store i64 -1, i64* %3
br label %26
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = load i8*, i8** %8
%22 = icmp uge i8* %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i64 1, i64* %3
br label %26
24: ; preds = %19
br label %25
25: ; preds = %24
store i64 0, i64* %3
br label %26
26: ; preds = %25, %23, %18
%27 = load i64, i64* %3
ret i64 %27
}

LLVM IR (-O2):
%struct.rbnode = type { i32 }
%struct.shmm_blk = type { i32 }
define i64 @_shmm_comp_func(i8* readnone %0, %struct.rbnode* %1) {
%3 = tail call %struct.shmm_blk* @_conv_shmm_from_rbn(%struct.rbnode* %1)
%4 = tail call i8* @shmm_begin_addr(%struct.shmm_blk* %3)
%5 = tail call i8* @shmm_end_addr(%struct.shmm_blk* %3)
%6 = icmp ugt i8* %4, %0
%7 = icmp ule i8* %5, %0
%8 = zext i1 %7 to i64
%9 = select i1 %6, i64 -1, i64 %8
ret i64 %9
}