#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*/ encrypt_32bits(unsigned long long *, unsigned int,
                                  unsigned int *, unsigned int *, int, int);
void acorn128_initialization_32bitversion(const unsigned char *key,
                                          const unsigned char *iv,
                                          unsigned long long *state) {
  int i, j;
  unsigned int m;
  unsigned int ks = 0, tem = 0;
  for (j = 0; j <= 6; j++)
    state[j] = 0;
  for (j = 0; j <= 3; j++) {
    encrypt_32bits(state, ((unsigned int *)key)[j], &tem, &ks, 0xffffffff,
                   0xffffffff);
  }
  for (j = 4; j <= 7; j++) {
    encrypt_32bits(state, ((unsigned int *)iv)[j - 4], &tem, &ks, 0xffffffff,
                   0xffffffff);
  }
  for (j = 8; j <= 8; j++) {
    encrypt_32bits(state, ((unsigned int *)key)[j & 3] ^ 1, &tem, &ks,
                   0xffffffff, 0xffffffff);
  }
  for (j = 9; j <= 55; j++) {
    encrypt_32bits(state, ((unsigned int *)key)[j & 3], &tem, &ks, 0xffffffff,
                   0xffffffff);
  }
}


x86 assembly (clang, -O0):
<acorn128_initialization_32bitversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x6,-0x20(%rbp)
jg     1161 <acorn128_initialization_32bitversion+0x51>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1139 <acorn128_initialization_32bitversion+0x29>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jg     11a5 <acorn128_initialization_32bitversion+0x95>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1030 <encrypt_32bits@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1168 <acorn128_initialization_32bitversion+0x58>
movl   $0x4,-0x20(%rbp)
cmpl   $0x7,-0x20(%rbp)
jg     11ee <acorn128_initialization_32bitversion+0xde>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1030 <encrypt_32bits@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <acorn128_initialization_32bitversion+0x9c>
movl   $0x8,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jg     123a <acorn128_initialization_32bitversion+0x12a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
xor    $0x1,%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1030 <encrypt_32bits@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11f5 <acorn128_initialization_32bitversion+0xe5>
movl   $0x9,-0x20(%rbp)
cmpl   $0x37,-0x20(%rbp)
jg     1283 <acorn128_initialization_32bitversion+0x173>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1030 <encrypt_32bits@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1241 <acorn128_initialization_32bitversion+0x131>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acorn128_initialization_32bitversion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rdx)
movups %xmm0,0x10(%rdx)
movups %xmm0,(%rdx)
movq   $0x0,0x30(%rdx)
mov    (%rdi),%esi
mov    %rsp,%r15
lea    0x4(%rsp),%r12
mov    %rdx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0x4(%r14),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0x8(%r14),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0xc(%r14),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0x4(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0x8(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    0xc(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    (%r14),%esi
xor    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
mov    $0x9,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
and    $0x3,%eax
mov    (%r14,%rax,4),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
add    $0x1,%ebp
cmp    $0x38,%ebp
jne    1270 <acorn128_initialization_32bitversion+0x160>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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