#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 /*<<< orphan*/ cdAppShort(unsigned char *, short);
int /*<<< orphan*/ cdcomhead(unsigned char *, int, int, int);
int cdcomheadlong(unsigned char *es, int elemclass, int id, int len) {
  if (!cdcomhead(es, elemclass, id, 31))
    return 0;
  es += 2;
  cdAppShort(es, (short int)len);
  *es = *es & 0177;
  es += 2;
  return 1;
}


x86 assembly (clang, -O0):
<cdcomheadlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1f,%ecx
call   1030 <cdcomhead@plt>
cmp    $0x0,%eax
jne    115e <cdcomheadlong+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    119e <cdcomheadlong+0x7e>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
movswl %ax,%esi
call   1040 <cdAppShort@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0x7f,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdcomheadlong>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdi,%rbx
mov    $0x1f,%ecx
call   1030 <cdcomhead@plt>
test   %eax,%eax
je     114d <cdcomheadlong+0x2d>
lea    0x2(%rbx),%rdi
movswl %bp,%esi
call   1040 <cdAppShort@plt>
andb   $0x7f,0x2(%rbx)
mov    $0x1,%eax
jmp    114f <cdcomheadlong+0x2f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cdcomheadlong(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = call i32 @cdcomhead(i8* %10, i32 %11, i32 %12, i32 31)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %4
store i32 0, i32* %5
br label %31
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 2
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = load i32, i32* %9
%21 = trunc i32 %20 to i16
%22 = call i32 @cdAppShort(i8* %19, i16 signext %21)
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = and i32 %25, 127
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %6
store i8 %27, i8* %28
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8* %30, i8** %6
store i32 1, i32* %5
br label %31
31: ; preds = %16, %15
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @cdcomheadlong(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @cdcomhead(i8* %0, i32 %1, i32 %2, i32 31)
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = trunc i32 %3 to i16
%10 = tail call i32 @cdAppShort(i8* %8, i16 signext %9)
%11 = load i8, i8* %8
%12 = and i8 %11, 127
store i8 %12, i8* %8
br label %13
13: ; preds = %4, %7
%14 = phi i32 [ 1, %7 ], [ 0, %4 ]
ret i32 %14
}