#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_s(char *, int *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int n, m;
  printf("Enter a 24-hour time:");
  scanf_s("%d:%d", &n, &m);
  if (n < 0) {
    printf("Error1!\n");
    system("PAUSE");
    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("Error2!\n");
    system("PAUSE");
    return 2;
  }
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf_s@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1191 <main+0x61>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1030 <system@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xfd>
cmpl   $0xc,-0x8(%rbp)
jge    11b4 <main+0x84>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
cmpl   $0xc,-0x8(%rbp)
jl     11ea <main+0xba>
cmpl   $0x18,-0x8(%rbp)
jge    11ea <main+0xba>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1210 <main+0xe0>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe26(%rip),%rdi
call   1030 <system@plt>
movl   $0x2,-0x4(%rbp)
jmp    122d <main+0xfd>
jmp    1215 <main+0xe5>
jmp    121a <main+0xea>
lea    0xe04(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf_s@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
js     1183 <main+0x43>
cmp    $0xb,%esi
ja     1196 <main+0x56>
mov    0x8(%rsp),%edx
lea    0xea1(%rip),%rdi
jmp    11ad <main+0x6d>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    11c9 <main+0x89>
cmp    $0x17,%esi
ja     11b8 <main+0x78>
add    $0xfffffff4,%esi
mov    %esi,0xc(%rsp)
mov    0x8(%rsp),%edx
lea    0xe9a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c9 <main+0x89>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
lea    0xe4c(%rip),%rdi
call   1040 <system@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [22 x i8] c"Enter a 24-hour time:\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.3 = [6 x i8] c"PAUSE\00"
@.str.4 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d AM\0A\00"
@.str.5 = [37 x i8] c"Equivalent 12-hour time: %2d:%2d PM\0A\00"
@str = [8 x i8] c"Error2!\00"
@str.7 = [8 x i8] c"Error1!\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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf_s(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 ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
br label %24
11: ; preds = %0
%12 = icmp ult i32 %7, 12
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.4, 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.5, i64 0, i64 0), i32 %19, i32 %20)
br label %24
22: ; preds = %16
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %18, %13, %22, %9
%25 = phi i32 [ 1, %9 ], [ 2, %22 ], [ 0, %13 ], [ 0, %18 ]
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 %25
}