#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*/ acorn128_enc_onebyte(unsigned char *, unsigned char,
                                        unsigned char *, unsigned char *, int,
                                        int);
void acorn128_initialization(const unsigned char *key, const unsigned char *iv,
                             unsigned char *state) {
  int i, j;
  unsigned char m[293], ks, tem;
  for (j = 0; j <= 292; j++)
    state[j] = 0;
  for (j = 0; j <= 15; j++)
    m[j] = key[j];
  for (j = 16; j <= 31; j++)
    m[j] = iv[j - 16];
  for (j = 32; j <= 223; j++)
    m[j] = key[j & 0xf];
  m[32] ^= 1;
  for (i = 0; i < 224; i++) {
    acorn128_enc_onebyte(state, m[i], &tem, &ks, 0xff, 0xff);
  }
}


x86 assembly (clang, -O0):
<acorn128_initialization>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x124,-0x20(%rbp)
jg     1155 <acorn128_initialization+0x45>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <acorn128_initialization+0x1e>
movl   $0x0,-0x20(%rbp)
cmpl   $0xf,-0x20(%rbp)
jg     118a <acorn128_initialization+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115c <acorn128_initialization+0x4c>
movl   $0x10,-0x20(%rbp)
cmpl   $0x1f,-0x20(%rbp)
jg     11c4 <acorn128_initialization+0xb4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x10,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1191 <acorn128_initialization+0x81>
movl   $0x20,-0x20(%rbp)
cmpl   $0xdf,-0x20(%rbp)
jg     1201 <acorn128_initialization+0xf1>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cb <acorn128_initialization+0xbb>
movzbl -0x130(%rbp),%eax
xor    $0x1,%eax
mov    %al,-0x130(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xe0,-0x1c(%rbp)
jge    125f <acorn128_initialization+0x14f>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
lea    -0x152(%rbp),%rdx
lea    -0x151(%rbp),%rcx
mov    $0xff,%r9d
movzbl -0x150(%rbp,%rax,1),%esi
ff
mov    %r9d,%r8d
call   1030 <acorn128_enc_onebyte@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1218 <acorn128_initialization+0x108>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acorn128_initialization>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x125,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
movups (%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
movups (%r15),%xmm0
movaps %xmm0,0x20(%rsp)
mov    $0x23,%eax
nopl   0x0(%rax)
lea    -0x3(%rax),%ecx
and    $0xc,%ecx
movzbl (%rbx,%rcx,1),%ecx
mov    %cl,0xd(%rsp,%rax,1)
lea    -0x2(%rax),%ecx
and    $0xd,%ecx
movzbl (%rbx,%rcx,1),%ecx
mov    %cl,0xe(%rsp,%rax,1)
lea    -0x1(%rax),%ecx
and    $0xe,%ecx
movzbl (%rbx,%rcx,1),%ecx
mov    %cl,0xf(%rsp,%rax,1)
mov    %eax,%ecx
and    $0xf,%ecx
movzbl (%rbx,%rcx,1),%ecx
mov    %cl,0x10(%rsp,%rax,1)
add    $0x4,%rax
cmp    $0xe3,%rax
jne    1160 <acorn128_initialization+0x40>
xorb   $0x1,0x30(%rsp)
xor    %ebx,%ebx
lea    0xe(%rsp),%r15
lea    0xf(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x10(%rsp,%rbx,1),%esi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xff,%r8d
mov    $0xff,%r9d
call   1040 <acorn128_enc_onebyte@plt>
add    $0x1,%rbx
cmp    $0xe0,%rbx
jne    11c0 <acorn128_initialization+0xa0>
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @acorn128_initialization(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [293 x i8]
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %8
br label %12
12: ; preds = %20, %3
%13 = load i32, i32* %8
%14 = icmp sle i32 %13, 292
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8*, i8** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %15
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %12
23: ; preds = %12
store i32 0, i32* %8
br label %24
24: ; preds = %36, %23
%25 = load i32, i32* %8
%26 = icmp sle i32 %25, 15
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [293 x i8], [293 x i8]* %9, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %27
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %24
39: ; preds = %24
store i32 16, i32* %8
br label %40
40: ; preds = %53, %39
%41 = load i32, i32* %8
%42 = icmp sle i32 %41, 31
br i1 %42, label %43, label %56
43: ; preds = %40
%44 = load i8*, i8** %5
%45 = load i32, i32* %8
%46 = sub nsw i32 %45, 16
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
%49 = load i8, i8* %48
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [293 x i8], [293 x i8]* %9, i64 0, i64 %51
store i8 %49, i8* %52
br label %53
53: ; preds = %43
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %40
56: ; preds = %40
store i32 32, i32* %8
br label %57
57: ; preds = %70, %56
%58 = load i32, i32* %8
%59 = icmp sle i32 %58, 223
br i1 %59, label %60, label %73
60: ; preds = %57
%61 = load i8*, i8** %4
%62 = load i32, i32* %8
%63 = and i32 %62, 15
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
%66 = load i8, i8* %65
%67 = load i32, i32* %8
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [293 x i8], [293 x i8]* %9, i64 0, i64 %68
store i8 %66, i8* %69
br label %70
70: ; preds = %60
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %57
73: ; preds = %57
%74 = getelementptr inbounds [293 x i8], [293 x i8]* %9, i64 0, i64 32
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = xor i32 %76, 1
%78 = trunc i32 %77 to i8
store i8 %78, i8* %74
store i32 0, i32* %7
br label %79
79: ; preds = %89, %73
%80 = load i32, i32* %7
%81 = icmp slt i32 %80, 224
br i1 %81, label %82, label %92
82: ; preds = %79
%83 = load i8*, i8** %6
%84 = load i32, i32* %7
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [293 x i8], [293 x i8]* %9, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = call i32 @acorn128_enc_onebyte(i8* %83, i8 zeroext %87, i8* %11, i8* %10, i32 255, i32 255)
br label %89
89: ; preds = %82
%90 = load i32, i32* %7
%91 = add nsw i32 %90, 1
store i32 %91, i32* %7
br label %79
92: ; preds = %79
ret void
}

LLVM IR (-O2):
define void @acorn128_initialization(i8* nocapture %0, i8* nocapture %1, i8* %2) {
%4 = alloca [293 x i8]
%5 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 0
%6 = alloca i8
%7 = alloca i8
%8 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 16
br label %10
10: ; preds = %10, %3
%11 = phi i64 [ 32, %3 ], [ %31, %10 ]
%12 = and i64 %11, 12
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 %11
store i8 %14, i8* %15
%16 = or i64 %11, 1
%17 = and i64 %16, 13
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 %16
store i8 %19, i8* %20
%21 = or i64 %11, 2
%22 = and i64 %21, 14
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 %21
store i8 %24, i8* %25
%26 = or i64 %11, 3
%27 = and i64 %26, 15
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 %26
store i8 %29, i8* %30
%31 = add nuw nsw i64 %11, 4
%32 = icmp eq i64 %31, 224
br i1 %32, label %33, label %10
33: ; preds = %10
%34 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 32
%35 = load i8, i8* %34
%36 = xor i8 %35, 1
store i8 %36, i8* %34
br label %37
37: ; preds = %33, %37
%38 = phi i64 [ 0, %33 ], [ %42, %37 ]
%39 = getelementptr inbounds [293 x i8], [293 x i8]* %4, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @acorn128_enc_onebyte(i8* %2, i8 zeroext %40, i8* %7, i8* %6, i32 255, i32 255)
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, 224
br i1 %43, label %44, label %37
44: ; preds = %37
ret void
}