#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 secondsSinceTwelve(int, int, int);
int main() {
  int hours, minutes, seconds;
  int result;
  printf("Enter hours: ");
  scanf("%d", &hours);
  if (hours < 0 || hours > 23) {
    printf("Invalid value for hours entered!\n");
    return -1;
  }
  printf("Enter minutes: ");
  scanf("%d", &minutes);
  if (minutes < 0 || minutes > 59) {
    printf("Invalid value for minutes entered!\n");
    return -1;
  }
  printf("Enter seconds: ");
  scanf("%d", &seconds);
  if (seconds < 0 || seconds > 59) {
    printf("Invalid value for seconds entered!\n");
    return -1;
  }
  result = secondsSinceTwelve(hours, minutes, seconds);
  printf("It has been %d seconds since 12 O'clock.\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1171 <main+0x41>
cmpl   $0x17,-0x8(%rbp)
jle    118b <main+0x5b>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    124c <main+0x11c>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x3b,-0xc(%rbp)
jle    11d7 <main+0xa7>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    124c <main+0x11c>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe22(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jl     1209 <main+0xd9>
cmpl   $0x3b,-0x10(%rbp)
jle    1223 <main+0xf3>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    124c <main+0x11c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <secondsSinceTwelve@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x18,0x8(%rsp)
jb     1174 <main+0x34>
lea    0xf2f(%rip),%rdi
jmp    11d4 <main+0x94>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x3c,0x4(%rsp)
jb     11a3 <main+0x63>
lea    0xedd(%rip),%rdi
jmp    11d4 <main+0x94>
lea    0xe77(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
cmp    $0x3c,%edx
jb     11e6 <main+0xa6>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <secondsSinceTwelve@plt>
lea    0xe37(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11de <main+0x9e>

LLVM IR (-O0):
@.str = [14 x i8] c"Enter hours: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Invalid value for hours entered!\0A\00"
@.str.3 = [16 x i8] c"Enter minutes: \00"
@.str.4 = [36 x i8] c"Invalid value for minutes entered!\0A\00"
@.str.5 = [16 x i8] c"Enter seconds: \00"
@.str.6 = [36 x i8] c"Invalid value for seconds entered!\0A\00"
@.str.7 = [42 x i8] c"It has been %d seconds since 12 O'clock.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 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* %2)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 23
br i1 %12, label %13, label %15
13: ; preds = %10, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %42
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 59
br i1 %22, label %23, label %25
23: ; preds = %20, %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %42
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 59
br i1 %32, label %33, label %35
33: ; preds = %30, %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %1
br label %42
35: ; preds = %30
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = call i32 @secondsSinceTwelve(i32 %36, i32 %37, i32 %38)
store i32 %39, i32* %5
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %40)
store i32 0, i32* %1
br label %42
42: ; preds = %35, %33, %23, %13
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter hours: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"Enter minutes: \00"
@.str.5 = [16 x i8] c"Enter seconds: \00"
@.str.7 = [42 x i8] c"It has been %d seconds since 12 O'clock.\0A\00"
@str = [35 x i8] c"Invalid value for seconds entered!\00"
@str.8 = [35 x i8] c"Invalid value for minutes entered!\00"
@str.9 = [33 x i8] c"Invalid value for hours entered!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp ugt i32 %9, 23
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
br label %32
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp ugt i32 %16, 59
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
br label %32
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = icmp ugt i32 %23, 59
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %32
27: ; preds = %20
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @secondsSinceTwelve(i32 %28, i32 %29, i32 %23)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %27, %25, %18, %11
%33 = phi i32 [ -1, %11 ], [ -1, %18 ], [ -1, %25 ], [ 0, %27 ]
ret i32 %33
}