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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ blockToSTring(int *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int rand();
int /*<<< orphan*/ srand(int);
int time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 3) {
    perror("Not enough args. eg ./program <no of plain text> <output file>");
    exit(1);
  }
  int seed = time(NULL);
  srand(seed);
  uint8_t plain[16];
  char cplain[100];
  FILE *file = fopen(argv[2], "w");
  int count = atoi(argv[1]);
  int j = 0;
  for (j = 0; j < count; j++) {
    int i = 0;
    for (i = 0; i < 16; i++) {
      plain[i] = rand() % 256;
    }
    blockToSTring(plain, cplain);
    fprintf(file, "%s\n", cplain);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11c9 <main+0x39>
lea    0xe46(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xd8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
movl   $0x0,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
cmp    -0xdc(%rbp),%eax
jge    12be <main+0x12e>
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x10,-0xe4(%rbp)
jge    1280 <main+0xf0>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
movslq -0xe4(%rbp),%rax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1245 <main+0xb5>
lea    -0x60(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1030 <blockToSTring@plt>
mov    -0xd8(%rbp),%rdi
lea    -0xd0(%rbp),%rdx
lea    0xd9c(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    121f <main+0x8f>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
cmp    $0x3,%edi
jne    1403 <main+0x273>
mov    %rsi,%rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x10(%rbx),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    13f1 <main+0x261>
mov    %eax,%ebp
mov    %rsp,%r14
lea    0x40(%rsp),%rbx
lea    0xe53(%rip),%r12
xchg   %ax,%ax
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x28(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x2c(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x30(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x34(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x38(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x3c(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <blockToSTring@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x60>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf6(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"Not enough args. eg ./program <no of plain text> <output file>\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [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 [16 x i32]
%8 = alloca [100 x i8]
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = call i32 @time(i32* null)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call i32 @srand(i32 %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %9
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %10
store i32 0, i32* %11
store i32 0, i32* %11
br label %30
30: ; preds = %54, %18
%31 = load i32, i32* %11
%32 = load i32, i32* %10
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %57
34: ; preds = %30
store i32 0, i32* %12
store i32 0, i32* %12
br label %35
35: ; preds = %44, %34
%36 = load i32, i32* %12
%37 = icmp slt i32 %36, 16
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 256
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 %42
store i32 %40, i32* %43
br label %44
44: ; preds = %38
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %35
47: ; preds = %35
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%50 = call i32 @blockToSTring(i32* %48, i8* %49)
%51 = load i32*, i32** %9
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%53 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %30
57: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [63 x i8] c"Not enough args. eg ./program <no of plain text> <output file>\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i32]
%4 = alloca [100 x i8]
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32 @time(i32* null)
%11 = tail call i32 @srand(i32 %10)
%12 = bitcast [16 x i32]* %3 to i8*
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%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 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %76
21: ; preds = %9
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 2
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 3
%26 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 4
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 5
%28 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 6
%29 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 7
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 8
%31 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 9
%32 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 10
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 11
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 12
%35 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 13
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 14
%37 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 15
br label %38
38: ; preds = %21, %38
%39 = phi i32 [ 0, %21 ], [ %74, %38 ]
%40 = call i32 (...) @rand()
%41 = srem i32 %40, 256
store i32 %41, i32* %22
%42 = call i32 (...) @rand()
%43 = srem i32 %42, 256
store i32 %43, i32* %23
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 256
store i32 %45, i32* %24
%46 = call i32 (...) @rand()
%47 = srem i32 %46, 256
store i32 %47, i32* %25
%48 = call i32 (...) @rand()
%49 = srem i32 %48, 256
store i32 %49, i32* %26
%50 = call i32 (...) @rand()
%51 = srem i32 %50, 256
store i32 %51, i32* %27
%52 = call i32 (...) @rand()
%53 = srem i32 %52, 256
store i32 %53, i32* %28
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 256
store i32 %55, i32* %29
%56 = call i32 (...) @rand()
%57 = srem i32 %56, 256
store i32 %57, i32* %30
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 256
store i32 %59, i32* %31
%60 = call i32 (...) @rand()
%61 = srem i32 %60, 256
store i32 %61, i32* %32
%62 = call i32 (...) @rand()
%63 = srem i32 %62, 256
store i32 %63, i32* %33
%64 = call i32 (...) @rand()
%65 = srem i32 %64, 256
store i32 %65, i32* %34
%66 = call i32 (...) @rand()
%67 = srem i32 %66, 256
store i32 %67, i32* %35
%68 = call i32 (...) @rand()
%69 = srem i32 %68, 256
store i32 %69, i32* %36
%70 = call i32 (...) @rand()
%71 = srem i32 %70, 256
store i32 %71, i32* %37
%72 = call i32 @blockToSTring(i32* %22, i8* %13)
%73 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%74 = add nuw nsw i32 %39, 1
%75 = icmp eq i32 %74, %19
br i1 %75, label %76, label %38
76: ; preds = %38, %9
ret i32 0
}