#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*/ KeccakF200_StateExtractLanes(void *, unsigned char *, int);
int /*<<< orphan*/ KeccakF200_StateXORBytesInLane(void *, int, unsigned char *,
                                                  int /*<<< orphan*/, int);
int /*<<< orphan*/ KeccakF200_StateXORLanes(void *, unsigned char *, int);
int /*<<< orphan*/ KeccakP200_StatePermute(void *, int);
void Ket_UnwrapBlocks(void *state, const unsigned char *ciphertext,
                      unsigned char *plaintext, unsigned int nBlocks) {
  unsigned char tempBlock[(2 * 1)];
  unsigned char frameAndPaddingBits[1];
  frameAndPaddingBits[0] = 0x08 | 0x07;
  while (nBlocks-- != 0) {
    KeccakF200_StateExtractLanes(state, tempBlock, (2 * 1) / 1);
    tempBlock[0] = *(plaintext++) = *(ciphertext++) ^ tempBlock[0];
    tempBlock[1] = *(plaintext++) = *(ciphertext++) ^ tempBlock[1];
    KeccakF200_StateXORLanes(state, tempBlock, (2 * 1) / 1);
    KeccakF200_StateXORBytesInLane(state, (2 * 1) / 1, frameAndPaddingBits, 0,
                                   1);
    KeccakP200_StatePermute(state, 1);
  }
}


x86 assembly (clang, -O0):
<Ket_UnwrapBlocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movb   $0xf,-0x1f(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1218 <Ket_UnwrapBlocks+0xd8>
mov    -0x8(%rbp),%rdi
lea    -0x1e(%rbp),%rsi
mov    $0x2,%edx
call   1050 <KeccakF200_StateExtractLanes@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
movzbl -0x1e(%rbp),%ecx
xor    %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %al,(%rcx)
mov    %al,-0x1e(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
movzbl -0x1d(%rbp),%ecx
xor    %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %al,(%rcx)
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1e(%rbp),%rsi
mov    $0x2,%edx
call   1040 <KeccakF200_StateXORLanes@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1f(%rbp),%rdx
mov    $0x2,%esi
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <KeccakF200_StateXORBytesInLane@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1060 <KeccakP200_StatePermute@plt>
jmp    115b <Ket_UnwrapBlocks+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ket_UnwrapBlocks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0xf,0x7(%rsp)
test   %ecx,%ecx
je     11e4 <Ket_UnwrapBlocks+0xa4>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %ecx,%ebp
xor    %r13d,%r13d
lea    0x5(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1050 <KeccakF200_StateExtractLanes@plt>
movzbl 0x5(%rsp),%eax
xor    (%r15,%r13,2),%al
mov    %al,(%r14,%r13,2)
mov    %al,0x5(%rsp)
movzbl 0x6(%rsp),%eax
xor    0x1(%r15,%r13,2),%al
mov    %al,0x1(%r14,%r13,2)
mov    %al,0x6(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1040 <KeccakF200_StateXORLanes@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
lea    0x7(%rsp),%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <KeccakF200_StateXORBytesInLane@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <KeccakP200_StatePermute@plt>
add    $0x1,%r13
cmp    %r13d,%ebp
jne    1170 <Ket_UnwrapBlocks+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @Ket_UnwrapBlocks(i8* %0, i8* nocapture %1, i8* nocapture writeonly %2, i32 %3) {
%5 = alloca [2 x i8]
%6 = alloca [1 x i8]
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
store i8 15, i8* %8
%9 = icmp eq i32 %3, 0
br i1 %9, label %32, label %10
10: ; preds = %4
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %3, %10 ], [ %16, %12 ]
%14 = phi i8* [ %2, %10 ], [ %27, %12 ]
%15 = phi i8* [ %1, %10 ], [ %23, %12 ]
%16 = add i32 %13, -1
%17 = call i32 @KeccakF200_StateExtractLanes(i8* %0, i8* %7, i32 2)
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = load i8, i8* %15
%20 = load i8, i8* %7
%21 = xor i8 %20, %19
%22 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %21, i8* %14
store i8 %21, i8* %7
%23 = getelementptr inbounds i8, i8* %15, i64 2
%24 = load i8, i8* %18
%25 = load i8, i8* %11
%26 = xor i8 %25, %24
%27 = getelementptr inbounds i8, i8* %14, i64 2
store i8 %26, i8* %22
store i8 %26, i8* %11
%28 = call i32 @KeccakF200_StateXORLanes(i8* %0, i8* %7, i32 2)
%29 = call i32 @KeccakF200_StateXORBytesInLane(i8* %0, i32 2, i8* %8, i32 0, i32 1)
%30 = call i32 @KeccakP200_StatePermute(i8* %0, i32 1)
%31 = icmp eq i32 %16, 0
br i1 %31, label %32, label %12
32: ; preds = %12, %4
ret void
}