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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ blockToString(unsigned char *, char *);
int /*<<< orphan*/ convertToBlock(unsigned char *, int *);
int /*<<< orphan*/ convertToNum(unsigned char *, int *);
int /*<<< orphan*/ encrypt(int *, int *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stringToBlock(char *, unsigned char *);
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");
  uint64_t *pt = malloc(sizeof(uint64_t) * 2);
  uint64_t *ct = malloc(sizeof(uint64_t) * 2);
  uint64_t *K = malloc(sizeof(uint64_t) * 2);
  unsigned char block[16];
  K[0] = 0x0807060504030201;
  K[1] = 0x0403020501010203;
  pt[0] = 0;
  pt[1] = 0;
  ct[0] = 0;
  ct[1] = 0;
  char cinp[100];
  char cout[100];
  int i = 0;
  for (i = 0; i < count; i++) {
    fscanf(input, "%s", cinp);
    stringToBlock(cinp, block);
    convertToNum(block, pt);
    encrypt(pt, ct, K);
    convertToBlock(block, ct);
    blockToString(block, cout);
    fprintf(output, "%s\n", cout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11f9 <main+0x39>
lea    0xe16(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe33(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe1d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movl   $0x4030201,(%rax)
mov    -0x40(%rbp),%rax
movl   $0x1010203,0x4(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,0x4(%rax)
movl   $0x0,-0x134(%rbp)
movl   $0x0,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1352 <main+0x192>
mov    -0x20(%rbp),%rdi
lea    -0xc0(%rbp),%rdx
lea    0xd78(%rip),%rsi
call   1040 <fscanf@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1090 <stringToBlock@plt>
lea    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10d0 <convertToNum@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1030 <encrypt@plt>
lea    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <convertToBlock@plt>
lea    -0x50(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1080 <blockToString@plt>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xd19(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    12b6 <main+0xf6>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x4,%edi
jne    12fd <main+0x13d>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x18(%rsp)
mov    0x18(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x10(%rsp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    $0x8,%edi
call   1060 <malloc@plt>
movabs $0x101020304030201,%rcx
02 01 01
mov    %rax,0x8(%rsp)
mov    %rcx,(%rax)
movq   $0x0,(%r12)
movq   $0x0,0x0(%r13)
test   %ebx,%ebx
jle    12e9 <main+0x129>
lea    0xa0(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x18(%rsp),%rdi
lea    0xdc3(%rip),%rsi
mov    %r14,%rdx
call   1040 <fscanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <stringToBlock@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10d0 <convertToNum@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%rdx
call   1030 <encrypt@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <convertToBlock@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1080 <blockToString@plt>
mov    0x10(%rsp),%rdi
lea    0xd76(%rip),%rsi
mov    %rbp,%rdx
call   1050 <fprintf@plt>
add    $0xffffffff,%ebx
jne    1280 <main+0xc0>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcfc(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <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"
@.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 i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca [16 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 = call i32* @malloc(i32 8)
store i32* %34, i32** %9
%35 = call i32* @malloc(i32 8)
store i32* %35, i32** %10
%36 = call i32* @malloc(i32 8)
store i32* %36, i32** %11
%37 = load i32*, i32** %11
%38 = getelementptr inbounds i32, i32* %37, i64 0
store i32 67305985, i32* %38
%39 = load i32*, i32** %11
%40 = getelementptr inbounds i32, i32* %39, i64 1
store i32 16843267, i32* %40
%41 = load i32*, i32** %9
%42 = getelementptr inbounds i32, i32* %41, i64 0
store i32 0, i32* %42
%43 = load i32*, i32** %9
%44 = getelementptr inbounds i32, i32* %43, i64 1
store i32 0, i32* %44
%45 = load i32*, i32** %10
%46 = getelementptr inbounds i32, i32* %45, i64 0
store i32 0, i32* %46
%47 = load i32*, i32** %10
%48 = getelementptr inbounds i32, i32* %47, i64 1
store i32 0, i32* %48
store i32 0, i32* %15
store i32 0, i32* %15
br label %49
49: ; preds = %76, %21
%50 = load i32, i32* %15
%51 = load i32, i32* %6
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %79
53: ; preds = %49
%54 = load i32*, i32** %7
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%56 = call i32 @fscanf(i32* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%59 = call i32 @stringToBlock(i8* %57, i8* %58)
%60 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%61 = load i32*, i32** %9
%62 = call i32 @convertToNum(i8* %60, i32* %61)
%63 = load i32*, i32** %9
%64 = load i32*, i32** %10
%65 = load i32*, i32** %11
%66 = call i32 @encrypt(i32* %63, i32* %64, i32* %65)
%67 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%68 = load i32*, i32** %10
%69 = call i32 @convertToBlock(i8* %67, i32* %68)
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%72 = call i32 @blockToString(i8* %70, i8* %71)
%73 = load i32*, i32** %8
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%75 = call i32 @fprintf(i32* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %53
%77 = load i32, i32* %15
%78 = add nsw i32 %77, 1
store i32 %78, i32* %15
br label %49
79: ; preds = %49
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"
@.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 i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = icmp eq i32 %0, 4
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32* @malloc(i32 8)
%21 = tail call i32* @malloc(i32 8)
%22 = tail call i32* @malloc(i32 8)
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
store i32 67305985, i32* %22
%24 = getelementptr inbounds i32, i32* %22, i64 1
store i32 16843267, i32* %24
store i32 0, i32* %20
%25 = getelementptr inbounds i32, i32* %20, i64 1
store i32 0, i32* %25
store i32 0, i32* %21
%26 = getelementptr inbounds i32, i32* %21, i64 1
store i32 0, i32* %26
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%29 = icmp sgt i32 %13, 0
br i1 %29, label %30, label %41
30: ; preds = %10, %30
%31 = phi i32 [ %39, %30 ], [ 0, %10 ]
%32 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%33 = call i32 @stringToBlock(i8* %27, i8* %23)
%34 = call i32 @convertToNum(i8* %23, i32* %20)
%35 = call i32 @encrypt(i32* %20, i32* %21, i32* %22)
%36 = call i32 @convertToBlock(i8* %23, i32* %21)
%37 = call i32 @blockToString(i8* %23, i8* %28)
%38 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%39 = add nuw nsw i32 %31, 1
%40 = icmp eq i32 %39, %13
br i1 %40, label %41, label %30
41: ; preds = %30, %10
ret i32 0
}