#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AES128_ECB_encrypt(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int atoi(char *);
int /*<<< orphan*/ blockToSTring(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stringToBlock(char *, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 4) {
    perror("Not enough args. eg : ./program <no of samples> <plain text> "
           "<cipher text>");
    exit(1);
  }
  int count = atoi(argv[1]);
  FILE *input = fopen(argv[2], "r");
  FILE *output = fopen(argv[3], "w");
  uint8_t inp[16];
  uint8_t key[16];
  uint8_t out[16];
  char cinp[100];
  char cout[100];
  char ckey[100] = "0102030405060708090A0B0C0D0E0F10";
  stringToBlock(ckey, key);
  int i = 0;
  for (i = 0; i < count; i++) {
    fscanf(input, "%s", cinp);
    stringToBlock(cinp, inp);
    AES128_ECB_encrypt(inp, key, out);
    blockToSTring(out, cout);
    fprintf(output, "%s\n", cout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11d9 <main+0x39>
lea    0xe36(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x240(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x240(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1080 <stringToBlock@plt>
movl   $0x0,-0x244(%rbp)
movl   $0x0,-0x244(%rbp)
mov    -0x244(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12e3 <main+0x143>
mov    -0x20(%rbp),%rdi
lea    -0x160(%rbp),%rdx
lea    0xdd6(%rip),%rsi
call   1040 <fscanf@plt>
lea    -0x160(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <stringToBlock@plt>
lea    -0x70(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1070 <AES128_ECB_encrypt@plt>
lea    -0xf0(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
call   1030 <blockToSTring@plt>
mov    -0x28(%rbp),%rdi
lea    -0x1d0(%rbp),%rdx
lea    0xd88(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x244(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x244(%rbp)
jmp    1258 <main+0xb8>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x4,%edi
jne    12d8 <main+0x148>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x8(%rsp)
mov    0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe91(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe59(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe3d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0x10(%rsp),%rdi
lea    0x80(%rsp),%rsi
call   1070 <stringToBlock@plt>
test   %ebx,%ebx
jle    12c4 <main+0x134>
lea    0x1b0(%rsp),%r13
lea    0x100(%rsp),%rbp
lea    0xc0(%rsp),%r12
lea    0x140(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
lea    0xdd3(%rip),%rsi
mov    %r13,%rdx
call   1040 <fscanf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <stringToBlock@plt>
mov    %rbp,%rdi
lea    0x80(%rsp),%rsi
mov    %r12,%rdx
call   1060 <AES128_ECB_encrypt@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <blockToSTring@plt>
mov    %r15,%rdi
lea    0xd9b(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
add    $0xffffffff,%ebx
jne    1270 <main+0xe0>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd21(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [75 x i8] c"Not enough args. eg : ./program <no of samples> <plain text> <cipher text>\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@__const.main.ckey = [100 x i8] c"0102030405060708090A0B0C0D0E0F10\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [16 x i32]
%10 = alloca [16 x i32]
%11 = alloca [16 x i32]
%12 = alloca [100 x i8]
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %8
%34 = bitcast [100 x i8]* %14 to i8*
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 0
%37 = call i32 @stringToBlock(i8* %35, i32* %36)
store i32 0, i32* %15
store i32 0, i32* %15
br label %38
38: ; preds = %59, %21
%39 = load i32, i32* %15
%40 = load i32, i32* %6
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %62
42: ; preds = %38
%43 = load i32*, i32** %7
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%45 = call i32 @fscanf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%47 = getelementptr inbounds [16 x i32], [16 x i32]* %9, i64 0, i64 0
%48 = call i32 @stringToBlock(i8* %46, i32* %47)
%49 = getelementptr inbounds [16 x i32], [16 x i32]* %9, i64 0, i64 0
%50 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 0
%51 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 0, i64 0
%52 = call i32 @AES128_ECB_encrypt(i32* %49, i32* %50, i32* %51)
%53 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 0, i64 0
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%55 = call i32 @blockToSTring(i32* %53, i8* %54)
%56 = load i32*, i32** %8
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%58 = call i32 @fprintf(i32* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %42
%60 = load i32, i32* %15
%61 = add nsw i32 %60, 1
store i32 %61, i32* %15
br label %38
62: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [75 x i8] c"Not enough args. eg : ./program <no of samples> <plain text> <cipher text>\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@__const.main.ckey = [100 x i8] c"0102030405060708090A0B0C0D0E0F10\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i32]
%4 = alloca [16 x i32]
%5 = alloca [16 x i32]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = icmp eq i32 %0, 4
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = bitcast [16 x i32]* %3 to i8*
%24 = bitcast [16 x i32]* %4 to i8*
%25 = bitcast [16 x i32]* %5 to i8*
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%29 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%30 = call i32 @stringToBlock(i8* %28, i32* %29)
%31 = icmp sgt i32 %16, 0
br i1 %31, label %32, label %44
32: ; preds = %13
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
br label %35
35: ; preds = %32, %35
%36 = phi i32 [ 0, %32 ], [ %42, %35 ]
%37 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%38 = call i32 @stringToBlock(i8* %26, i32* %33)
%39 = call i32 @AES128_ECB_encrypt(i32* %33, i32* %29, i32* %34)
%40 = call i32 @blockToSTring(i32* %34, i8* %27)
%41 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%42 = add nuw nsw i32 %36, 1
%43 = icmp eq i32 %42, %16
br i1 %43, label %44, label %35
44: ; preds = %35, %13
ret i32 0
}