#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 D_GET_TAG(long);
long l_car(long);
long l_equal(long s1, long s2) {
  int d1 = s1 & 0x0fffffffUL;
  int d2 = s2 & 0x0fffffffUL;
  int i;
  if (D_GET_TAG(s1) != D_GET_TAG(s2))
    return (0UL << 28UL);
  switch (D_GET_TAG(s1)) {
  case (4UL << 28UL):
    if (l_equal(l_car(s1), l_car(s1)) == (0UL << 28UL))
      return (0UL << 28UL);
    return l_equal(l_car(s2), l_car(s2));
  default:
    return (s1 == s2) ? (1UL << 28UL) : (0UL << 28UL);
  }
}


x86 assembly (clang, -O0):
<l_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0xfffffff,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
and    $0xfffffff,%rax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <D_GET_TAG@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <D_GET_TAG@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
je     1189 <l_equal+0x59>
movq   $0x0,-0x8(%rbp)
jmp    1220 <l_equal+0xf0>
mov    -0x10(%rbp),%rdi
call   1030 <D_GET_TAG@plt>
sub    $0x40000000,%eax
jne    1206 <l_equal+0xd6>
jmp    11a2 <l_equal+0x72>
mov    -0x10(%rbp),%rdi
call   1040 <l_car@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <l_car@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   1050 <l_equal@plt>
cmp    $0x0,%rax
jne    11db <l_equal+0xab>
movq   $0x0,-0x8(%rbp)
jmp    1220 <l_equal+0xf0>
mov    -0x18(%rbp),%rdi
call   1040 <l_car@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <l_car@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1050 <l_equal@plt>
mov    %rax,-0x8(%rbp)
jmp    1220 <l_equal+0xf0>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    $0x10000000,%ecx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_equal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <D_GET_TAG@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <D_GET_TAG@plt>
xor    %r14d,%r14d
cmp    %eax,%ebp
jne    11ce <l_equal+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <D_GET_TAG@plt>
cmp    $0x40000000,%eax
jne    11c0 <l_equal+0x90>
mov    %rbx,%rdi
call   1040 <l_car@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <l_car@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <l_equal@plt>
test   %rax,%rax
je     11ce <l_equal+0x9e>
mov    %r15,%rdi
call   1040 <l_car@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <l_car@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <D_GET_TAG@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <D_GET_TAG@plt>
cmp    %eax,%ebp
je     1160 <l_equal+0x30>
jmp    11ce <l_equal+0x9e>
xor    %r14d,%r14d
cmp    %r15,%rbx
sete   %r14b
shl    $0x1c,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @l_equal(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
%9 = load i64, i64* %4
%10 = and i64 %9, 268435455
%11 = trunc i64 %10 to i32
store i32 %11, i32* %6
%12 = load i64, i64* %5
%13 = and i64 %12, 268435455
%14 = trunc i64 %13 to i32
store i32 %14, i32* %7
%15 = load i64, i64* %4
%16 = call i32 @D_GET_TAG(i64 %15)
%17 = load i64, i64* %5
%18 = call i32 @D_GET_TAG(i64 %17)
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i64 0, i64* %3
br label %44
21: ; preds = %2
%22 = load i64, i64* %4
%23 = call i32 @D_GET_TAG(i64 %22)
switch i32 %23, label %38 [
i32 1073741824, label %24
]
24: ; preds = %21
%25 = load i64, i64* %4
%26 = call i64 @l_car(i64 %25)
%27 = load i64, i64* %4
%28 = call i64 @l_car(i64 %27)
%29 = call i64 @l_equal(i64 %26, i64 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %24
store i64 0, i64* %3
br label %44
32: ; preds = %24
%33 = load i64, i64* %5
%34 = call i64 @l_car(i64 %33)
%35 = load i64, i64* %5
%36 = call i64 @l_car(i64 %35)
%37 = call i64 @l_equal(i64 %34, i64 %36)
store i64 %37, i64* %3
br label %44
38: ; preds = %21
%39 = load i64, i64* %4
%40 = load i64, i64* %5
%41 = icmp eq i64 %39, %40
%42 = zext i1 %41 to i64
%43 = select i1 %41, i64 268435456, i64 0
store i64 %43, i64* %3
br label %44
44: ; preds = %38, %32, %31, %20
%45 = load i64, i64* %3
ret i64 %45
}

LLVM IR (-O2):
define i64 @l_equal(i64 %0, i64 %1) {
%3 = tail call i32 @D_GET_TAG(i64 %0)
%4 = tail call i32 @D_GET_TAG(i64 %1)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %25
6: ; preds = %2, %16
%7 = phi i64 [ %18, %16 ], [ %1, %2 ]
%8 = phi i64 [ %17, %16 ], [ %0, %2 ]
%9 = tail call i32 @D_GET_TAG(i64 %8)
%10 = icmp eq i32 %9, 1073741824
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = tail call i64 @l_car(i64 %8)
%13 = tail call i64 @l_car(i64 %8)
%14 = tail call i64 @l_equal(i64 %12, i64 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %11
%17 = tail call i64 @l_car(i64 %7)
%18 = tail call i64 @l_car(i64 %7)
%19 = tail call i32 @D_GET_TAG(i64 %17)
%20 = tail call i32 @D_GET_TAG(i64 %18)
%21 = icmp eq i32 %19, %20
br i1 %21, label %6, label %25
22: ; preds = %6
%23 = icmp eq i64 %8, %7
%24 = select i1 %23, i64 268435456, i64 0
br label %25
25: ; preds = %16, %11, %2, %22
%26 = phi i64 [ %24, %22 ], [ 0, %2 ], [ 0, %11 ], [ 0, %16 ]
ret i64 %26
}