#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*/ memcpy(void *, void *, unsigned int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int flipBit(void *data, unsigned bytesz) {
  srand(time(NULL));
  long long dest = 0;
  long long bitPos = -1;
  bitPos = 6;
  memcpy((void *)&dest, data, bytesz);
  if ((dest >> bitPos) & 0x1) {
    dest = dest & (~((long long)0x1 << (bitPos)));
  } else {
    dest = dest | ((long long)0x1 << (bitPos));
  }
  memcpy(data, (void *)&dest, bytesz);
  return bitPos;
}


x86 assembly (clang, -O0):
<flipBit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movq   $0x0,-0x18(%rbp)
movq   $0xffffffffffffffff,-0x20(%rbp)
ff
movq   $0x6,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sar    %cl,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11b3 <flipBit+0x83>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%rdx
mov    %rdx,%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    11cd <flipBit+0x9d>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flipBit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
xorb   $0x40,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    $0x6,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @flipBit(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
store i64 0, i64* %5
store i64 -1, i64* %6
store i64 6, i64* %6
%9 = bitcast i64* %5 to i8*
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @memcpy(i8* %9, i8* %10, i32 %11)
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = ashr i64 %13, %14
%16 = and i64 %15, 1
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = shl i64 1, %20
%22 = xor i64 %21, -1
%23 = and i64 %19, %22
store i64 %23, i64* %5
br label %29
24: ; preds = %2
%25 = load i64, i64* %5
%26 = load i64, i64* %6
%27 = shl i64 1, %26
%28 = or i64 %25, %27
store i64 %28, i64* %5
br label %29
29: ; preds = %24, %18
%30 = load i8*, i8** %3
%31 = bitcast i64* %5 to i8*
%32 = load i32, i32* %4
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
%34 = load i64, i64* %6
%35 = trunc i64 %34 to i32
ret i32 %35
}

LLVM IR (-O2):
define i32 @flipBit(i8* %0, i32 %1) {
%3 = alloca i64
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i32 @memcpy(i8* %6, i8* %0, i32 %1)
%8 = load i64, i64* %3
%9 = xor i64 %8, 64
store i64 %9, i64* %3
%10 = call i32 @memcpy(i8* %0, i8* %6, i32 %1)
ret i32 6
}