#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ randomiseRange(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fd;
  if (argc != 2) {
    printf("Usage: %s <filename.sti>\n", argv[0]);
    return 1;
  }
  fd = fopen(argv[1], "wt");
  if (!fd) {
    printf("Failed to open %s for writing !\n", argv[1]);
    return 1;
  }
  srand((int)time(NULL));
  randomiseRange(fd, 0x020, 96);
  randomiseRange(fd, 0x0a0, 80);
  randomiseRange(fd, 0x120, 80);
  fclose(fd);
  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     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123b <main+0xdb>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
mov    $0x60,%edx
call   1030 <randomiseRange@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa0,%esi
mov    $0x50,%edx
call   1030 <randomiseRange@plt>
mov    -0x18(%rbp),%rdi
mov    $0x120,%esi
mov    $0x50,%edx
call   1030 <randomiseRange@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11d6 <main+0x76>
mov    0x8(%rbx),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11e2 <main+0x82>
mov    %rax,%r15
xor    %r14d,%r14d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    %r15,%rdi
mov    $0x20,%esi
mov    $0x60,%edx
call   1030 <randomiseRange@plt>
mov    %r15,%rdi
mov    $0xa0,%esi
mov    $0x50,%edx
call   1030 <randomiseRange@plt>
mov    %r15,%rdi
mov    $0x120,%esi
mov    $0x50,%edx
call   1030 <randomiseRange@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    11f8 <main+0x98>
mov    (%rbx),%rsi
lea    0xe20(%rip),%rdi
jmp    11ed <main+0x8d>
mov    0x8(%rbx),%rsi
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: %s <filename.sti>\0A\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [33 x i8] c"Failed to open %s for writing !\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 %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %3
br label %38
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp ne i32* %19, null
br i1 %20, label %26, label %21
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %38
26: ; preds = %14
%27 = call i64 @time(i32* null)
%28 = trunc i64 %27 to i32
%29 = call i32 @srand(i32 %28)
%30 = load i32*, i32** %6
%31 = call i32 @randomiseRange(i32* %30, i32 32, i32 96)
%32 = load i32*, i32** %6
%33 = call i32 @randomiseRange(i32* %32, i32 160, i32 80)
%34 = load i32*, i32** %6
%35 = call i32 @randomiseRange(i32* %34, i32 288, i32 80)
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %26, %21, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: %s <filename.sti>\0A\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [33 x i8] c"Failed to open %s for writing !\0A\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 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %23
15: ; preds = %7
%16 = tail call i64 @time(i32* null)
%17 = trunc i64 %16 to i32
%18 = tail call i32 @srand(i32 %17)
%19 = tail call i32 @randomiseRange(i32* %10, i32 32, i32 96)
%20 = tail call i32 @randomiseRange(i32* %10, i32 160, i32 80)
%21 = tail call i32 @randomiseRange(i32* %10, i32 288, i32 80)
%22 = tail call i32 @fclose(i32* %10)
br label %23
23: ; preds = %15, %12, %4
%24 = phi i32 [ 1, %4 ], [ 0, %15 ], [ 1, %12 ]
ret i32 %24
}