#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 time24hto12h() {
  int n = 0, m = 0;
  printf("Enter a 24-hour time: h:m\n");
  scanf("%d:%d", &n, &m);
  if (n < 0) {
    printf("Input Error1!\n");
    return -1;
  } else if (n <= 12) {
    printf("Equivalent 12-hour time: %2d:%2d AM\n", n, m);
  } else if ((n > 12) && (n < 24)) {
    n -= 12;
    printf("Equivalent 12-hour time: %2d:%2d PM\n", n, m);
  } else {
    printf("Input Error!\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<time24hto12h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    117c <time24hto12h+0x5c>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <time24hto12h+0xe0>
cmpl   $0xc,-0x8(%rbp)
jg     119f <time24hto12h+0x7f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f4 <time24hto12h+0xd4>
cmpl   $0xc,-0x8(%rbp)
jle    11d5 <time24hto12h+0xb5>
cmpl   $0x18,-0x8(%rbp)
jge    11d5 <time24hto12h+0xb5>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ef <time24hto12h+0xcf>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <time24hto12h+0xe0>
jmp    11f4 <time24hto12h+0xd4>
jmp    11f9 <time24hto12h+0xd9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time24hto12h>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
js     1181 <time24hto12h+0x51>
cmp    $0xc,%esi
ja     118a <time24hto12h+0x5a>
mov    0x8(%rsp),%edx
lea    0xe87(%rip),%rdi
jmp    11a1 <time24hto12h+0x71>
lea    0xeef(%rip),%rdi
jmp    11b3 <time24hto12h+0x83>
cmp    $0x17,%esi
ja     11ac <time24hto12h+0x7c>
add    $0xfffffff4,%esi
mov    %esi,0xc(%rsp)
mov    0x8(%rsp),%edx
lea    0xe8a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bd <time24hto12h+0x8d>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter a 24-hour time: h:m\0A\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [15 x i8] c"Input Error1!\0A\00"
@.str.3 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d AM\0A\00"
@.str.4 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d PM\0A\00"
@.str.5 = [14 x i8] c"Input Error!\0A\00"
define i32 @time24hto12h() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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 slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp sle i32 %11, 12
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %15)
br label %32
17: ; preds = %10
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 12
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 24
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 12
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %27)
br label %31
29: ; preds = %20, %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
31: ; preds = %23
br label %32
32: ; preds = %31, %13
br label %33
33: ; preds = %32
store i32 0, i32* %1
br label %34
34: ; preds = %33, %29, %8
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.3 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d AM\0A\00"
@.str.4 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d PM\0A\00"
@str = [26 x i8] c"Enter a 24-hour time: h:m\00"
@str.6 = [13 x i8] c"Input Error!\00"
@str.7 = [14 x i8] c"Input Error1!\00"
define i32 @time24hto12h() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %24
11: ; preds = %0
%12 = icmp ult i32 %7, 13
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %14)
br label %24
16: ; preds = %11
%17 = icmp ult i32 %7, 24
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = add nsw i32 %7, -12
store i32 %19, i32* %1
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %20)
br label %24
22: ; preds = %16
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
br label %24
24: ; preds = %18, %13, %22, %9
%25 = phi i32 [ -1, %9 ], [ -1, %22 ], [ 0, %13 ], [ 0, %18 ]
ret i32 %25
}