#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 hh, mm;
  printf("Enter a 24-hour time: ");
  scanf("%d:%d:", &hh, &mm);
  printf("Equivalent 12-hour time: ");
  if (hh == 0)
    printf("12:%.2d AM\n", mm);
  else if (hh < 12)
    printf("%d:%.2d AM\n", hh, mm);
  else if (hh == 12)
    printf("12:%.2d PM\n", mm);
  else
    printf("%d:%.d PM\n", hh - 12, mm);
  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>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    117f <main+0x5f>
mov    -0xc(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xc3>
cmpl   $0xc,-0x8(%rbp)
jge    11a2 <main+0x82>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0xbe>
cmpl   $0xc,-0x8(%rbp)
jne    11c2 <main+0xa2>
mov    -0xc(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xb9>
mov    -0x8(%rbp),%esi
sub    $0xc,%esi
mov    -0xc(%rbp),%edx
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0xbe>
jmp    11e3 <main+0xc3>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     116a <main+0x4a>
cmp    $0xb,%esi
jg     1176 <main+0x56>
mov    (%rsp),%edx
lea    0xedc(%rip),%rdi
jmp    119b <main+0x7b>
mov    (%rsp),%esi
lea    0xec4(%rip),%rdi
jmp    1185 <main+0x65>
cmp    $0xc,%esi
jne    118e <main+0x6e>
mov    (%rsp),%esi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a2 <main+0x82>
add    $0xfffffff4,%esi
mov    (%rsp),%edx
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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