#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int timeDay = 0;
  int timeDur;
  int result;
  int digitTens;
  bool checkCorrect = false;
  while ((timeDay > 2400) || (timeDay < 0) || (checkCorrect == false)) {
    checkCorrect = false;
    printf("Please enter the first integer (time of day on a 24 hour clock): ");
    scanf("%d", &timeDay);
    digitTens = (timeDay / 10) % 10;
    if (digitTens <= 5) {
      checkCorrect = true;
    }
  }
  checkCorrect = false;
  while (checkCorrect == false) {
    checkCorrect = false;
    printf("Please enter the second integer (time duration): ");
    scanf("%d", &timeDur);
    digitTens = (timeDur / 10) % 10;
    if ((digitTens <= 5) && (digitTens >= -5)) {
      checkCorrect = true;
    }
  }
  result = timeDay + timeDur;
  result = result % 2400;
  if (result < 0) {
    result = 2400 + result;
  }
  printf("Time of day + time duration is : %.4d", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x1,%al
cmpl   $0x960,-0x8(%rbp)
mov    %al,-0x19(%rbp)
jg     1168 <main+0x48>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x19(%rbp)
jl     1168 <main+0x48>
cmpl   $0x0,-0x18(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1178 <main+0x58>
jmp    11c9 <main+0xa9>
movl   $0x0,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     11c4 <main+0xa4>
movl   $0x1,-0x18(%rbp)
jmp    113d <main+0x1d>
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1235 <main+0x115>
movl   $0x0,-0x18(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     1230 <main+0x110>
cmpl   $0xfffffffb,-0x14(%rbp)
jl     1230 <main+0x110>
movl   $0x1,-0x18(%rbp)
jmp    11d0 <main+0xb0>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x960,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1261 <main+0x141>
mov    -0x10(%rbp),%eax
add    $0x960,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
lea    0xec8(%rip),%r14
lea    0xf03(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq 0x8(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
cmp    $0x5,%ecx
jg     1150 <main+0x30>
cmp    $0x960,%eax
ja     1150 <main+0x30>
lea    0xe96(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
add    $0xfffffffa,%ecx
cmp    $0xfffffff5,%ecx
jb     11c0 <main+0xa0>
add    0x8(%rsp),%eax
cltq
imul   $0x1b4e81b5,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x28,%rcx
add    %edx,%ecx
imul   $0x960,%ecx,%ecx
sub    %ecx,%eax
lea    0x960(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Please enter the first integer (time of day on a 24 hour clock): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [50 x i8] c"Please enter the second integer (time duration): \00"
@.str.3 = [38 x i8] c"Time of day + time duration is : %.4d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %6
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 2400
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
br label %16
16: ; preds = %13, %10, %7
%17 = phi i1 [ true, %10 ], [ true, %7 ], [ %15, %13 ]
br i1 %17, label %18, label %28
18: ; preds = %16
store i32 0, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 10
%23 = srem i32 %22, 10
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 5
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 1, i32* %6
br label %27
27: ; preds = %26, %18
br label %7
28: ; preds = %16
store i32 0, i32* %6
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %29
store i32 0, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%35 = load i32, i32* %3
%36 = sdiv i32 %35, 10
%37 = srem i32 %36, 10
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = icmp sle i32 %38, 5
br i1 %39, label %40, label %44
40: ; preds = %32
%41 = load i32, i32* %5
%42 = icmp sge i32 %41, -5
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 1, i32* %6
br label %44
44: ; preds = %43, %40, %32
br label %29
45: ; preds = %29
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = add nsw i32 %46, %47
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = srem i32 %49, 2400
store i32 %50, i32* %4
%51 = load i32, i32* %4
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %45
%54 = load i32, i32* %4
%55 = add nsw i32 2400, %54
store i32 %55, i32* %4
br label %56
56: ; preds = %53, %45
%57 = load i32, i32* %4
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %57)
ret i32 0
}

LLVM IR (-O2):
@.str = [66 x i8] c"Please enter the first integer (time of day on a 24 hour clock): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [50 x i8] c"Please enter the second integer (time duration): \00"
@.str.3 = [38 x i8] c"Time of day + time duration is : %.4d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = sdiv i32 %8, 10
%10 = srem i32 %9, 10
%11 = icmp sgt i32 %10, 5
%12 = icmp ugt i32 %8, 2400
%13 = or i1 %11, %12
br i1 %13, label %5, label %14
14: ; preds = %5, %14
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 10
%19 = srem i32 %18, 10
%20 = add nsw i32 %19, -6
%21 = icmp ult i32 %20, -11
br i1 %21, label %14, label %22
22: ; preds = %14
%23 = load i32, i32* %1
%24 = add nsw i32 %17, %23
%25 = srem i32 %24, 2400
%26 = icmp slt i32 %25, 0
%27 = add nsw i32 %25, 2400
%28 = select i1 %26, i32 %27, i32 %25
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i32 0
}