#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*/ AES_128_encrypt(void *, void *);
int fread(void *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ fwrite(void *, int, int, int /*<<< orphan*/);
void *malloc(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  void *plaintext = malloc(16);
  void *ciphertext = malloc(16);
  while (fread(plaintext, 1, 16, stdin) == 16) {
    AES_128_encrypt(ciphertext, plaintext);
    fwrite(ciphertext, 1, 16, stdout);
  }
  free(ciphertext);
  free(plaintext);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e62(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
cmp    $0x10,%eax
jne    11ce <main+0x7e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <AES_128_encrypt@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e20(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x10,%edx
call   1070 <fwrite@plt>
jmp    117b <main+0x2b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x2e6f(%rip),%r15
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
cmp    $0x10,%eax
jne    11db <main+0x8b>
mov    0x2e3e(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <AES_128_encrypt@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1070 <fwrite@plt>
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
cmp    $0x10,%eax
je     11a0 <main+0x50>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @malloc(i32 16)
store i8* %4, i8** %2
%5 = call i8* @malloc(i32 16)
store i8* %5, i8** %3
br label %6
6: ; preds = %11, %0
%7 = load i8*, i8** %2
%8 = load i32, i32* @stdin
%9 = call i32 @fread(i8* %7, i32 1, i32 16, i32 %8)
%10 = icmp eq i32 %9, 16
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8*, i8** %2
%14 = call i32 @AES_128_encrypt(i8* %12, i8* %13)
%15 = load i8*, i8** %3
%16 = load i32, i32* @stdout
%17 = call i32 @fwrite(i8* %15, i32 1, i32 16, i32 %16)
br label %6
18: ; preds = %6
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %2
%22 = call i32 @free(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%2 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%3 = load i32, i32* @stdin
%4 = tail call i32 @fread(i8* %1, i32 1, i32 16, i32 %3)
%5 = icmp eq i32 %4, 16
br i1 %5, label %6, label %13
6: ; preds = %0, %6
%7 = tail call i32 @AES_128_encrypt(i8* %2, i8* %1)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fwrite(i8* %2, i32 1, i32 16, i32 %8)
%10 = load i32, i32* @stdin
%11 = tail call i32 @fread(i8* %1, i32 1, i32 16, i32 %10)
%12 = icmp eq i32 %11, 16
br i1 %12, label %6, label %13
13: ; preds = %6, %0
%14 = tail call i32 @free(i8* %2)
%15 = tail call i32 @free(i8* %1)
ret i32 0
}