#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 RAND_load_file(char *, int);
int /*<<< orphan*/ RAND_write_file(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int nb;
  if (argc != 2) {
    printf("Usage: tport_rand <output seed file>\n");
    exit(0);
  }
  printf("Please move mouse for until the application stops\n");
  RAND_load_file("/dev/random", 1024);
  RAND_write_file(argv[1]);
  nb = RAND_load_file(argv[1], -1);
  printf("Wrote %d bytes to the seed file\n", nb);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1175 <main+0x35>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x400,%esi
call   1030 <RAND_load_file@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <RAND_write_file@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0xffffffff,%esi
call   1030 <RAND_load_file@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11a1 <main+0x51>
mov    %rsi,%rbx
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe94(%rip),%rdi
mov    $0x400,%esi
call   1030 <RAND_load_file@plt>
mov    0x8(%rbx),%rdi
call   1060 <RAND_write_file@plt>
mov    0x8(%rbx),%rdi
mov    $0xffffffff,%esi
call   1030 <RAND_load_file@plt>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Usage: tport_rand <output seed file>\0A\00"
@.str.1 = [51 x i8] c"Please move mouse for until the application stops\0A\00"
@.str.2 = [12 x i8] c"/dev/random\00"
@.str.3 = [33 x i8] c"Wrote %d bytes to the seed file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @RAND_load_file(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @RAND_write_file(i8* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @RAND_load_file(i8* %21, i32 -1)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [12 x i8] c"/dev/random\00"
@.str.3 = [33 x i8] c"Wrote %d bytes to the seed file\0A\00"
@str = [50 x i8] c"Please move mouse for until the application stops\00"
@str.4 = [37 x i8] c"Usage: tport_rand <output seed file>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @RAND_load_file(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @RAND_write_file(i8* %11)
%13 = load i8*, i8** %10
%14 = tail call i32 @RAND_load_file(i8* %13, i32 -1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %14)
ret i32 0
}