#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 ceil(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int fromstart, fromend, totaltime;
  int starthr, startmin, endhr, endmin;
  printf("Enter a start time: ");
  scanf("%d %d", &starthr, &startmin);
  printf("Enter a end time: ");
  scanf("%d %d", &endhr, &endmin);
  if (starthr < 1 || starthr > 12 || startmin < 0 || startmin > 59 ||
      endhr < 1 || endhr > 12 || endmin < 0 || endmin > 59) {
    printf("ERROR: incorrect time notation");
  } else {
    if (starthr >= 6 && starthr <= 11)
      fromstart = starthr * 60 + startmin - 6 * 60;
    else if (starthr == 12)
      fromstart = startmin + 6 * 60;
    else
      fromstart = starthr * 60 + startmin + 6 * 60;
    if (endhr < 6)
      endhr += 12;
    fromend = (12 * 60 + 5 * 60 + 59) - endhr * 60 - endmin;
    totaltime = (6 * 60 + 5 * 60 + 59) - fromend - fromstart;
    totaltime < 0 ? printf("ERROR: End time preceeds start time.")
                  : printf("The babysitting charge is: $%.2f",
                           ceil((totaltime / 60.0) * 4.5));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <scanf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jl     11d3 <main+0xa3>
cmpl   $0xc,-0x14(%rbp)
jg     11d3 <main+0xa3>
cmpl   $0x0,-0x18(%rbp)
jl     11d3 <main+0xa3>
cmpl   $0x3b,-0x18(%rbp)
jg     11d3 <main+0xa3>
cmpl   $0x1,-0x1c(%rbp)
jl     11d3 <main+0xa3>
cmpl   $0xc,-0x1c(%rbp)
jg     11d3 <main+0xa3>
cmpl   $0x0,-0x20(%rbp)
jl     11d3 <main+0xa3>
cmpl   $0x3b,-0x20(%rbp)
jle    11e6 <main+0xb6>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bf <main+0x18f>
cmpl   $0x6,-0x14(%rbp)
jl     120e <main+0xde>
cmpl   $0xb,-0x14(%rbp)
jg     120e <main+0xde>
imul   $0x3c,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
sub    $0x168,%eax
mov    %eax,-0x8(%rbp)
jmp    123c <main+0x10c>
cmpl   $0xc,-0x14(%rbp)
jne    1228 <main+0xf8>
mov    -0x18(%rbp),%eax
add    $0x168,%eax
mov    %eax,-0x8(%rbp)
jmp    1237 <main+0x107>
imul   $0x3c,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x168,%eax
mov    %eax,-0x8(%rbp)
jmp    123c <main+0x10c>
cmpl   $0x6,-0x1c(%rbp)
jge    124f <main+0x11f>
mov    -0x1c(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x1c(%rbp)
imul   $0x3c,-0x1c(%rbp),%ecx
mov    $0x437,%eax
sub    %ecx,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x2cf,%eax
sub    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    128b <main+0x15b>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bf <main+0x18f>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xd70(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
lea    0xdca(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedb(%rip),%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0xd(%rsi),%eax
cmp    $0xfffffff4,%eax
jb     11c6 <main+0x96>
mov    0x8(%rsp),%edx
test   %edx,%edx
js     11c6 <main+0x96>
cmp    $0x3b,%edx
jg     11c6 <main+0x96>
mov    (%rsp),%ecx
test   %ecx,%ecx
jle    11c6 <main+0x96>
cmp    $0xc,%ecx
jg     11c6 <main+0x96>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     11c6 <main+0x96>
cmp    $0x3c,%eax
jge    11c6 <main+0x96>
lea    -0x6(%rsi),%edi
cmp    $0x5,%edi
ja     11cf <main+0x9f>
imul   $0xffffffc4,%esi,%esi
sub    %edx,%esi
add    $0x168,%esi
cmp    $0x5,%ecx
jbe    11f2 <main+0xc2>
jmp    11f8 <main+0xc8>
lea    0xe71(%rip),%rdi
jmp    123a <main+0x10a>
cmp    $0xc,%esi
jne    11e2 <main+0xb2>
mov    $0xfffffe98,%esi
sub    %edx,%esi
cmp    $0x5,%ecx
jbe    11f2 <main+0xc2>
jmp    11f8 <main+0xc8>
imul   $0xffffffc4,%esi,%esi
sub    %edx,%esi
add    $0xfffffe98,%esi
cmp    $0x5,%ecx
ja     11f8 <main+0xc8>
add    $0xc,%ecx
mov    %ecx,(%rsp)
imul   $0x3c,%ecx,%ecx
add    %esi,%eax
add    %ecx,%eax
add    $0xfffffe98,%eax
js     1233 <main+0x103>
cvtsi2sd %eax,%xmm0
divsd  0xdee(%rip),%xmm0
mulsd  0xdee(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1241 <main+0x111>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter a start time: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [19 x i8] c"Enter a end time: \00"
@.str.3 = [31 x i8] c"ERROR: incorrect time notation\00"
@.str.4 = [37 x i8] c"ERROR: End time preceeds start time.\00"
@.str.5 = [33 x i8] c"The babysitting charge is: $%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 1
br i1 %14, label %36, label %15
15: ; preds = %0
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 12
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 59
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 1
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 12
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %8
%35 = icmp sgt i32 %34, 59
br i1 %35, label %36, label %38
36: ; preds = %33, %30, %27, %24, %21, %18, %15, %0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %93
38: ; preds = %33
%39 = load i32, i32* %5
%40 = icmp sge i32 %39, 6
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp sle i32 %42, 11
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* %5
%46 = mul nsw i32 %45, 60
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
%49 = sub nsw i32 %48, 360
store i32 %49, i32* %2
br label %63
50: ; preds = %41, %38
%51 = load i32, i32* %5
%52 = icmp eq i32 %51, 12
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 360
store i32 %55, i32* %2
br label %62
56: ; preds = %50
%57 = load i32, i32* %5
%58 = mul nsw i32 %57, 60
%59 = load i32, i32* %6
%60 = add nsw i32 %58, %59
%61 = add nsw i32 %60, 360
store i32 %61, i32* %2
br label %62
62: ; preds = %56, %53
br label %63
63: ; preds = %62, %44
%64 = load i32, i32* %7
%65 = icmp slt i32 %64, 6
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 12
store i32 %68, i32* %7
br label %69
69: ; preds = %66, %63
%70 = load i32, i32* %7
%71 = mul nsw i32 %70, 60
%72 = sub nsw i32 1079, %71
%73 = load i32, i32* %8
%74 = sub nsw i32 %72, %73
store i32 %74, i32* %3
%75 = load i32, i32* %3
%76 = sub nsw i32 719, %75
%77 = load i32, i32* %2
%78 = sub nsw i32 %76, %77
store i32 %78, i32* %4
%79 = load i32, i32* %4
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %69
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %91
83: ; preds = %69
%84 = load i32, i32* %4
%85 = sitofp i32 %84 to double
%86 = fdiv double %85, 6.000000e+01
%87 = fmul double %86, 4.500000e+00
%88 = fptosi double %87 to i32
%89 = call double @ceil(i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %89)
br label %91
91: ; preds = %83, %81
%92 = phi i32 [ %82, %81 ], [ %90, %83 ]
br label %93
93: ; preds = %91, %36
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter a start time: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [19 x i8] c"Enter a end time: \00"
@.str.3 = [31 x i8] c"ERROR: incorrect time notation\00"
@.str.4 = [37 x i8] c"ERROR: End time preceeds start time.\00"
@.str.5 = [33 x i8] c"The babysitting charge is: $%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%13 = load i32, i32* %1
%14 = add i32 %13, -13
%15 = icmp ult i32 %14, -12
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 0
%18 = select i1 %15, i1 true, i1 %17
%19 = icmp sgt i32 %16, 59
%20 = select i1 %18, i1 true, i1 %19
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 1
%23 = select i1 %20, i1 true, i1 %22
%24 = icmp sgt i32 %21, 12
%25 = select i1 %23, i1 true, i1 %24
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
%29 = icmp sgt i32 %26, 59
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %69
33: ; preds = %0
%34 = add nsw i32 %13, -6
%35 = icmp ult i32 %34, 6
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = mul nsw i32 %13, -60
%38 = sub nuw nsw i32 360, %16
%39 = add nsw i32 %38, %37
br label %48
40: ; preds = %33
%41 = icmp eq i32 %13, 12
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = sub nuw nsw i32 -360, %16
br label %48
44: ; preds = %40
%45 = mul nsw i32 %13, -60
%46 = sub nuw nsw i32 -360, %16
%47 = add nsw i32 %46, %45
br label %48
48: ; preds = %42, %44, %36
%49 = phi i32 [ %39, %36 ], [ %43, %42 ], [ %47, %44 ]
%50 = icmp ult i32 %21, 6
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = add nuw nsw i32 %21, 12
store i32 %52, i32* %3
br label %53
53: ; preds = %51, %48
%54 = phi i32 [ %52, %51 ], [ %21, %48 ]
%55 = mul nuw nsw i32 %54, 60
%56 = add nuw nsw i32 %26, -360
%57 = add nsw i32 %56, %49
%58 = add nsw i32 %57, %55
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %69
62: ; preds = %53
%63 = sitofp i32 %58 to double
%64 = fdiv double %63, 6.000000e+01
%65 = fmul double %64, 4.500000e+00
%66 = fptosi double %65 to i32
%67 = call double @ceil(i32 %66)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %67)
br label %69
69: ; preds = %60, %62, %31
ret i32 0
}