#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 */
double RAND_MAX;
int /*<<< orphan*/ compute(int);
int getpid();
int /*<<< orphan*/ printf(char *, char *, int, int);
scalar_t__ rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  int i, delay, pid;
  pid = getpid();
  srand(pid);
  delay = 30 + ((double)rand() / RAND_MAX) * 130;
  printf("%s: Starting, NMSG = %d, delay = %d\n", argv[0], 200, delay);
  for (i = 0; i < 200; i++) {
    printf("%s[%d]: This is message %d\n", argv[0], pid, i);
    compute(delay);
  }
  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)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e5d(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe69(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe65(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%ecx
lea    0xe51(%rip),%rdi
mov    $0xc8,%edx
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jge    120c <main+0xbc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <compute@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <main+0x80>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e67(%rip),%rax
divsd  (%rax),%xmm0
mulsd  0xe73(%rip),%xmm0
addsd  0xe73(%rip),%xmm0
cvttsd2si %xmm0,%ebx
mov    (%r14),%rsi
lea    0xe6d(%rip),%rdi
mov    $0xc8,%edx
mov    %ebx,%ecx
call   1040 <printf@plt>
lea    0xe7f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%rsi
mov    %r12,%rdi
mov    %r15d,%edx
mov    %ebp,%ecx
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <compute@plt>
add    $0x1,%ebp
cmp    $0xc8,%ebp
jne    11c0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@.str = [37 x i8] c"%s: Starting, NMSG = %d, delay = %d\0A\00"
@.str.1 = [28 x i8] c"%s[%d]: This is message %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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @getpid()
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = call i32 @srand(i32 %10)
%12 = call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
%16 = call double @llvm.fmuladd.f64(double %15, double 1.300000e+02, double 3.000000e+01)
%17 = fptosi double %16 to i32
store i32 %17, i32* %7
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = load i32, i32* %7
%22 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %20, i32 200, i32 %21)
store i32 0, i32* %6
br label %23
23: ; preds = %35, %2
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 200
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %30, i32 %31)
%33 = load i32, i32* %7
%34 = call i32 @compute(i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %23
38: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [37 x i8] c"%s: Starting, NMSG = %d, delay = %d\0A\00"
@.str.1 = [28 x i8] c"%s[%d]: This is message %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i64 (...) @rand()
%6 = sitofp i64 %5 to double
%7 = load double, double* @RAND_MAX
%8 = fdiv double %6, %7
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.300000e+02, double 3.000000e+01)
%10 = fptosi double %9 to i32
%11 = load i8*, i8** %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %11, i32 200, i32 %10)
br label %13
13: ; preds = %2, %13
%14 = phi i32 [ 0, %2 ], [ %18, %13 ]
%15 = load i8*, i8** %1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %3, i32 %14)
%17 = tail call i32 @compute(i32 %10)
%18 = add nuw nsw i32 %14, 1
%19 = icmp eq i32 %18, 200
br i1 %19, label %20, label %13
20: ; preds = %13
ret i32 0
}