#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 */
scalar_t__ bit_get(unsigned char const *, int);
int /*<<< orphan*/ bit_set(unsigned char *, int, int);
void bit_xor(const unsigned char *bits1, const unsigned char *bits2,
             unsigned char *bitsx, int size) {
  int i;
  for (i = 0; i < size; i++) {
    if (bit_get(bits1, i) != bit_get(bits2, i))
      bit_set(bitsx, i, 1);
    else
      bit_set(bitsx, i, 0);
  }
  return;
}


x86 assembly (clang, -O0):
<bit_xor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ad <bit_xor+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <bit_get@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <bit_get@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     118c <bit_xor+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    $0x1,%edx
call   1040 <bit_set@plt>
jmp    119a <bit_xor+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
xor    %edx,%edx
call   1040 <bit_set@plt>
jmp    119f <bit_xor+0x7f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113e <bit_xor+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_xor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    1171 <bit_xor+0x51>
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %ebp,%ebp
nopl   (%rax)
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <bit_get@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <bit_get@plt>
xor    %edx,%edx
cmp    %rax,%rbx
setne  %dl
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <bit_set@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1140 <bit_xor+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bit_xor(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %31, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i32, i32* %9
%17 = call i64 @bit_get(i8* %15, i32 %16)
%18 = load i8*, i8** %6
%19 = load i32, i32* %9
%20 = call i64 @bit_get(i8* %18, i32 %19)
%21 = icmp ne i64 %17, %20
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i8*, i8** %7
%24 = load i32, i32* %9
%25 = call i32 @bit_set(i8* %23, i32 %24, i32 1)
br label %30
26: ; preds = %14
%27 = load i8*, i8** %7
%28 = load i32, i32* %9
%29 = call i32 @bit_set(i8* %27, i32 %28, i32 0)
br label %30
30: ; preds = %26, %22
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %10
34: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @bit_xor(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %15
6: ; preds = %4, %6
%7 = phi i32 [ %13, %6 ], [ 0, %4 ]
%8 = tail call i64 @bit_get(i8* %0, i32 %7)
%9 = tail call i64 @bit_get(i8* %1, i32 %7)
%10 = icmp ne i64 %8, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @bit_set(i8* %2, i32 %7, i32 %11)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %15, label %6
15: ; preds = %6, %4
ret void
}