#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atof(char *);
int /*<<< orphan*/ busy_sleep(char *, long);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
long rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  long runtime = (long)(atof(argv[1]) * 100);
  double fail_prob = atof(argv[2]);
  if (runtime >= 300)
    runtime -= 150;
  else
    runtime -= 100;
  srand((unsigned int)time(NULL));
  printf("\t[%s] started.\n", argv[0]);
  if (rand() % 100 <= fail_prob * 100) {
    runtime = rand() % runtime;
    busy_sleep(argv[0], runtime);
    printf("\t[%s] failed (after %.2fs).\n", argv[0], (double)runtime / 100);
    exit(EXIT_FAILURE);
  } else {
    busy_sleep(argv[0], runtime);
    printf("\t[%s] succeed.\n", argv[0]);
    exit(EXIT_SUCCESS);
  }
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
imul   $0x64,%eax,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x12c,-0x18(%rbp)
jl     11d3 <main+0x63>
mov    -0x18(%rbp),%rax
sub    $0x96,%rax
mov    %rax,-0x18(%rbp)
jmp    11df <main+0x6f>
mov    -0x18(%rbp),%rax
sub    $0x64,%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cqto
idiv   %rcx
cvtsi2sd %rdx,%xmm1
movsd  0xdde(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1287 <main+0x117>
mov    $0x0,%al
call   1090 <rand@plt>
cqto
idivq  -0x18(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <busy_sleep@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xd99(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xda6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <busy_sleep@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
imul   $0x64,%eax,%eax
movslq %eax,%rbx
mov    0x10(%r14),%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    -0x64(%rbx),%r15
lea    -0x96(%rbx),%rax
cmp    $0x12c,%ebx
cmovge %rax,%r15
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    (%r14),%rsi
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rax,%rcx
movabs $0xa3d70a3d70a3d70b,%rdx
0a d7 a3
imul   %rdx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
imul   $0x64,%rdx,%rax
sub    %rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xde9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1247 <main+0xd7>
mov    (%r14),%rdi
mov    %r15,%rsi
call   1070 <busy_sleep@plt>
mov    (%r14),%rsi
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rax,%rcx
or     %r15,%rcx
shr    $0x20,%rcx
jne    1263 <main+0xf3>
xor    %edx,%edx
div    %r15d
mov    %edx,%ebx
jmp    126b <main+0xfb>
cqto
idiv   %r15
mov    %rdx,%rbx
mov    (%r14),%rdi
mov    %rbx,%rsi
call   1070 <busy_sleep@plt>
mov    (%r14),%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
divsd  0xd77(%rip),%xmm0
lea    0xd88(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"\09[%s] started.\0A\00"
@.str.1 = [29 x i8] c"\09[%s] failed (after %.2fs).\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [16 x i8] c"\09[%s] succeed.\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 i64
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atof(i8* %10)
%12 = mul nsw i32 %11, 100
%13 = sext i32 %12 to i64
store i64 %13, i64* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atof(i8* %16)
%18 = sitofp i32 %17 to double
store double %18, double* %7
%19 = load i64, i64* %6
%20 = icmp sge i64 %19, 300
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i64, i64* %6
%23 = sub nsw i64 %22, 150
store i64 %23, i64* %6
br label %27
24: ; preds = %2
%25 = load i64, i64* %6
%26 = sub nsw i64 %25, 100
store i64 %26, i64* %6
br label %27
27: ; preds = %24, %21
%28 = call i64 @time(i32* null)
%29 = trunc i64 %28 to i32
%30 = call i32 @srand(i32 %29)
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = call i64 (...) @rand()
%36 = srem i64 %35, 100
%37 = sitofp i64 %36 to double
%38 = load double, double* %7
%39 = fmul double %38, 1.000000e+02
%40 = fcmp ole double %37, %39
br i1 %40, label %41, label %59
41: ; preds = %27
%42 = call i64 (...) @rand()
%43 = load i64, i64* %6
%44 = srem i64 %42, %43
store i64 %44, i64* %6
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = load i64, i64* %6
%49 = call i32 @busy_sleep(i8* %47, i64 %48)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = load i64, i64* %6
%54 = sitofp i64 %53 to double
%55 = fdiv double %54, 1.000000e+02
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %52, double %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %27
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 0
%62 = load i8*, i8** %61
%63 = load i64, i64* %6
%64 = call i32 @busy_sleep(i8* %62, i64 %63)
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %67)
%69 = load i32, i32* @EXIT_SUCCESS
%70 = call i32 @exit(i32 %69)
unreachable
}

LLVM IR (-O2):
@.str = [16 x i8] c"\09[%s] started.\0A\00"
@.str.1 = [29 x i8] c"\09[%s] failed (after %.2fs).\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [16 x i8] c"\09[%s] succeed.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atof(i8* %4)
%6 = mul nsw i32 %5, 100
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atof(i8* %9)
%11 = sitofp i32 %10 to double
%12 = icmp sgt i32 %6, 299
%13 = select i1 %12, i64 -150, i64 -100
%14 = add nsw i64 %13, %7
%15 = tail call i64 @time(i32* null)
%16 = trunc i64 %15 to i32
%17 = tail call i32 @srand(i32 %16)
%18 = load i8*, i8** %1
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i64 (...) @rand()
%21 = srem i64 %20, 100
%22 = sitofp i64 %21 to double
%23 = fmul double %11, 1.000000e+02
%24 = fcmp ult double %23, %22
br i1 %24, label %36, label %25
25: ; preds = %2
%26 = tail call i64 (...) @rand()
%27 = srem i64 %26, %14
%28 = load i8*, i8** %1
%29 = tail call i32 @busy_sleep(i8* %28, i64 %27)
%30 = load i8*, i8** %1
%31 = sitofp i64 %27 to double
%32 = fdiv double %31, 1.000000e+02
%33 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %30, double %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %2
%37 = load i8*, i8** %1
%38 = tail call i32 @busy_sleep(i8* %37, i64 %14)
%39 = load i8*, i8** %1
%40 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_SUCCESS
%42 = tail call i32 @exit(i32 %41)
unreachable
}