#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 */
typedef int uint64_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int ct_ge_u64(int /*<<< orphan*/ const, unsigned long long);
int ct_le_u64(int /*<<< orphan*/ const, unsigned long long);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
void round2_ct(uint64_t *out, const uint32_t *in) {
  int i;
  memset(out, 0, 128);
  for (i = 0; i < 1024; i++) {
    uint64_t b =
        ct_ge_u64(in[i], 1073741824ULL) & ct_le_u64(in[i], 3221225471ULL);
    out[i / 64] |= b << (uint64_t)(i % 64);
  }
}


x86 assembly (clang, -O0):
<round2_ct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1030 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    11e9 <round2_ct+0xb9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    $0x40000000,%esi
call   1050 <ct_ge_u64@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    $0xbfffffff,%esi
call   1040 <ct_le_u64@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%eax
mov    %edx,%ecx
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <round2_ct+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<round2_ct>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x80,%edx
call   1030 <memset@plt>
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%edi
mov    $0x40000000,%esi
call   1050 <ct_ge_u64@plt>
mov    %eax,%ebp
mov    (%r15,%rbx,4),%edi
mov    $0xbfffffff,%esi
call   1040 <ct_le_u64@plt>
and    %ebp,%eax
mov    %ebx,%ecx
shl    %cl,%eax
mov    %rbx,%rcx
shr    $0x4,%rcx
and    $0xffffffc,%ecx
or     %eax,(%r14,%rcx,1)
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1150 <round2_ct+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @round2_ct(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %3
%8 = call i32 @memset(i32* %7, i32 0, i32 128)
store i32 0, i32* %5
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 1024
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @ct_ge_u64(i32 %17, i64 1073741824)
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @ct_le_u64(i32 %23, i64 3221225471)
%25 = and i32 %18, %24
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = srem i32 %27, 64
%29 = shl i32 %26, %28
%30 = load i32*, i32** %3
%31 = load i32, i32* %5
%32 = sdiv i32 %31, 64
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %30, i64 %33
%35 = load i32, i32* %34
%36 = or i32 %35, %29
store i32 %36, i32* %34
br label %37
37: ; preds = %12
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %9
40: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @round2_ct(i32* %0, i32* nocapture %1) {
%3 = tail call i32 @memset(i32* %0, i32 0, i32 128)
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %20, %4 ]
%6 = getelementptr inbounds i32, i32* %1, i64 %5
%7 = load i32, i32* %6
%8 = tail call i32 @ct_ge_u64(i32 %7, i64 1073741824)
%9 = load i32, i32* %6
%10 = tail call i32 @ct_le_u64(i32 %9, i64 3221225471)
%11 = and i32 %10, %8
%12 = trunc i64 %5 to i32
%13 = and i32 %12, 63
%14 = shl i32 %11, %13
%15 = lshr i64 %5, 6
%16 = and i64 %15, 67108863
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
%19 = or i32 %14, %18
store i32 %19, i32* %17
%20 = add nuw nsw i64 %5, 1
%21 = icmp eq i64 %20, 1024
br i1 %21, label %22, label %4
22: ; preds = %4
ret void
}