#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 */
unsigned long UNPACKLONG2(unsigned char *);
unsigned char *compress3(unsigned int, unsigned char *);
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, unsigned int);
int /*<<< orphan*/ progerr(char *);
unsigned int uncompress2(unsigned char **);
void remove_worddata_longs(unsigned char *worddata, int *sz_worddata) {
  unsigned char *src, *dst;
  unsigned int metaID, tfrequency, data_len;
  unsigned long nextposmetaID;
  src = worddata;
  tfrequency = uncompress2(&src);
  metaID = uncompress2(&src);
  dst = src;
  while (1) {
    nextposmetaID = UNPACKLONG2(src);
    src += sizeof(long);
    data_len = (int)nextposmetaID - (src - worddata);
    dst = compress3(data_len, dst);
    if (dst > src)
      progerr("Internal error in remove_worddata_longs");
    memmove(dst, src, data_len);
    src += data_len;
    dst += data_len;
    if ((src - worddata) == *sz_worddata)
      break;
    metaID = uncompress2(&src);
    dst = compress3(metaID, dst);
  }
  *sz_worddata = dst - worddata;
}


x86 assembly (clang, -O0):
<remove_worddata_longs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <uncompress2@plt>
mov    %eax,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <uncompress2@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <UNPACKLONG2@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
cltq
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <compress3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11e2 <remove_worddata_longs+0x92>
lea    0xe23(%rip),%rdi
call   1040 <progerr@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1060 <memmove@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jne    1232 <remove_worddata_longs+0xe2>
jmp    1253 <remove_worddata_longs+0x103>
lea    -0x18(%rbp),%rdi
call   1050 <uncompress2@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <compress3@plt>
mov    %rax,-0x20(%rbp)
jmp    1188 <remove_worddata_longs+0x38>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_worddata_longs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
mov    %rdi,(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
call   1050 <uncompress2@plt>
mov    %r15,%rdi
call   1050 <uncompress2@plt>
mov    (%rsp),%rdi
lea    0xe7d(%rip),%r12
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
call   1070 <UNPACKLONG2@plt>
mov    (%rsp),%rcx
add    $0x8,%rcx
mov    %rcx,(%rsp)
mov    %r13,%rbp
sub    %rcx,%rbp
add    %rax,%rbp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <compress3@plt>
mov    %rax,%rbx
mov    (%rsp),%rsi
cmp    %rsi,%rax
jbe    11cc <remove_worddata_longs+0x7c>
mov    %r12,%rdi
call   1040 <progerr@plt>
mov    (%rsp),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1060 <memmove@plt>
mov    %ebp,%eax
add    %rax,%rbx
add    (%rsp),%rax
mov    %rax,(%rsp)
sub    %r13,%rax
movslq (%r14),%rcx
cmp    %rcx,%rax
je     1209 <remove_worddata_longs+0xb9>
mov    %r15,%rdi
call   1050 <uncompress2@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <compress3@plt>
mov    %rax,%rbx
mov    (%rsp),%rdi
jmp    1190 <remove_worddata_longs+0x40>
sub    %r13d,%ebx
mov    %ebx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Internal error in remove_worddata_longs\00"
define void @remove_worddata_longs(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
store i8* %0, i8** %3
store i32* %1, i32** %4
%11 = load i8*, i8** %3
store i8* %11, i8** %5
%12 = call i32 @uncompress2(i8** %5)
store i32 %12, i32* %8
%13 = call i32 @uncompress2(i8** %5)
store i32 %13, i32* %7
%14 = load i8*, i8** %5
store i8* %14, i8** %6
br label %15
15: ; preds = %2, %61
%16 = load i8*, i8** %5
%17 = call i64 @UNPACKLONG2(i8* %16)
store i64 %17, i64* %10
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 8
store i8* %19, i8** %5
%20 = load i64, i64* %10
%21 = trunc i64 %20 to i32
%22 = sext i32 %21 to i64
%23 = load i8*, i8** %5
%24 = load i8*, i8** %3
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
%28 = sub nsw i64 %22, %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = load i8*, i8** %6
%32 = call i8* @compress3(i32 %30, i8* %31)
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = load i8*, i8** %5
%35 = icmp ugt i8* %33, %34
br i1 %35, label %36, label %38
36: ; preds = %15
%37 = call i32 @progerr(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %38
38: ; preds = %36, %15
%39 = load i8*, i8** %6
%40 = load i8*, i8** %5
%41 = load i32, i32* %9
%42 = call i32 @memmove(i8* %39, i8* %40, i32 %41)
%43 = load i32, i32* %9
%44 = load i8*, i8** %5
%45 = zext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %5
%47 = load i32, i32* %9
%48 = load i8*, i8** %6
%49 = zext i32 %47 to i64
%50 = getelementptr inbounds i8, i8* %48, i64 %49
store i8* %50, i8** %6
%51 = load i8*, i8** %5
%52 = load i8*, i8** %3
%53 = ptrtoint i8* %51 to i64
%54 = ptrtoint i8* %52 to i64
%55 = sub i64 %53, %54
%56 = load i32*, i32** %4
%57 = load i32, i32* %56
%58 = sext i32 %57 to i64
%59 = icmp eq i64 %55, %58
br i1 %59, label %60, label %61
60: ; preds = %38
br label %66
61: ; preds = %38
%62 = call i32 @uncompress2(i8** %5)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = load i8*, i8** %6
%65 = call i8* @compress3(i32 %63, i8* %64)
store i8* %65, i8** %6
br label %15
66: ; preds = %60
%67 = load i8*, i8** %6
%68 = load i8*, i8** %3
%69 = ptrtoint i8* %67 to i64
%70 = ptrtoint i8* %68 to i64
%71 = sub i64 %69, %70
%72 = trunc i64 %71 to i32
%73 = load i32*, i32** %4
store i32 %72, i32* %73
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Internal error in remove_worddata_longs\00"
define void @remove_worddata_longs(i8* %0, i32* nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
%5 = call i32 @uncompress2(i8** %3)
%6 = call i32 @uncompress2(i8** %3)
%7 = load i8*, i8** %3
%8 = ptrtoint i8* %0 to i64
br label %9
9: ; preds = %37, %2
%10 = phi i8* [ %7, %2 ], [ %40, %37 ]
%11 = phi i8* [ %7, %2 ], [ %39, %37 ]
%12 = call i64 @UNPACKLONG2(i8* %10)
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 8
store i8* %14, i8** %3
%15 = ptrtoint i8* %14 to i64
%16 = sub i64 %8, %15
%17 = add i64 %16, %12
%18 = trunc i64 %17 to i32
%19 = call i8* @compress3(i32 %18, i8* %11)
%20 = load i8*, i8** %3
%21 = icmp ugt i8* %19, %20
br i1 %21, label %22, label %25
22: ; preds = %9
%23 = call i32 @progerr(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %3
br label %25
25: ; preds = %22, %9
%26 = phi i8* [ %24, %22 ], [ %20, %9 ]
%27 = call i32 @memmove(i8* %19, i8* %26, i32 %18)
%28 = load i8*, i8** %3
%29 = and i64 %17, 4294967295
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %3
%31 = getelementptr inbounds i8, i8* %19, i64 %29
%32 = ptrtoint i8* %30 to i64
%33 = sub i64 %32, %8
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp eq i64 %33, %35
br i1 %36, label %41, label %37
37: ; preds = %25
%38 = call i32 @uncompress2(i8** %3)
%39 = call i8* @compress3(i32 %38, i8* %31)
%40 = load i8*, i8** %3
br label %9
41: ; preds = %25
%42 = ptrtoint i8* %31 to i64
%43 = sub i64 %42, %8
%44 = trunc i64 %43 to i32
store i32 %44, i32* %1
ret void
}