#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 *);
int main(void) {
  int hrs, mins;
  printf("Enter a 24-hour time: ");
  scanf("%d:%d", &hrs, &mins);
  if (hrs > 0 && hrs <= 12 && (mins >= 0 && mins < 60)) {
    printf("Equivalent 12-hour time: %d:%.2d AM\n", hrs, mins);
  } else if (hrs == 0 && (mins >= 0 && mins < 60)) {
    printf("Equivalent 12-hour time: %d:%.2d AM\n", hrs + 12, mins);
  } else if (hrs > 12 && hrs <= 24 && (mins >= 0 && mins < 60)) {
    printf("Equivalent 12-hour time: %d:%.2d PM\n", hrs - 12, mins);
  } else {
    printf("Not a valid time\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1192 <main+0x72>
cmpl   $0xc,-0x8(%rbp)
jg     1192 <main+0x72>
cmpl   $0x0,-0xc(%rbp)
jl     1192 <main+0x72>
cmpl   $0x3c,-0xc(%rbp)
jge    1192 <main+0x72>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <main+0x108>
cmpl   $0x0,-0x8(%rbp)
jne    11cc <main+0xac>
cmpl   $0x0,-0xc(%rbp)
jl     11cc <main+0xac>
cmpl   $0x3c,-0xc(%rbp)
jge    11cc <main+0xac>
mov    -0x8(%rbp),%esi
add    $0xc,%esi
mov    -0xc(%rbp),%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <main+0x103>
cmpl   $0xc,-0x8(%rbp)
jle    1210 <main+0xf0>
cmpl   $0x18,-0x8(%rbp)
jg     1210 <main+0xf0>
cmpl   $0x0,-0xc(%rbp)
jl     1210 <main+0xf0>
cmpl   $0x3c,-0xc(%rbp)
jge    1210 <main+0xf0>
mov    -0x8(%rbp),%esi
sub    $0xc,%esi
mov    -0xc(%rbp),%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <main+0xfe>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <main+0x103>
jmp    1228 <main+0x108>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    -0x1(%rsi),%eax
mov    (%rsp),%edx
cmp    $0xb,%eax
ja     1174 <main+0x44>
test   %edx,%edx
js     1174 <main+0x44>
cmp    $0x3b,%edx
jg     1174 <main+0x44>
lea    0xeab(%rip),%rdi
jmp    11aa <main+0x7a>
test   %esi,%esi
jne    118f <main+0x5f>
test   %edx,%edx
js     118f <main+0x5f>
cmp    $0x3b,%edx
jg     118f <main+0x5f>
lea    0xe95(%rip),%rdi
mov    $0xc,%esi
jmp    11aa <main+0x7a>
lea    -0xd(%rsi),%eax
cmp    $0xb,%eax
ja     11b5 <main+0x85>
test   %edx,%edx
js     11b5 <main+0x85>
cmp    $0x3b,%edx
jg     11b5 <main+0x85>
add    $0xfffffff4,%esi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
jmp    11b1 <main+0x81>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter a 24-hour time: \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [37 x i8] c"Equivalent 12-hour time: %d:%.2d AM\0A\00"
@.str.3 = [37 x i8] c"Equivalent 12-hour time: %d:%.2d PM\0A\00"
@.str.4 = [18 x i8] c"Not a valid time\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 12
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 60
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
br label %56
21: ; preds = %14, %11, %8, %0
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 60
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 12
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33)
br label %55
35: ; preds = %27, %24, %21
%36 = load i32, i32* %2
%37 = icmp sgt i32 %36, 12
br i1 %37, label %38, label %52
38: ; preds = %35
%39 = load i32, i32* %2
%40 = icmp sle i32 %39, 24
br i1 %40, label %41, label %52
41: ; preds = %38
%42 = load i32, i32* %3
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %41
%45 = load i32, i32* %3
%46 = icmp slt i32 %45, 60
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* %2
%49 = sub nsw i32 %48, 12
%50 = load i32, i32* %3
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50)
br label %54
52: ; preds = %44, %41, %38, %35
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %52, %47
br label %55
55: ; preds = %54, %30
br label %56
56: ; preds = %55, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter a 24-hour time: \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [37 x i8] c"Equivalent 12-hour time: %d:%.2d AM\0A\00"
@.str.3 = [37 x i8] c"Equivalent 12-hour time: %d:%.2d PM\0A\00"
@str = [17 x i8] c"Not a valid time\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = add i32 %7, -1
%9 = icmp ult i32 %8, 12
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, -1
%12 = select i1 %9, i1 %11, i1 false
%13 = icmp slt i32 %10, 60
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %10)
br label %33
17: ; preds = %0
%18 = icmp eq i32 %7, 0
%19 = select i1 %18, i1 %11, i1 false
%20 = select i1 %19, i1 %13, i1 false
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 %10)
br label %33
23: ; preds = %17
%24 = add i32 %7, -13
%25 = icmp ult i32 %24, 12
%26 = select i1 %25, i1 %11, i1 false
%27 = select i1 %26, i1 %13, i1 false
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = add nsw i32 %7, -12
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %10)
br label %33
31: ; preds = %23
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %21, %31, %28, %15
ret i32 0
}