#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 get_l_offset(int);
void proctal_x86_64_dr_l_set(unsigned long long *dr7, int r, int enable) {
  int offset = get_l_offset(r);
  if (offset == -1) {
    return;
  }
  unsigned int mask = 1u << offset;
  int state = enable ? 1u : 0u;
  state <<= offset;
  *dr7 &= ~(mask);
  *dr7 |= state;
}


x86 assembly (clang, -O0):
<proctal_x86_64_dr_l_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <get_l_offset@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    113c <proctal_x86_64_dr_l_set+0x2c>
jmp    1189 <proctal_x86_64_dr_l_set+0x79>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%rcx
mov    %rcx,(%rax)
movslq -0x1c(%rbp),%rcx
mov    -0x8(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proctal_x86_64_dr_l_set>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <get_l_offset@plt>
cmp    $0xffffffff,%eax
je     113d <proctal_x86_64_dr_l_set+0x2d>
xor    %edx,%edx
test   %ebp,%ebp
setne  %dl
mov    %eax,%ecx
shl    %cl,%edx
mov    (%rbx),%ecx
btr    %eax,%ecx
movslq %edx,%rax
or     %rcx,%rax
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @proctal_x86_64_dr_l_set(i64* %0, i32 %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i64* %0, i64** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = call i32 @get_l_offset(i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %3
br label %36
15: ; preds = %3
%16 = load i32, i32* %7
%17 = shl i32 1, %16
store i32 %17, i32* %8
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 1, i32 0
store i32 %21, i32* %9
%22 = load i32, i32* %7
%23 = load i32, i32* %9
%24 = shl i32 %23, %22
store i32 %24, i32* %9
%25 = load i32, i32* %8
%26 = xor i32 %25, -1
%27 = zext i32 %26 to i64
%28 = load i64*, i64** %4
%29 = load i64, i64* %28
%30 = and i64 %29, %27
store i64 %30, i64* %28
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = load i64*, i64** %4
%34 = load i64, i64* %33
%35 = or i64 %34, %32
store i64 %35, i64* %33
br label %36
36: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
define void @proctal_x86_64_dr_l_set(i64* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 @get_l_offset(i32 %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = shl nuw i32 1, %4
%8 = icmp ne i32 %2, 0
%9 = zext i1 %8 to i32
%10 = shl nuw i32 %9, %4
%11 = xor i32 %7, -1
%12 = zext i32 %11 to i64
%13 = load i64, i64* %0
%14 = and i64 %13, %12
%15 = sext i32 %10 to i64
%16 = or i64 %14, %15
store i64 %16, i64* %0
br label %17
17: ; preds = %3, %6
ret void
}