#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 */
unsigned char *malloc(int);
unsigned char *cbc_pre_process(unsigned char *message,
                               unsigned char *previous_ciphertext) {
  unsigned char *pre_message_processed = malloc(8 * sizeof(char) + 1);
  int i = 0;
  unsigned char xor_char;
  for (i = 0; i < 8; i++) {
    xor_char = message[i] ^ previous_ciphertext[i];
    pre_message_processed[i] = xor_char;
  }
  pre_message_processed[9] = '\0';
  return pre_message_processed;
}


x86 assembly (clang, -O0):
<cbc_pre_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    117f <cbc_pre_process+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113c <cbc_pre_process+0x2c>
mov    -0x18(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbc_pre_process>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    (%rbx),%cl
xor    (%r14),%cl
mov    %cl,(%rax)
mov    0x1(%rbx),%cl
xor    0x1(%r14),%cl
mov    %cl,0x1(%rax)
mov    0x2(%rbx),%cl
xor    0x2(%r14),%cl
mov    %cl,0x2(%rax)
mov    0x3(%rbx),%cl
xor    0x3(%r14),%cl
mov    %cl,0x3(%rax)
mov    0x4(%rbx),%cl
xor    0x4(%r14),%cl
mov    %cl,0x4(%rax)
mov    0x5(%rbx),%cl
xor    0x5(%r14),%cl
mov    %cl,0x5(%rax)
mov    0x6(%rbx),%cl
xor    0x6(%r14),%cl
mov    %cl,0x6(%rax)
mov    0x7(%rbx),%cl
xor    0x7(%r14),%cl
mov    %cl,0x7(%rax)
movb   $0x0,0x9(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @cbc_pre_process(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i8* @malloc(i32 9)
store i8* %8, i8** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %9
9: ; preds = %32, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %35
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = load i8*, i8** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = xor i32 %18, %24
%26 = trunc i32 %25 to i8
store i8 %26, i8* %7
%27 = load i8, i8* %7
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %12
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %9
35: ; preds = %9
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 9
store i8 0, i8* %37
%38 = load i8*, i8** %5
ret i8* %38
}

LLVM IR (-O2):
define noalias i8* @cbc_pre_process(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%4 = load i8, i8* %0
%5 = load i8, i8* %1
%6 = xor i8 %5, %4
store i8 %6, i8* %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 1
%10 = load i8, i8* %9
%11 = xor i8 %10, %8
%12 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 2
%16 = load i8, i8* %15
%17 = xor i8 %16, %14
%18 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %17, i8* %18
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %1, i64 3
%22 = load i8, i8* %21
%23 = xor i8 %22, %20
%24 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %23, i8* %24
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %1, i64 4
%28 = load i8, i8* %27
%29 = xor i8 %28, %26
%30 = getelementptr inbounds i8, i8* %3, i64 4
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %0, i64 5
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %1, i64 5
%34 = load i8, i8* %33
%35 = xor i8 %34, %32
%36 = getelementptr inbounds i8, i8* %3, i64 5
store i8 %35, i8* %36
%37 = getelementptr inbounds i8, i8* %0, i64 6
%38 = load i8, i8* %37
%39 = getelementptr inbounds i8, i8* %1, i64 6
%40 = load i8, i8* %39
%41 = xor i8 %40, %38
%42 = getelementptr inbounds i8, i8* %3, i64 6
store i8 %41, i8* %42
%43 = getelementptr inbounds i8, i8* %0, i64 7
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %1, i64 7
%46 = load i8, i8* %45
%47 = xor i8 %46, %44
%48 = getelementptr inbounds i8, i8* %3, i64 7
store i8 %47, i8* %48
%49 = getelementptr inbounds i8, i8* %3, i64 9
store i8 0, i8* %49
ret i8* %3
}