#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;

/* Variables and functions */
uint64_t scrambler_bitwise(uint64_t *state, uint64_t syncheader,
                           uint64_t payload) {
  int i;
  uint64_t in_bit, out_bit;
  uint64_t scrambled = 0x0;
  for (i = 0; i < 64; i++) {
    in_bit = (payload >> i) & 0x1;
    out_bit = (in_bit ^ (*state >> 38) ^ (*state >> 57)) & 0x1;
    *state = (*state << 1) | out_bit;
    scrambled |= (out_bit << i);
  };
  return scrambled;
}


x86 assembly (clang, -O0):
<scrambler_bitwise>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    118d <scrambler_bitwise+0x8d>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%edx
mov    $0x26,%ecx
sar    %cl,%edx
mov    %edx,%ecx
xor    %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%edx
mov    $0x39,%ecx
sar    %cl,%edx
mov    %edx,%ecx
xor    %ecx,%eax
and    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
shl    $0x1,%ecx
or     -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    %cl,%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    111c <scrambler_bitwise+0x1c>
mov    -0x20(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<scrambler_bitwise>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @scrambler_bitwise(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %10
store i32 0, i32* %7
br label %11
11: ; preds = %40, %3
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 64
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = ashr i32 %15, %16
%18 = and i32 %17, 1
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = ashr i32 %21, 38
%23 = xor i32 %19, %22
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = ashr i32 %25, 57
%27 = xor i32 %23, %26
%28 = and i32 %27, 1
store i32 %28, i32* %9
%29 = load i32*, i32** %4
%30 = load i32, i32* %29
%31 = shl i32 %30, 1
%32 = load i32, i32* %9
%33 = or i32 %31, %32
%34 = load i32*, i32** %4
store i32 %33, i32* %34
%35 = load i32, i32* %9
%36 = load i32, i32* %7
%37 = shl i32 %35, %36
%38 = load i32, i32* %10
%39 = or i32 %38, %37
store i32 %39, i32* %10
br label %40
40: ; preds = %14
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %11
43: ; preds = %11
%44 = load i32, i32* %10
ret i32 %44
}

LLVM IR (-O2):
define i32 @scrambler_bitwise(i32* nocapture readnone %0, i32 %1, i32 %2) {
ret i32 0
}