#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ RAND_MAX;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int,
                           int);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int i;
  FILE *file;
  int duration;
  int walltime;
  int submit_time = 0;
  int nb_proc;
  if (argc != 2) {
    printf("usage: %s <nb_jobs>", argv[0]);
    return EXIT_FAILURE;
  }
  srand(time(NULL));
  file = fopen("load.wld", "w");
  for (i = 0; i < atoi(argv[1]); i++) {
    submit_time += rand() % 401 + 100;
    duration = rand() % 2901 + 100;
    walltime = duration * (1.1 + 1.9 * (rand() / ((double)RAND_MAX + 1)));
    nb_proc = rand() % 5 + 1;
    fprintf(file, "%d\t%d\t%d\t0\t0\t%d\t%d\t0\t0\n", i, submit_time, duration,
            walltime, nb_proc);
  }
  fclose(file);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11cb <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12fd <main+0x17d>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe4a(%rip),%rdi
lea    0xe4c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    12e8 <main+0x168>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x191,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x64,%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0xb55,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mov    0x2d7f(%rip),%rax
cvtsi2sdq (%rax),%xmm2
movsd  0xd9a(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
movsd  0xd7a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd76(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x30(%rbp),%eax
lea    0xd65(%rip),%rsi
mov    %eax,(%rsp)
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f9 <main+0x79>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    12f1 <main+0x171>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe7d(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
mov    0x8(%r14),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    12e0 <main+0x160>
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x28db9c69,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x191,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%ebx
add    $0x64,%ebx
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x5a5d02bd,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2a,%rcx
add    %edx,%ecx
imul   $0xb55,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0x64,%r13d
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x2d8e(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rax),%xmm1
addsd  0xd96(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xd92(%rip),%xmm0
addsd  0xd92(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%r15d
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%rsp)
mov    %r12,%rdi
lea    0xd7a(%rip),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    %r15d,%r9d
call   1060 <fprintf@plt>
add    $0x1,%ebp
mov    0x8(%r14),%rdi
call   1090 <atoi@plt>
cmp    %eax,%ebp
jl     11e0 <main+0x60>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x2ce1(%rip),%rax
jmp    1307 <main+0x187>
mov    (%r14),%rsi
lea    0xd1d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"usage: %s <nb_jobs>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"load.wld\00"
@.str.2 = [2 x i8] c"w\00"
@RAND_MAX = global i64 0
@.str.3 = [24 x i8] c"%d\09%d\09%d\090\090\09%d\09%d\090\090\0A\00"
@EXIT_SUCCESS = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
store i32 %19, i32* %3
br label %68
20: ; preds = %2
%21 = call i32 @time(i32* null)
%22 = call i32 @srand(i32 %21)
%23 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %7
store i32 0, i32* %6
br label %24
24: ; preds = %61, %20
%25 = load i32, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = icmp slt i32 %25, %29
br i1 %30, label %31, label %64
31: ; preds = %24
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 401
%34 = add nsw i32 %33, 100
%35 = load i32, i32* %10
%36 = add nsw i32 %35, %34
store i32 %36, i32* %10
%37 = call i32 (...) @rand()
%38 = srem i32 %37, 2901
%39 = add nsw i32 %38, 100
store i32 %39, i32* %8
%40 = load i32, i32* %8
%41 = sitofp i32 %40 to double
%42 = call i32 (...) @rand()
%43 = sitofp i32 %42 to double
%44 = load i64, i64* @RAND_MAX
%45 = sitofp i64 %44 to double
%46 = fadd double %45, 1.000000e+00
%47 = fdiv double %43, %46
%48 = call double @llvm.fmuladd.f64(double 1.900000e+00, double %47, double 1.100000e+00)
%49 = fmul double %41, %48
%50 = fptosi double %49 to i32
store i32 %50, i32* %9
%51 = call i32 (...) @rand()
%52 = srem i32 %51, 5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
%54 = load i32*, i32** %7
%55 = load i32, i32* %6
%56 = load i32, i32* %10
%57 = load i32, i32* %8
%58 = load i32, i32* %9
%59 = load i32, i32* %11
%60 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %55, i32 %56, i32 %57, i32 %58, i32 %59)
br label %61
61: ; preds = %31
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %24
64: ; preds = %24
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
%67 = load i32, i32* @EXIT_SUCCESS
store i32 %67, i32* %3
br label %68
68: ; preds = %64, %14
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [20 x i8] c"usage: %s <nb_jobs>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"load.wld\00"
@.str.2 = [2 x i8] c"w\00"
@RAND_MAX = global i64 0
@.str.3 = [24 x i8] c"%d\09%d\09%d\090\090\09%d\09%d\090\090\0A\00"
@EXIT_SUCCESS = global i32 0
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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %45
7: ; preds = %2
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %43
15: ; preds = %7, %15
%16 = phi i32 [ %21, %15 ], [ 0, %7 ]
%17 = phi i32 [ %39, %15 ], [ 0, %7 ]
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 401
%20 = add i32 %16, 100
%21 = add i32 %20, %19
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 2901
%24 = add nsw i32 %23, 100
%25 = sitofp i32 %24 to double
%26 = tail call i32 (...) @rand()
%27 = sitofp i32 %26 to double
%28 = load i64, i64* @RAND_MAX
%29 = sitofp i64 %28 to double
%30 = fadd double %29, 1.000000e+00
%31 = fdiv double %27, %30
%32 = tail call double @llvm.fmuladd.f64(double %31, double 1.900000e+00, double 1.100000e+00)
%33 = fmul double %32, %25
%34 = fptosi double %33 to i32
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 5
%37 = add nsw i32 %36, 1
%38 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %21, i32 %24, i32 %34, i32 %37)
%39 = add nuw nsw i32 %17, 1
%40 = load i8*, i8** %11
%41 = tail call i32 @atoi(i8* %40)
%42 = icmp slt i32 %39, %41
br i1 %42, label %15, label %43
43: ; preds = %15, %7
%44 = tail call i32 @fclose(i32* %10)
br label %45
45: ; preds = %43, %4
%46 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %43 ]
%47 = load i32, i32* %46
ret i32 %47
}