#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*/ assert(int);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int xor_bytes(unsigned char *, unsigned char *, int);
void test_xor_bytes(void) {
  unsigned char dest[] = {15, 3, 9, 2, 17};
  unsigned char src[] = {12, 5, 1, 8, 12, 19};
  unsigned char expected_dest[] = {15, 2, 1, 14, 17};
  unsigned char expected_src[] = {12, 5, 1, 8, 12, 19};
  printf("\tStart  test_xor_bytes\n");
  assert(xor_bytes(NULL, src, 0));
  assert(xor_bytes(dest, NULL, 0));
  assert(xor_bytes(NULL, NULL, 0));
  assert(!xor_bytes(NULL, src, 5));
  assert(!xor_bytes(dest, NULL, 1));
  assert(!xor_bytes(NULL, NULL, 10));
  assert(xor_bytes(dest + 1, src + 2, 3));
  assert(memcmp(dest, expected_dest, sizeof dest) == 0);
  assert(memcmp(src, expected_src, sizeof src) == 0);
  assert(xor_bytes(dest, src, 0));
  assert(memcmp(dest, expected_dest, sizeof dest) == 0);
  assert(memcmp(src, expected_src, sizeof src) == 0);
  printf("\tFinish test_xor_bytes\n");
}


x86 assembly (clang, -O0):
<test_xor_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xeb2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xead(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xe9f(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe97(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe92(%rip),%al
mov    %al,-0xc(%rbp)
mov    0xe8a(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe84(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
lea    -0xb(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
mov    %rsi,%rdi
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0xb(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x5,%edx
call   1030 <xor_bytes@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <xor_bytes@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
mov    %rsi,%rdi
call   1030 <xor_bytes@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
add    $0x1,%rdi
lea    -0xb(%rbp),%rsi
add    $0x2,%rsi
mov    $0x3,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0xb(%rbp),%rdi
lea    -0x16(%rbp),%rsi
mov    $0x6,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
lea    -0xb(%rbp),%rsi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0x5(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0xb(%rbp),%rdi
lea    -0x16(%rbp),%rsi
mov    $0x6,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd18(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_xor_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movb   $0x11,0xc(%rsp)
movl   $0x209030f,0x8(%rsp)
02
movw   $0x130c,0x14(%rsp)
movl   $0x801050c,0x10(%rsp)
08
movb   $0x11,0x1c(%rsp)
movl   $0xe01020f,0x18(%rsp)
0e
movw   $0x130c,0x24(%rsp)
movl   $0x801050c,0x20(%rsp)
08
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r14
xor    %edi,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <xor_bytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <xor_bytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <xor_bytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0x9(%rsp),%rdi
lea    0x12(%rsp),%rsi
mov    $0x3,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    0x18(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <xor_bytes@plt>
mov    %eax,%edi
call   1060 <assert@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xd4b(%rip),%rdi
call   1040 <puts@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_xor_bytes.dest = [5 x i8] c"\0F\03\09\02\11"
@__const.test_xor_bytes.src = [6 x i8] c"\0C\05\01\08\0C\13"
@__const.test_xor_bytes.expected_dest = [5 x i8] c"\0F\02\01\0E\11"
@__const.test_xor_bytes.expected_src = [6 x i8] c"\0C\05\01\08\0C\13"
@.str = [24 x i8] c"\09Start test_xor_bytes\0A\00"
@.str.1 = [24 x i8] c"\09Finish test_xor_bytes\0A\00"
define void @test_xor_bytes() {
%1 = alloca [5 x i8]
%2 = alloca [6 x i8]
%3 = alloca [5 x i8]
%4 = alloca [6 x i8]
%5 = bitcast [5 x i8]* %1 to i8*
%6 = bitcast [6 x i8]* %2 to i8*
%7 = bitcast [5 x i8]* %3 to i8*
%8 = bitcast [6 x i8]* %4 to i8*
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%11 = call i32 @xor_bytes(i8* null, i8* %10, i32 0)
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%14 = call i32 @xor_bytes(i8* %13, i8* null, i32 0)
%15 = call i32 @assert(i32 %14)
%16 = call i32 @xor_bytes(i8* null, i8* null, i32 0)
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%19 = call i32 @xor_bytes(i8* null, i8* %18, i32 5)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%25 = call i32 @xor_bytes(i8* %24, i8* null, i32 1)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @xor_bytes(i8* null, i8* null, i32 10)
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds i8, i8* %37, i64 2
%39 = call i32 @xor_bytes(i8* %36, i8* %38, i32 3)
%40 = call i32 @assert(i32 %39)
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%43 = call i64 @memcmp(i8* %41, i8* %42, i32 5)
%44 = icmp eq i64 %43, 0
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%49 = call i64 @memcmp(i8* %47, i8* %48, i32 6)
%50 = icmp eq i64 %49, 0
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%55 = call i32 @xor_bytes(i8* %53, i8* %54, i32 0)
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%58 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%59 = call i64 @memcmp(i8* %57, i8* %58, i32 5)
%60 = icmp eq i64 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%64 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%65 = call i64 @memcmp(i8* %63, i8* %64, i32 6)
%66 = icmp eq i64 %65, 0
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_xor_bytes.dest = [5 x i8] c"\0F\03\09\02\11"
@__const.test_xor_bytes.expected_dest = [5 x i8] c"\0F\02\01\0E\11"
@__const.test_xor_bytes.expected_src = [6 x i8] c"\0C\05\01\08\0C\13"
@str = [23 x i8] c"\09Start test_xor_bytes\00"
@str.2 = [23 x i8] c"\09Finish test_xor_bytes\00"
define void @test_xor_bytes() {
%1 = alloca [5 x i8]
%2 = alloca [6 x i8]
%3 = alloca [5 x i8]
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%10 = call i32 @xor_bytes(i8* null, i8* %6, i32 0)
%11 = call i32 @assert(i32 %10)
%12 = call i32 @xor_bytes(i8* %5, i8* null, i32 0)
%13 = call i32 @assert(i32 %12)
%14 = call i32 @xor_bytes(i8* null, i8* null, i32 0)
%15 = call i32 @assert(i32 %14)
%16 = call i32 @xor_bytes(i8* null, i8* %6, i32 5)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @xor_bytes(i8* %5, i8* null, i32 1)
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @xor_bytes(i8* null, i8* null, i32 10)
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 2
%30 = call i32 @xor_bytes(i8* %28, i8* %29, i32 3)
%31 = call i32 @assert(i32 %30)
%32 = call i64 @memcmp(i8* %5, i8* %7, i32 5)
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = call i64 @memcmp(i8* %6, i8* %8, i32 6)
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 @xor_bytes(i8* %5, i8* %6, i32 0)
%41 = call i32 @assert(i32 %40)
%42 = call i64 @memcmp(i8* %5, i8* %7, i32 5)
%43 = icmp eq i64 %42, 0
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = call i64 @memcmp(i8* %6, i8* %8, i32 6)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
ret void
}