#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*/ encshare2(unsigned int *, unsigned int *, int);
void encshare1(unsigned int *tbuff, unsigned char *datap, int len) {
  unsigned char *p, *s;
  p = s = (unsigned char *)(tbuff + 309);
  encshare2(tbuff, (unsigned int *)p, 16);
  while (len--) {
    if ((p - s) == 63) {
      p = s;
      encshare2(tbuff, (unsigned int *)p, 16);
    }
    *datap ^= *p;
    datap++;
    p++;
  }
}


x86 assembly (clang, -O0):
<encshare1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4d4,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <encshare2@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11b9 <encshare1+0xa9>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x3f,%rax
jne    118a <encshare1+0x7a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <encshare2@plt>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edx
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
xor    %edx,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <encshare1+0x37>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encshare1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x4d4(%rdi),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1030 <encshare2@plt>
test   %ebp,%ebp
je     1185 <encshare1+0x75>
mov    %ebp,%r12d
xor    %ebp,%ebp
mov    %rbx,%rax
jmp    1164 <encshare1+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rax),%ecx
xor    %cl,(%r15,%rbp,1)
add    $0x1,%rax
add    $0x1,%rbp
cmp    %ebp,%r12d
je     1185 <encshare1+0x75>
mov    %rax,%rcx
sub    %rbx,%rcx
cmp    $0x3f,%rcx
jne    1150 <encshare1+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1030 <encshare2@plt>
mov    %rbx,%rax
jmp    1150 <encshare1+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @encshare1(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 309
%11 = bitcast i32* %10 to i8*
store i8* %11, i8** %8
store i8* %11, i8** %7
%12 = load i32*, i32** %4
%13 = load i8*, i8** %7
%14 = bitcast i8* %13 to i32*
%15 = call i32 @encshare2(i32* %12, i32* %14, i32 16)
br label %16
16: ; preds = %33, %3
%17 = load i32, i32* %6
%18 = add nsw i32 %17, -1
store i32 %18, i32* %6
%19 = icmp ne i32 %17, 0
br i1 %19, label %20, label %46
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = icmp eq i64 %25, 63
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i8*, i8** %8
store i8* %28, i8** %7
%29 = load i32*, i32** %4
%30 = load i8*, i8** %7
%31 = bitcast i8* %30 to i32*
%32 = call i32 @encshare2(i32* %29, i32* %31, i32 16)
br label %33
33: ; preds = %27, %20
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = load i8*, i8** %5
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = xor i32 %39, %36
%41 = trunc i32 %40 to i8
store i8 %41, i8* %37
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %7
br label %16
46: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @encshare1(i32* %0, i8* nocapture %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 309
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 @encshare2(i32* %0, i32* %4, i32 16)
%7 = icmp eq i32 %2, 0
br i1 %7, label %28, label %8
8: ; preds = %3
%9 = ptrtoint i32* %4 to i64
br label %10
10: ; preds = %8, %20
%11 = phi i32 [ %2, %8 ], [ %14, %20 ]
%12 = phi i8* [ %1, %8 ], [ %25, %20 ]
%13 = phi i8* [ %5, %8 ], [ %26, %20 ]
%14 = add nsw i32 %11, -1
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %15, %9
%17 = icmp eq i64 %16, 63
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = tail call i32 @encshare2(i32* %0, i32* %4, i32 16)
br label %20
20: ; preds = %18, %10
%21 = phi i8* [ %5, %18 ], [ %13, %10 ]
%22 = load i8, i8* %21
%23 = load i8, i8* %12
%24 = xor i8 %23, %22
store i8 %24, i8* %12
%25 = getelementptr inbounds i8, i8* %12, i64 1
%26 = getelementptr inbounds i8, i8* %21, i64 1
%27 = icmp eq i32 %14, 0
br i1 %27, label %28, label %10
28: ; preds = %20, %3
ret void
}