#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_tag_generation_32bits_version(unsigned long long msglen,
                                            unsigned long long adlen,
                                            unsigned char maclen,
                                            unsigned char *mac,
                                            unsigned long long *state) {
  int i;
  unsigned int plaintextword = 0;
  unsigned int ciphertextword = 0;
  unsigned int ksword = 0;
  for (i = 0; i < 768 / 32; i++) {
    encrypt_32bits(state, plaintextword, &ciphertextword, &ksword, 0xffffffff,
                   0xffffffff);
    if (i >= (768 / 32 - 4)) {
      ((unsigned int *)mac)[i - (768 / 32 - 4)] = ksword;
    }
  }
}


x86 assembly (clang, -O0):
<acorn128_tag_generation_32bits_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x18,-0x2c(%rbp)
jge    11a0 <acorn128_tag_generation_32bits_version+0x90>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1030 <encrypt_32bits@plt>
cmpl   $0x14,-0x2c(%rbp)
jl     118d <acorn128_tag_generation_32bits_version+0x7d>
mov    -0x38(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x14,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1192 <acorn128_tag_generation_32bits_version+0x82>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1149 <acorn128_tag_generation_32bits_version+0x39>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acorn128_tag_generation_32bits_version>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r13
mov    %rcx,%r14
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xor    %ebx,%ebx
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
jmp    115a <acorn128_tag_generation_32bits_version+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x18,%rbx
je     1189 <acorn128_tag_generation_32bits_version+0x79>
mov    %r13,%rdi
xor    %esi,%esi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <encrypt_32bits@plt>
cmp    $0x14,%rbx
jb     1150 <acorn128_tag_generation_32bits_version+0x40>
mov    0x8(%rsp),%eax
lea    -0x14(%rbx),%ecx
mov    %eax,(%r14,%rcx,4)
jmp    1150 <acorn128_tag_generation_32bits_version+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @acorn128_tag_generation_32bits_version(i64 %0, i64 %1, i8 zeroext %2, i8* %3, i64* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i64*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i64 %0, i64* %6
store i64 %1, i64* %7
store i8 %2, i8* %8
store i8* %3, i8** %9
store i64* %4, i64** %10
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %11
br label %15
15: ; preds = %33, %5
%16 = load i32, i32* %11
%17 = icmp slt i32 %16, 24
br i1 %17, label %18, label %36
18: ; preds = %15
%19 = load i64*, i64** %10
%20 = load i32, i32* %12
%21 = call i32 @encrypt_32bits(i64* %19, i32 %20, i32* %13, i32* %14, i32 -1, i32 -1)
%22 = load i32, i32* %11
%23 = icmp sge i32 %22, 20
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = load i32, i32* %14
%26 = load i8*, i8** %9
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %11
%29 = sub nsw i32 %28, 20
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %27, i64 %30
store i32 %25, i32* %31
br label %32
32: ; preds = %24, %18
br label %33
33: ; preds = %32
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
br label %15
36: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @acorn128_tag_generation_32bits_version(i64 %0, i64 %1, i8 zeroext %2, i8* nocapture writeonly %3, i64* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%10 = bitcast i8* %3 to i32*
br label %11
11: ; preds = %5, %20
%12 = phi i64 [ 0, %5 ], [ %21, %20 ]
%13 = call i32 @encrypt_32bits(i64* %4, i32 0, i32* %6, i32* %7, i32 -1, i32 -1)
%14 = icmp ugt i64 %12, 19
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %7
%17 = add nuw i64 %12, 4294967276
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds i32, i32* %10, i64 %18
store i32 %16, i32* %19
br label %20
20: ; preds = %11, %15
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, 24
br i1 %22, label %23, label %11
23: ; preds = %20
ret void
}