#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_StateUpdate128(unsigned char *, unsigned char,
                                          unsigned char *, unsigned char *,
                                          unsigned char, unsigned char);
void acorn128_enc_onebyte(unsigned char *state, unsigned char plaintextbyte,
                          unsigned char *ciphertextbyte, unsigned char *ksbyte,
                          unsigned char cabyte, unsigned char cbbyte) {
  unsigned char i;
  unsigned char plaintextbit, ciphertextbit, kstem, ca, cb;
  *ciphertextbyte = 0;
  kstem = 0;
  *ksbyte = 0;
  for (i = 0; i < 8; i++) {
    ca = (cabyte >> i) & 1;
    cb = (cbbyte >> i) & 1;
    plaintextbit = (plaintextbyte >> i) & 1;
    Encrypt_StateUpdate128(state, plaintextbit, &ciphertextbit, &kstem, ca, cb);
    *ciphertextbyte |= (ciphertextbit << i);
    *ksbyte |= (kstem << i);
  }
}


x86 assembly (clang, -O0):
<acorn128_enc_onebyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r8d,-0x44(%rbp)
mov    %rcx,%rax
mov    -0x44(%rbp),%ecx
mov    %rax,-0x40(%rbp)
mov    %rdx,%rax
mov    -0x40(%rbp),%rdx
mov    %rax,-0x38(%rbp)
mov    %esi,%eax
mov    -0x38(%rbp),%rsi
mov    %eax,-0x2c(%rbp)
mov    %rdi,%r8
mov    -0x2c(%rbp),%edi
mov    %r9b,%al
mov    %r8,-0x8(%rbp)
mov    %dil,-0x9(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x21(%rbp)
mov    %al,-0x22(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x0,-0x26(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x0,-0x23(%rbp)
movzbl -0x23(%rbp),%eax
cmp    $0x8,%eax
jge    1208 <acorn128_enc_onebyte+0xf8>
movzbl -0x21(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x27(%rbp)
movzbl -0x22(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x28(%rbp)
movzbl -0x9(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%sil
mov    -0x27(%rbp),%al
lea    -0x25(%rbp),%rdx
lea    -0x26(%rbp),%rcx
movzbl %sil,%esi
movzbl %al,%r8d
movzbl -0x28(%rbp),%r9d
call   1030 <Encrypt_StateUpdate128@plt>
movzbl -0x25(%rbp),%edx
movzbl -0x23(%rbp),%ecx
shl    %cl,%edx
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
movzbl -0x26(%rbp),%edx
movzbl -0x23(%rbp),%ecx
shl    %cl,%edx
mov    -0x20(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x23(%rbp),%al
add    $0x1,%al
mov    %al,-0x23(%rbp)
jmp    116f <acorn128_enc_onebyte+0x5f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acorn128_enc_onebyte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,%r15d
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %esi,%r12d
mov    %rdi,%rbx
movb   $0x0,(%rdx)
movb   $0x0,0x2(%rsp)
movb   $0x0,(%rcx)
xor    %r14d,%r14d
nopl   (%rax)
mov    %r15d,%r8d
mov    %r14d,%ecx
shr    %cl,%r8d
mov    0x4(%rsp),%r9d
shr    %cl,%r9d
mov    %r12d,%esi
shr    %cl,%esi
and    $0x1,%esi
and    $0x1,%r8d
and    $0x1,%r9d
mov    %rbx,%rdi
lea    0x3(%rsp),%rdx
lea    0x2(%rsp),%rcx
call   1030 <Encrypt_StateUpdate128@plt>
movzbl 0x3(%rsp),%eax
mov    %r14d,%ecx
shl    %cl,%eax
or     %al,0x0(%rbp)
movzbl 0x2(%rsp),%eax
shl    %cl,%eax
or     %al,0x0(%r13)
add    $0x1,%r14d
cmp    $0x8,%r14d
jne    1140 <acorn128_enc_onebyte+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @acorn128_enc_onebyte(i8* %0, i8 zeroext %1, i8* %2, i8* %3, i8 zeroext %4, i8 zeroext %5) {
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
store i8* %0, i8** %7
store i8 %1, i8* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8 %4, i8* %11
store i8 %5, i8* %12
%19 = load i8*, i8** %9
store i8 0, i8* %19
store i8 0, i8* %16
%20 = load i8*, i8** %10
store i8 0, i8* %20
store i8 0, i8* %13
br label %21
21: ; preds = %72, %6
%22 = load i8, i8* %13
%23 = zext i8 %22 to i32
%24 = icmp slt i32 %23, 8
br i1 %24, label %25, label %75
25: ; preds = %21
%26 = load i8, i8* %11
%27 = zext i8 %26 to i32
%28 = load i8, i8* %13
%29 = zext i8 %28 to i32
%30 = ashr i32 %27, %29
%31 = and i32 %30, 1
%32 = trunc i32 %31 to i8
store i8 %32, i8* %17
%33 = load i8, i8* %12
%34 = zext i8 %33 to i32
%35 = load i8, i8* %13
%36 = zext i8 %35 to i32
%37 = ashr i32 %34, %36
%38 = and i32 %37, 1
%39 = trunc i32 %38 to i8
store i8 %39, i8* %18
%40 = load i8, i8* %8
%41 = zext i8 %40 to i32
%42 = load i8, i8* %13
%43 = zext i8 %42 to i32
%44 = ashr i32 %41, %43
%45 = and i32 %44, 1
%46 = trunc i32 %45 to i8
store i8 %46, i8* %14
%47 = load i8*, i8** %7
%48 = load i8, i8* %14
%49 = load i8, i8* %17
%50 = load i8, i8* %18
%51 = call i32 @Encrypt_StateUpdate128(i8* %47, i8 zeroext %48, i8* %15, i8* %16, i8 zeroext %49, i8 zeroext %50)
%52 = load i8, i8* %15
%53 = zext i8 %52 to i32
%54 = load i8, i8* %13
%55 = zext i8 %54 to i32
%56 = shl i32 %53, %55
%57 = load i8*, i8** %9
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = or i32 %59, %56
%61 = trunc i32 %60 to i8
store i8 %61, i8* %57
%62 = load i8, i8* %16
%63 = zext i8 %62 to i32
%64 = load i8, i8* %13
%65 = zext i8 %64 to i32
%66 = shl i32 %63, %65
%67 = load i8*, i8** %10
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = or i32 %69, %66
%71 = trunc i32 %70 to i8
store i8 %71, i8* %67
br label %72
72: ; preds = %25
%73 = load i8, i8* %13
%74 = add i8 %73, 1
store i8 %74, i8* %13
br label %21
75: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @acorn128_enc_onebyte(i8* %0, i8 zeroext %1, i8* nocapture %2, i8* nocapture %3, i8 zeroext %4, i8 zeroext %5) {
%7 = alloca i8
%8 = alloca i8
store i8 0, i8* %2
store i8 0, i8* %8
store i8 0, i8* %3
%9 = zext i8 %4 to i32
%10 = zext i8 %5 to i32
%11 = zext i8 %1 to i32
br label %12
12: ; preds = %6, %12
%13 = phi i32 [ 0, %6 ], [ %36, %12 ]
%14 = lshr i32 %9, %13
%15 = trunc i32 %14 to i8
%16 = and i8 %15, 1
%17 = lshr i32 %10, %13
%18 = trunc i32 %17 to i8
%19 = and i8 %18, 1
%20 = lshr i32 %11, %13
%21 = trunc i32 %20 to i8
%22 = and i8 %21, 1
%23 = call i32 @Encrypt_StateUpdate128(i8* %0, i8 zeroext %22, i8* %7, i8* %8, i8 zeroext %16, i8 zeroext %19)
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = shl i32 %25, %13
%27 = load i8, i8* %2
%28 = trunc i32 %26 to i8
%29 = or i8 %27, %28
store i8 %29, i8* %2
%30 = load i8, i8* %8
%31 = zext i8 %30 to i32
%32 = shl i32 %31, %13
%33 = load i8, i8* %3
%34 = trunc i32 %32 to i8
%35 = or i8 %33, %34
store i8 %35, i8* %3
%36 = add nuw nsw i32 %13, 1
%37 = icmp eq i32 %36, 8
br i1 %37, label %38, label %12
38: ; preds = %12
ret void
}