#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int length;
  int *data;
};
typedef TYPE_1__ ASN1_BIT_STRING;

/* Variables and functions */
int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) {
  int w, v;
  w = n / 8;
  v = 1 << (7 - (n & 0x07));
  if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL))
    return (0);
  return ((a->data[w] & v) != 0);
}


x86 assembly (clang, -O0):
<ASN1_BIT_STRING_get_bit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
and    $0x7,%eax
mov    $0x7,%ecx
sub    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115e <ASN1_BIT_STRING_get_bit+0x5e>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jl     115e <ASN1_BIT_STRING_get_bit+0x5e>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    116a <ASN1_BIT_STRING_get_bit+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    118a <ASN1_BIT_STRING_get_bit+0x8a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    -0x1c(%rbp),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_BIT_STRING_get_bit>:
lea    0x7(%rsi),%ecx
test   %esi,%esi
cmovns %esi,%ecx
xor    %eax,%eax
test   %rdi,%rdi
je     1131 <ASN1_BIT_STRING_get_bit+0x31>
sar    $0x3,%ecx
cmp    %ecx,(%rdi)
jle    1131 <ASN1_BIT_STRING_get_bit+0x31>
mov    0x8(%rdi),%rdx
test   %rdx,%rdx
je     1131 <ASN1_BIT_STRING_get_bit+0x31>
not    %esi
and    $0x7,%esi
movslq %ecx,%rax
mov    (%rdx,%rax,4),%eax
mov    %esi,%ecx
shr    %cl,%eax
and    $0x1,%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32* }
define i32 @ASN1_BIT_STRING_get_bit(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = sdiv i32 %8, 8
store i32 %9, i32* %6
%10 = load i32, i32* %5
%11 = and i32 %10, 7
%12 = sub nsw i32 7, %11
%13 = shl i32 1, %12
store i32 %13, i32* %7
%14 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%15 = icmp eq %struct.TYPE_3__* %14, null
br i1 %15, label %28, label %16
16: ; preds = %2
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
%22 = icmp slt i32 %19, %21
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 1
%26 = load i32*, i32** %25
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23, %16, %2
store i32 0, i32* %3
br label %41
29: ; preds = %23
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 1
%32 = load i32*, i32** %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %7
%38 = and i32 %36, %37
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i32
store i32 %40, i32* %3
br label %41
41: ; preds = %29, %28
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32* }
define i32 @ASN1_BIT_STRING_get_bit(%struct.TYPE_3__* %0, i32 %1) {
%3 = sdiv i32 %1, 8
%4 = and i32 %1, 7
%5 = xor i32 %4, 7
%6 = icmp eq %struct.TYPE_3__* %0, null
br i1 %6, label %21, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = icmp sgt i32 %9, %3
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%13 = load i32*, i32** %12
%14 = icmp eq i32* %13, null
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = sext i32 %3 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
%18 = load i32, i32* %17
%19 = lshr i32 %18, %5
%20 = and i32 %19, 1
br label %21
21: ; preds = %2, %7, %11, %15
%22 = phi i32 [ %20, %15 ], [ 0, %11 ], [ 0, %7 ], [ 0, %2 ]
ret i32 %22
}