#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 */
scalar_t__ encode_char(int /*<<< orphan*/);
unsigned int strlen(char const *);
int /*<<< orphan*/ toupper(char const);
scalar_t__ vrna_alloc(int);
short *aliencode_seq(const char *sequence) {
  unsigned int i, l;
  short *Stemp;
  l = strlen(sequence);
  Stemp = (short *)vrna_alloc(sizeof(short) * (l + 2));
  Stemp[0] = (short)l;
  for (i = 1; i <= l; i++)
    Stemp[i] = (short)encode_char(toupper(sequence[i - 1]));
  return Stemp;
}


x86 assembly (clang, -O0):
<aliencode_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,%eax
shl    $0x1,%rax
mov    %eax,%edi
call   1060 <vrna_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     11c7 <aliencode_seq+0x87>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%edi
call   1050 <encode_char@plt>
mov    %ax,%dx
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dx,(%rax,%rcx,2)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <aliencode_seq+0x43>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aliencode_seq>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    (%r15,%r15,1),%edi
add    $0x4,%edi
call   1060 <vrna_alloc@plt>
mov    %rax,%r12
mov    %r15w,(%rax)
test   %r15d,%r15d
je     1193 <aliencode_seq+0x53>
mov    $0x1,%ebx
lea    -0x1(%rbx),%eax
movsbl (%r14,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%edi
call   1050 <encode_char@plt>
mov    %ebx,%ecx
mov    %ax,(%r12,%rcx,2)
add    $0x1,%ebx
cmp    %r15d,%ebx
jbe    1170 <aliencode_seq+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i16* @aliencode_seq(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = add i32 %8, 2
%10 = zext i32 %9 to i64
%11 = mul i64 2, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @vrna_alloc(i32 %12)
%14 = inttoptr i64 %13 to i16*
store i16* %14, i16** %5
%15 = load i32, i32* %4
%16 = trunc i32 %15 to i16
%17 = load i16*, i16** %5
%18 = getelementptr inbounds i16, i16* %17, i64 0
store i16 %16, i16* %18
store i32 1, i32* %3
br label %19
19: ; preds = %37, %1
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = icmp ule i32 %20, %21
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load i8*, i8** %2
%25 = load i32, i32* %3
%26 = sub i32 %25, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @toupper(i8 signext %29)
%31 = call i64 @encode_char(i32 %30)
%32 = trunc i64 %31 to i16
%33 = load i16*, i16** %5
%34 = load i32, i32* %3
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i16, i16* %33, i64 %35
store i16 %32, i16* %36
br label %37
37: ; preds = %23
%38 = load i32, i32* %3
%39 = add i32 %38, 1
store i32 %39, i32* %3
br label %19
40: ; preds = %19
%41 = load i16*, i16** %5
ret i16* %41
}

LLVM IR (-O2):
define i16* @aliencode_seq(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = shl i32 %2, 1
%4 = add i32 %3, 4
%5 = tail call i64 @vrna_alloc(i32 %4)
%6 = inttoptr i64 %5 to i16*
%7 = trunc i32 %2 to i16
store i16 %7, i16* %6
%8 = icmp eq i32 %2, 0
br i1 %8, label %22, label %9
9: ; preds = %1, %9
%10 = phi i32 [ %20, %9 ], [ 1, %1 ]
%11 = add i32 %10, -1
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @toupper(i8 signext %14)
%16 = tail call i64 @encode_char(i32 %15)
%17 = trunc i64 %16 to i16
%18 = zext i32 %10 to i64
%19 = getelementptr inbounds i16, i16* %6, i64 %18
store i16 %17, i16* %19
%20 = add i32 %10, 1
%21 = icmp ugt i32 %20, %2
br i1 %21, label %22, label %9
22: ; preds = %9, %1
ret i16* %6
}