#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ generate_arrival_interval();
int generate_priority(float);
float generate_task_length();
int /*<<< orphan*/ printf(char *, int, int, float, int);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i;
  if (argc < 3) {
    fprintf(stderr, "usage: %s <number of tasks> <random seed>\n", argv[0]);
    exit(1);
  }
  int num_tasks = atoi(argv[1]);
  int random_seed = atoi(argv[2]);
  srand(random_seed);
  int task_arrival_time = 0;
  float task_length = 0.0;
  int task_priority = 0;
  for (i = 0; i < num_tasks; i++) {
    task_arrival_time += generate_arrival_interval();
    task_length = generate_task_length();
    task_priority = generate_priority(task_length);
    printf("%d %d %.1f %d\n", i, task_arrival_time, task_length, task_priority);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c6 <main+0x46>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <srand@plt>
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    126c <main+0xec>
mov    $0x0,%al
call   1080 <generate_arrival_interval@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <generate_task_length@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
call   1070 <generate_priority@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
movss  -0x24(%rbp),%xmm0
mov    -0x28(%rbp),%ecx
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120b <main+0x8b>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     11b1 <main+0x31>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe5e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %r15d,%r15d
jle    121b <main+0x9b>
lea    0xe52(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   (%rax)
xor    %eax,%eax
call   1080 <generate_arrival_interval@plt>
movslq %ebx,%rbx
add    %rax,%rbx
xor    %eax,%eax
call   1040 <generate_task_length@plt>
movss  %xmm0,0x4(%rsp)
call   1070 <generate_priority@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
movss  0x4(%rsp),%xmm0
mov    %eax,%ecx
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    11e0 <main+0x60>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"usage: %s <number of tasks> <random seed>\0A\00"
@.str.1 = [15 x i8] c"%d %d %.1f %d\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 float
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %18)
%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* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = call i32 @srand(i32 %30)
store i32 0, i32* %9
store float 0.000000e+00, float* %10
store i32 0, i32* %11
store i32 0, i32* %6
br label %32
32: ; preds = %50, %21
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %53
36: ; preds = %32
%37 = call i64 (...) @generate_arrival_interval()
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = add nsw i64 %39, %37
%41 = trunc i64 %40 to i32
store i32 %41, i32* %9
%42 = call float (...) @generate_task_length()
store float %42, float* %10
%43 = load float, float* %10
%44 = call i32 @generate_priority(float %43)
store i32 %44, i32* %11
%45 = load i32, i32* %6
%46 = load i32, i32* %9
%47 = load float, float* %10
%48 = load i32, i32* %11
%49 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %46, float %47, i32 %48)
br label %50
50: ; preds = %36
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %32
53: ; preds = %32
%54 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"usage: %s <number of tasks> <random seed>\0A\00"
@.str.1 = [15 x i8] c"%d %d %.1f %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i32 @srand(i32 %15)
%17 = icmp sgt i32 %12, 0
br i1 %17, label %18, label %31
18: ; preds = %9, %18
%19 = phi i64 [ %24, %18 ], [ 0, %9 ]
%20 = phi i32 [ %29, %18 ], [ 0, %9 ]
%21 = tail call i64 (...) @generate_arrival_interval()
%22 = shl i64 %19, 32
%23 = ashr exact i64 %22, 32
%24 = add nsw i64 %21, %23
%25 = trunc i64 %24 to i32
%26 = tail call float (...) @generate_task_length()
%27 = tail call i32 @generate_priority(float %26)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %25, float %26, i32 %27)
%29 = add nuw nsw i32 %20, 1
%30 = icmp eq i32 %29, %12
br i1 %30, label %31, label %18
31: ; preds = %18, %9
%32 = tail call i32 @exit(i32 0)
unreachable
}