#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 asn1_ctx {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ asn1_octet_decode(struct asn1_ctx *, unsigned char *);
int /*<<< orphan*/ asn1_tag_decode(struct asn1_ctx *, unsigned int *);
unsigned char asn1_id_decode(struct asn1_ctx *ctx, unsigned int *cls,
                             unsigned int *con, unsigned int *tag) {
  unsigned char ch;
  if (!asn1_octet_decode(ctx, &ch))
    return 0;
  *cls = (ch & 0xC0) >> 6;
  *con = (ch & 0x20) >> 5;
  *tag = (ch & 0x1F);
  if (*tag == 0x1F) {
    if (!asn1_tag_decode(ctx, tag))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<asn1_id_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x29(%rbp),%rsi
call   1030 <asn1_octet_decode@plt>
cmp    $0x0,%eax
jne    1157 <asn1_id_decode+0x37>
movb   $0x0,-0x1(%rbp)
jmp    11bc <asn1_id_decode+0x9c>
movzbl -0x29(%rbp),%ecx
and    $0xc0,%ecx
sar    $0x6,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movzbl -0x29(%rbp),%ecx
and    $0x20,%ecx
sar    $0x5,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movzbl -0x29(%rbp),%ecx
and    $0x1f,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x1f,(%rax)
jne    11b8 <asn1_id_decode+0x98>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <asn1_tag_decode@plt>
cmp    $0x0,%eax
jne    11b3 <asn1_id_decode+0x93>
movb   $0x0,-0x1(%rbp)
jmp    11bc <asn1_id_decode+0x9c>
jmp    11b8 <asn1_id_decode+0x98>
movb   $0x1,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_id_decode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x7(%rsp),%rsi
call   1030 <asn1_octet_decode@plt>
test   %eax,%eax
je     1178 <asn1_id_decode+0x58>
movzbl 0x7(%rsp),%eax
mov    %eax,%ecx
shr    $0x6,%ecx
mov    %ecx,(%r12)
mov    %eax,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
mov    %ecx,(%r15)
and    $0x1f,%eax
mov    %eax,(%r14)
cmp    $0x1f,%al
jne    1174 <asn1_id_decode+0x54>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <asn1_tag_decode@plt>
test   %eax,%eax
je     1178 <asn1_id_decode+0x58>
mov    $0x1,%al
jmp    117a <asn1_id_decode+0x5a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.asn1_ctx = type { i32 }
define zeroext i8 @asn1_id_decode(%struct.asn1_ctx* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8
%6 = alloca %struct.asn1_ctx*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8
store %struct.asn1_ctx* %0, %struct.asn1_ctx** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%11 = load %struct.asn1_ctx*, %struct.asn1_ctx** %6
%12 = call i32 @asn1_octet_decode(%struct.asn1_ctx* %11, i8* %10)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %4
store i8 0, i8* %5
br label %41
15: ; preds = %4
%16 = load i8, i8* %10
%17 = zext i8 %16 to i32
%18 = and i32 %17, 192
%19 = ashr i32 %18, 6
%20 = load i32*, i32** %7
store i32 %19, i32* %20
%21 = load i8, i8* %10
%22 = zext i8 %21 to i32
%23 = and i32 %22, 32
%24 = ashr i32 %23, 5
%25 = load i32*, i32** %8
store i32 %24, i32* %25
%26 = load i8, i8* %10
%27 = zext i8 %26 to i32
%28 = and i32 %27, 31
%29 = load i32*, i32** %9
store i32 %28, i32* %29
%30 = load i32*, i32** %9
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 31
br i1 %32, label %33, label %40
33: ; preds = %15
%34 = load %struct.asn1_ctx*, %struct.asn1_ctx** %6
%35 = load i32*, i32** %9
%36 = call i32 @asn1_tag_decode(%struct.asn1_ctx* %34, i32* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %33
store i8 0, i8* %5
br label %41
39: ; preds = %33
br label %40
40: ; preds = %39, %15
store i8 1, i8* %5
br label %41
41: ; preds = %40, %38, %14
%42 = load i8, i8* %5
ret i8 %42
}

LLVM IR (-O2):
%struct.asn1_ctx = type { i32 }
define zeroext i8 @asn1_id_decode(%struct.asn1_ctx* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* %3) {
%5 = alloca i8
%6 = call i32 @asn1_octet_decode(%struct.asn1_ctx* %0, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = load i8, i8* %5
%10 = lshr i8 %9, 6
%11 = zext i8 %10 to i32
store i32 %11, i32* %1
%12 = lshr i8 %9, 5
%13 = and i8 %12, 1
%14 = zext i8 %13 to i32
store i32 %14, i32* %2
%15 = and i8 %9, 31
%16 = zext i8 %15 to i32
store i32 %16, i32* %3
%17 = icmp eq i8 %15, 31
br i1 %17, label %18, label %21
18: ; preds = %8
%19 = call i32 @asn1_tag_decode(%struct.asn1_ctx* %0, i32* %3)
%20 = icmp eq i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %18, %8
br label %22
22: ; preds = %18, %4, %21
%23 = phi i8 [ 1, %21 ], [ 0, %4 ], [ 0, %18 ]
ret i8 %23
}