#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*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int, int, double);
int scanf(char *, int *, int *, float *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int dl = 0, dlmiss = -1;
  int res, lastv;
  int value, num;
  float prob, lastp = 0;
  if (argc > 1) {
    dl = atoi(argv[1]);
  }
  if (dl <= 0) {
    fprintf(stderr, "Please provide a deadline!\n");
  }
  while (!feof(stdin)) {
    res = scanf("%d %d %f\n", &value, &num, &prob);
    if (res == 3) {
      if ((value > dl) && (dlmiss == -1)) {
        dlmiss = lastv;
        fprintf(stderr, "Dl miss probability: %f\n", 1 - lastp);
      }
      lastv = num;
      lastp = prob;
    }
  }
  if (dlmiss == -1) {
    dlmiss = lastv;
  }
  printf("Miss: 1 - %d / %d = %f\n", dlmiss, lastv,
         1.0 - ((double)dlmiss / (double)lastv));
  return 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)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1196 <main+0x46>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11b7 <main+0x67>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11bc <main+0x6c>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11df <main+0x8f>
jmp    125d <main+0x10d>
lea    0xe42(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1060 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jne    1258 <main+0x108>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1248 <main+0xf8>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1248 <main+0xf8>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
movss  0xdd7(%rip),%xmm0
subss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf1(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    11bc <main+0x6c>
cmpl   $0xffffffff,-0x18(%rbp)
jne    126d <main+0x11d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
cvtsi2sdl -0x18(%rbp),%xmm1
cvtsi2sdl -0x20(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd77(%rip),%xmm0
subsd  %xmm1,%xmm0
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jl     117c <main+0x2c>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jg     1193 <main+0x43>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
mov    $0xffffffff,%ebx
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe76(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%r14
jmp    11f2 <main+0xa2>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%ebp
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
test   %eax,%eax
jne    1244 <main+0xf4>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
call   1060 <scanf@plt>
cmp    $0x3,%eax
jne    11e0 <main+0x90>
mov    0x4(%rsp),%eax
cmp    %eax,0x14(%rsp)
jle    11d0 <main+0x80>
cmp    $0xffffffff,%ebx
jne    11d0 <main+0x80>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
movss  0xdd8(%rip),%xmm0
subss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfd(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    %ebp,%ebx
jmp    11d0 <main+0x80>
cmp    $0xffffffff,%ebx
cmove  %ebp,%ebx
cvtsi2sd %ebx,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm1
movsd  0xda7(%rip),%xmm0
subsd  %xmm1,%xmm0
lea    0xde3(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Please provide a deadline!\0A\00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"%d %d %f\0A\00"
@.str.2 = [25 x i8] c"Dl miss probability: %f\0A\00"
@.str.3 = [24 x i8] c"Miss: 1 - %d / %d = %f\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 i32
%11 = alloca i32
%12 = alloca float
%13 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 -1, i32* %7
store float 0.000000e+00, float* %13
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
br label %21
21: ; preds = %16, %2
%22 = load i32, i32* %6
%23 = icmp sle i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %54, %27
%29 = load i32, i32* @stdin
%30 = call i32 @feof(i32 %29)
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %33, label %55
33: ; preds = %28
%34 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11, float* %12)
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %54
37: ; preds = %33
%38 = load i32, i32* %10
%39 = load i32, i32* %6
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %51
41: ; preds = %37
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %51
44: ; preds = %41
%45 = load i32, i32* %9
store i32 %45, i32* %7
%46 = load i32, i32* @stderr
%47 = load float, float* %13
%48 = fsub float 1.000000e+00, %47
%49 = fpext float %48 to double
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %49)
br label %51
51: ; preds = %44, %41, %37
%52 = load i32, i32* %11
store i32 %52, i32* %9
%53 = load float, float* %12
store float %53, float* %13
br label %54
54: ; preds = %51, %33
br label %28
55: ; preds = %28
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = load i32, i32* %9
store i32 %59, i32* %7
br label %60
60: ; preds = %58, %55
%61 = load i32, i32* %7
%62 = load i32, i32* %9
%63 = load i32, i32* %7
%64 = sitofp i32 %63 to double
%65 = load i32, i32* %9
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = fsub double 1.000000e+00, %67
%69 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %61, i32 %62, double %68)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Please provide a deadline!\0A\00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"%d %d %f\0A\00"
@.str.2 = [25 x i8] c"Dl miss probability: %f\0A\00"
@.str.3 = [24 x i8] c"Miss: 1 - %d / %d = %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast float* %5 to i8*
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %2, %10
%16 = phi i32 [ %13, %10 ], [ 0, %2 ]
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %15, %10
%20 = phi i32 [ %16, %15 ], [ %13, %10 ]
%21 = load i32, i32* @stdin
%22 = call i32 @feof(i32 %21)
%23 = icmp eq i32 %22, 0
br label %24
24: ; preds = %19, %44
%25 = phi float [ %47, %44 ], [ 0.000000e+00, %19 ]
%26 = phi i32 [ %46, %44 ], [ undef, %19 ]
%27 = phi i32 [ %45, %44 ], [ -1, %19 ]
%28 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, float* %5)
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %44
30: ; preds = %24
%31 = load i32, i32* %3
%32 = icmp sgt i32 %31, %20
%33 = icmp eq i32 %27, -1
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = fsub float 1.000000e+00, %25
%38 = fpext float %37 to double
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %38)
br label %40
40: ; preds = %35, %30
%41 = phi i32 [ %26, %35 ], [ %27, %30 ]
%42 = load i32, i32* %4
%43 = load float, float* %5
br label %44
44: ; preds = %40, %24
%45 = phi i32 [ %41, %40 ], [ %27, %24 ]
%46 = phi i32 [ %42, %40 ], [ %26, %24 ]
%47 = phi float [ %43, %40 ], [ %25, %24 ]
%48 = load i32, i32* @stdin
%49 = call i32 @feof(i32 %48)
%50 = icmp eq i32 %49, 0
br i1 %50, label %24, label %51
51: ; preds = %44
%52 = icmp eq i32 %45, -1
%53 = select i1 %52, i32 %46, i32 %45
%54 = sitofp i32 %53 to double
%55 = sitofp i32 %46 to double
%56 = fdiv double %54, %55
%57 = fsub double 1.000000e+00, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 %46, double %57)
ret i32 0
}