#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*/ aes256_encrypt_ecb(unsigned char *, unsigned long);
int /*<<< orphan*/ aes256_init(unsigned char *);
int /*<<< orphan*/ printf(char *);
void encrypt(unsigned char key[32], unsigned char *buf,
             unsigned long numbytes) {
  printf("\nBeginning encryption\n");
  aes256_init(key);
  unsigned long offset;
  for (offset = 0; offset < numbytes; offset += 16)
    aes256_encrypt_ecb(buf, offset);
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <aes256_init@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118d <encrypt+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <aes256_encrypt_ecb@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
jmp    1161 <encrypt+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <aes256_init@plt>
test   %r15,%r15
je     1174 <encrypt+0x44>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes256_encrypt_ecb@plt>
add    $0x10,%rbx
cmp    %r15,%rbx
jb     1160 <encrypt+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0ABeginning encryption\0A\00"
define void @encrypt(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = call i32 @aes256_init(i8* %9)
store i64 0, i64* %7
br label %11
11: ; preds = %19, %3
%12 = load i64, i64* %7
%13 = load i64, i64* %6
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i64, i64* %7
%18 = call i32 @aes256_encrypt_ecb(i8* %16, i64 %17)
br label %19
19: ; preds = %15
%20 = load i64, i64* %7
%21 = add i64 %20, 16
store i64 %21, i64* %7
br label %11
22: ; preds = %11
ret void
}

LLVM IR (-O2):
@str = [22 x i8] c"\0ABeginning encryption\00"
define void @encrypt(i8* %0, i8* %1, i64 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @aes256_init(i8* %0)
%6 = icmp eq i64 %2, 0
br i1 %6, label %12, label %7
7: ; preds = %3, %7
%8 = phi i64 [ %10, %7 ], [ 0, %3 ]
%9 = tail call i32 @aes256_encrypt_ecb(i8* %1, i64 %8)
%10 = add i64 %8, 16
%11 = icmp ult i64 %10, %2
br i1 %11, label %7, label %12
12: ; preds = %7, %3
ret void
}