#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 int uint16_t;

/* Variables and functions */
int toRep16(int);
int compareResultH(uint16_t result, uint16_t expected) {
  uint16_t rep = toRep16(result);
  if (rep == expected) {
    return 0;
  } else if (expected == 0x7e00U) {
    if ((rep & 0x7c00U) == 0x7c00U && (rep & 0x3ffU) > 0) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<compareResultH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <toRep16@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1141 <compareResultH+0x31>
movl   $0x0,-0x4(%rbp)
jmp    118f <compareResultH+0x7f>
cmpl   $0x7e00,-0xc(%rbp)
jne    1183 <compareResultH+0x73>
mov    -0x10(%rbp),%eax
and    $0x7c00,%eax
cmp    $0x7c00,%eax
jne    117e <compareResultH+0x6e>
mov    -0x10(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
jbe    117e <compareResultH+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    118f <compareResultH+0x7f>
jmp    1183 <compareResultH+0x73>
jmp    1188 <compareResultH+0x78>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareResultH>:
push   %rbx
mov    %esi,%ebx
call   1030 <toRep16@plt>
xor    %ecx,%ecx
cmp    %ebx,%eax
je     1140 <compareResultH+0x30>
xor    $0x7e00,%ebx
mov    %eax,%ecx
not    %ecx
and    $0x7c00,%ecx
or     %ebx,%ecx
setne  %cl
test   $0x3ff,%eax
sete   %al
or     %cl,%al
movzbl %al,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @compareResultH(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* %4
%8 = call i32 @toRep16(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %28
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 32256
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32, i32* %6
%18 = and i32 %17, 31744
%19 = icmp eq i32 %18, 31744
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* %6
%22 = and i32 %21, 1023
%23 = icmp ugt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %3
br label %28
25: ; preds = %20, %16
br label %26
26: ; preds = %25, %13
br label %27
27: ; preds = %26
store i32 1, i32* %3
br label %28
28: ; preds = %27, %24, %12
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @compareResultH(i32 %0, i32 %1) {
%3 = tail call i32 @toRep16(i32 %0)
%4 = icmp eq i32 %3, %1
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = icmp ne i32 %1, 32256
%7 = and i32 %3, 31744
%8 = icmp ne i32 %7, 31744
%9 = select i1 %6, i1 true, i1 %8
%10 = and i32 %3, 1023
%11 = icmp eq i32 %10, 0
%12 = select i1 %9, i1 true, i1 %11
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %5, %2
%15 = phi i32 [ 0, %2 ], [ %13, %5 ]
ret i32 %15
}