#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_1bit(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, t[4];
  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_1bit(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,-0x30(%rbp)
mov    %rdi,%r8
mov    -0x30(%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,-0x2a(%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,-0x2b(%rbp)
movzbl -0x22(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x2c(%rbp)
movzbl -0x9(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%sil
mov    -0x2b(%rbp),%al
lea    -0x29(%rbp),%rdx
lea    -0x2a(%rbp),%rcx
movzbl %sil,%esi
movzbl %al,%r8d
movzbl -0x2c(%rbp),%r9d
call   1030 <Encrypt_StateUpdate128_1bit@plt>
movzbl -0x29(%rbp),%edx
movzbl -0x23(%rbp),%ecx
shl    %cl,%edx
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
movzbl -0x2a(%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_1bit@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 [4 x i8]
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = 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
%20 = load i8*, i8** %9
store i8 0, i8* %20
store i8 0, i8* %17
%21 = load i8*, i8** %10
store i8 0, i8* %21
store i8 0, i8* %13
br label %22
22: ; preds = %73, %6
%23 = load i8, i8* %13
%24 = zext i8 %23 to i32
%25 = icmp slt i32 %24, 8
br i1 %25, label %26, label %76
26: ; preds = %22
%27 = load i8, i8* %11
%28 = zext i8 %27 to i32
%29 = load i8, i8* %13
%30 = zext i8 %29 to i32
%31 = ashr i32 %28, %30
%32 = and i32 %31, 1
%33 = trunc i32 %32 to i8
store i8 %33, i8* %18
%34 = load i8, i8* %12
%35 = zext i8 %34 to i32
%36 = load i8, i8* %13
%37 = zext i8 %36 to i32
%38 = ashr i32 %35, %37
%39 = and i32 %38, 1
%40 = trunc i32 %39 to i8
store i8 %40, i8* %19
%41 = load i8, i8* %8
%42 = zext i8 %41 to i32
%43 = load i8, i8* %13
%44 = zext i8 %43 to i32
%45 = ashr i32 %42, %44
%46 = and i32 %45, 1
%47 = trunc i32 %46 to i8
store i8 %47, i8* %15
%48 = load i8*, i8** %7
%49 = load i8, i8* %15
%50 = load i8, i8* %18
%51 = load i8, i8* %19
%52 = call i32 @Encrypt_StateUpdate128_1bit(i8* %48, i8 zeroext %49, i8* %16, i8* %17, i8 zeroext %50, i8 zeroext %51)
%53 = load i8, i8* %16
%54 = zext i8 %53 to i32
%55 = load i8, i8* %13
%56 = zext i8 %55 to i32
%57 = shl i32 %54, %56
%58 = load i8*, i8** %9
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = or i32 %60, %57
%62 = trunc i32 %61 to i8
store i8 %62, i8* %58
%63 = load i8, i8* %17
%64 = zext i8 %63 to i32
%65 = load i8, i8* %13
%66 = zext i8 %65 to i32
%67 = shl i32 %64, %66
%68 = load i8*, i8** %10
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = or i32 %70, %67
%72 = trunc i32 %71 to i8
store i8 %72, i8* %68
br label %73
73: ; preds = %26
%74 = load i8, i8* %13
%75 = add i8 %74, 1
store i8 %75, i8* %13
br label %22
76: ; preds = %22
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_1bit(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
}