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


x86 assembly (clang, -O0):
<acorn128_dec_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    %edx,%eax
mov    -0x40(%rbp),%rdx
mov    %eax,-0x34(%rbp)
mov    %rsi,%rax
mov    -0x34(%rbp),%esi
mov    %rax,-0x30(%rbp)
mov    %rdi,%r8
mov    -0x30(%rbp),%rdi
mov    %r9b,%al
mov    %r8,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %sil,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x21(%rbp)
mov    %al,-0x22(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x0,-0x23(%rbp)
movzbl -0x23(%rbp),%eax
cmp    $0x8,%eax
jge    11e6 <acorn128_dec_onebyte+0xd6>
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 -0x11(%rbp),%eax
movzbl -0x23(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x25(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x25(%rbp),%dl
mov    -0x27(%rbp),%al
lea    -0x24(%rbp),%rsi
lea    -0x26(%rbp),%rcx
movzbl %dl,%edx
movzbl %al,%r8d
movzbl -0x28(%rbp),%r9d
call   1030 <Decrypt_StateUpdate128_1bit@plt>
movzbl -0x24(%rbp),%edx
movzbl -0x23(%rbp),%ecx
shl    %cl,%edx
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x23(%rbp),%al
add    $0x1,%al
mov    %al,-0x23(%rbp)
jmp    1164 <acorn128_dec_onebyte+0x54>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acorn128_dec_onebyte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r13
movb   $0x0,(%rsi)
xor    %ebx,%ebx
nop
mov    %r15d,%r8d
mov    %ebx,%ecx
shr    %cl,%r8d
mov    %r14d,%r9d
shr    %cl,%r9d
mov    %r12d,%edx
shr    %cl,%edx
and    $0x1,%edx
and    $0x1,%r8d
and    $0x1,%r9d
mov    %r13,%rdi
lea    0x6(%rsp),%rsi
lea    0x7(%rsp),%rcx
call   1030 <Decrypt_StateUpdate128_1bit@plt>
movzbl 0x6(%rsp),%eax
mov    %ebx,%ecx
shl    %cl,%eax
or     %al,0x0(%rbp)
add    $0x1,%ebx
cmp    $0x8,%ebx
jne    1130 <acorn128_dec_onebyte+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @acorn128_dec_onebyte(i8* %0, i8* %1, i8 zeroext %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** %8
store i8 0, i8* %19
store i8 0, i8* %13
br label %20
20: ; preds = %61, %6
%21 = load i8, i8* %13
%22 = zext i8 %21 to i32
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %64
24: ; preds = %20
%25 = load i8, i8* %11
%26 = zext i8 %25 to i32
%27 = load i8, i8* %13
%28 = zext i8 %27 to i32
%29 = ashr i32 %26, %28
%30 = and i32 %29, 1
%31 = trunc i32 %30 to i8
store i8 %31, i8* %17
%32 = load i8, i8* %12
%33 = zext i8 %32 to i32
%34 = load i8, i8* %13
%35 = zext i8 %34 to i32
%36 = ashr i32 %33, %35
%37 = and i32 %36, 1
%38 = trunc i32 %37 to i8
store i8 %38, i8* %18
%39 = load i8, i8* %9
%40 = zext i8 %39 to i32
%41 = load i8, i8* %13
%42 = zext i8 %41 to i32
%43 = ashr i32 %40, %42
%44 = and i32 %43, 1
%45 = trunc i32 %44 to i8
store i8 %45, i8* %15
%46 = load i8*, i8** %7
%47 = load i8, i8* %15
%48 = load i8, i8* %17
%49 = load i8, i8* %18
%50 = call i32 @Decrypt_StateUpdate128_1bit(i8* %46, i8* %14, i8 zeroext %47, i8* %16, i8 zeroext %48, i8 zeroext %49)
%51 = load i8, i8* %14
%52 = zext i8 %51 to i32
%53 = load i8, i8* %13
%54 = zext i8 %53 to i32
%55 = shl i32 %52, %54
%56 = load i8*, i8** %8
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = or i32 %58, %55
%60 = trunc i32 %59 to i8
store i8 %60, i8* %56
br label %61
61: ; preds = %24
%62 = load i8, i8* %13
%63 = add i8 %62, 1
store i8 %63, i8* %13
br label %20
64: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @acorn128_dec_onebyte(i8* %0, i8* nocapture %1, i8 zeroext %2, i8* nocapture readnone %3, i8 zeroext %4, i8 zeroext %5) {
%7 = alloca i8
%8 = alloca i8
store i8 0, i8* %1
%9 = zext i8 %4 to i32
%10 = zext i8 %5 to i32
%11 = zext i8 %2 to i32
br label %12
12: ; preds = %6, %12
%13 = phi i32 [ 0, %6 ], [ %30, %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 @Decrypt_StateUpdate128_1bit(i8* %0, i8* %7, i8 zeroext %22, 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* %1
%28 = trunc i32 %26 to i8
%29 = or i8 %27, %28
store i8 %29, i8* %1
%30 = add nuw nsw i32 %13, 1
%31 = icmp eq i32 %30, 8
br i1 %31, label %32, label %12
32: ; preds = %12
ret void
}