#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*/ SHA256_sodium(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ check_KAT(unsigned char *, unsigned char *, int, char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
SHA256_sodium_KAT_7() {
  unsigned char *input = malloc(sizeof(char) * 1073741824);
  char to_repeat[] =
      "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno";
  int i;
  for (i = 0; i < 16777216; i++) {
    memcpy(input + i * 64, to_repeat, 64);
  }
  unsigned char result[32];
  unsigned char expected_result[32] = {
      0x50, 0xe7, 0x2a, 0x0e, 0x26, 0x44, 0x2f, 0xe2, 0x55, 0x2d, 0xc3,
      0x93, 0x8a, 0xc5, 0x86, 0x58, 0x22, 0x8c, 0x0c, 0xbf, 0xb1, 0xd2,
      0xca, 0x87, 0x2a, 0xe4, 0x35, 0x26, 0x6f, 0xcd, 0x05, 0x5e};
  SHA256_sodium(input, result, 1073741824);
  check_KAT(result, expected_result, 32, "SHA256_sodium_KAT_7");
}


x86 assembly (clang, -O0):
<SHA256_sodium_KAT_7>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    $0x40000000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x41,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x1000000,-0x64(%rbp)
jge    11ad <SHA256_sodium_KAT_7+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%eax
shl    $0x6,%eax
cltq
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1175 <SHA256_sodium_KAT_7+0x35>
mov    0xe9c(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x40000000,%edx
call   1050 <SHA256_sodium@plt>
lea    -0x90(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x20,%edx
lea    0xe5c(%rip),%rcx
call   1060 <check_KAT@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHA256_sodium_KAT_7>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    $0x40000000,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x60(%rsp)
xor    %ebx,%ebx
lea    0x20(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r15,%rbx,1),%rdi
mov    %r14,%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
add    $0x40,%rbx
cmp    $0x40000000,%rbx
jne    11a0 <SHA256_sodium_KAT_7+0x60>
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x70(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x40000000,%edx
call   1050 <SHA256_sodium@plt>
lea    0xe7f(%rip),%rcx
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x20,%edx
call   1060 <check_KAT@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.SHA256_sodium_KAT_7.to_repeat = [65 x i8] c"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno\00"
@__const.SHA256_sodium_KAT_7.expected_result = [32 x i8] c"P\E7*\0E&D/\E2U-\C3\93\8A\C5\86X\22\8C\0C\BF\B1\D2\CA\87*\E45&o\CD\05^"
@.str = [20 x i8] c"SHA256_sodium_KAT_7\00"
define i32 @SHA256_sodium_KAT_7() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [65 x i8]
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = call i8* @malloc(i32 1073741824)
store i8* %7, i8** %2
%8 = bitcast [65 x i8]* %3 to i8*
store i32 0, i32* %4
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 16777216
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = load i32, i32* %4
%15 = mul nsw i32 %14, 64
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 64)
br label %20
20: ; preds = %12
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %9
23: ; preds = %9
%24 = bitcast [32 x i8]* %6 to i8*
%25 = load i8*, i8** %2
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%27 = call i32 @SHA256_sodium(i8* %25, i8* %26, i32 1073741824)
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%30 = call i32 @check_KAT(i8* %28, i8* %29, i32 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@__const.SHA256_sodium_KAT_7.to_repeat = [65 x i8] c"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno\00"
@__const.SHA256_sodium_KAT_7.expected_result = [32 x i8] c"P\E7*\0E&D/\E2U-\C3\93\8A\C5\86X\22\8C\0C\BF\B1\D2\CA\87*\E45&o\CD\05^"
@.str = [20 x i8] c"SHA256_sodium_KAT_7\00"
define i32 @SHA256_sodium_KAT_7() {
%1 = alloca [65 x i8]
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = tail call dereferenceable_or_null(1073741824) i8* @malloc(i32 1073741824)
%5 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %11, %6 ]
%8 = shl nuw nsw i64 %7, 6
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = call i32 @memcpy(i8* %9, i8* %5, i32 64)
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, 16777216
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = call i32 @SHA256_sodium(i8* %4, i8* %14, i32 1073741824)
%17 = call i32 @check_KAT(i8* %14, i8* %15, i32 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
ret i32 undef
}