#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 */
size_t EOF;
int /*<<< orphan*/ encryptAES(unsigned char *, unsigned char *,
                              unsigned char *);
int /*<<< orphan*/ expandKey(unsigned char *, unsigned char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fwrite(unsigned char *, int, int, int /*<<< orphan*/);
size_t scanf(char *, unsigned char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  unsigned char key[16];
  unsigned char exp_key[176];
  unsigned char plain[16];
  unsigned char cipher[16];
  size_t i;
  i = scanf("%16c", key);
  expandKey(key, exp_key);
  while (scanf("%16c", plain) != EOF) {
    encryptAES(exp_key, plain, cipher);
    if (fwrite(cipher, sizeof(unsigned char), 16, stdout) != 16)
      fprintf(stderr, "ERROR: FWRITE to stdout.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1050 <scanf@plt>
mov    %rax,-0xf8(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1070 <expandKey@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%rax
je     120f <main+0xbf>
lea    -0xd0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1030 <encryptAES@plt>
lea    -0xf0(%rbp),%rdi
mov    0x2df5(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x10,%edx
call   1060 <fwrite@plt>
cmp    $0x10,%eax
je     120a <main+0xba>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1190 <main+0x40>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
lea    0xe98(%rip),%r14
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <expandKey@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x2e51(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    11b1 <main+0x61>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x30(%rsp),%r14
mov    %rsp,%r15
lea    0x10(%rsp),%rbx
mov    0x2e0b(%rip),%r13
lea    0xe34(%rip),%r12
jmp    11e1 <main+0x91>
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     119d <main+0x4d>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <encryptAES@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1060 <fwrite@plt>
cmp    $0x10,%eax
je     11d0 <main+0x80>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11d0 <main+0x80>

LLVM IR (-O0):
@.str = [5 x i8] c"%16c\00"
@EOF = global i64 0
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: FWRITE to stdout.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca [176 x i8]
%8 = alloca [16 x i8]
%9 = alloca [16 x i8]
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%12 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
store i64 %12, i64* %10
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [176 x i8], [176 x i8]* %7, i64 0, i64 0
%15 = call i32 @expandKey(i8* %13, i8* %14)
br label %16
16: ; preds = %33, %2
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%18 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %16
%22 = getelementptr inbounds [176 x i8], [176 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%25 = call i32 @encryptAES(i8* %22, i8* %23, i8* %24)
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i8* %26, i32 1, i32 16, i32 %27)
%29 = icmp ne i32 %28, 16
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %30, %21
br label %16
34: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%16c\00"
@EOF = global i64 0
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: FWRITE to stdout.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i8]
%4 = alloca [176 x i8]
%5 = alloca [16 x i8]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [176 x i8], [176 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%11 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %7)
%12 = call i32 @expandKey(i8* %7, i8* %8)
%13 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %28, label %16
16: ; preds = %2, %24
%17 = call i32 @encryptAES(i8* %8, i8* %9, i8* %10)
%18 = load i32, i32* @stdout
%19 = call i32 @fwrite(i8* %10, i32 1, i32 16, i32 %18)
%20 = icmp eq i32 %19, 16
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %16
%25 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %16
28: ; preds = %24, %2
ret i32 0
}