#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() {
  int hours = 0;
  int minutes = 0;
  char *am = "AM";
  char *pm = "PM";
  char *abbreviation = "";
  printf("Enter a 24-hour time: ");
  scanf("%d:%d", &hours, &minutes);
  if (hours == 0) {
    hours = 12;
    abbreviation = am;
  } else if (hours < 12) {
    abbreviation = am;
  } else if (hours == 12) {
    abbreviation = pm;
  } else {
    hours = hours - 12;
    abbreviation = pm;
  }
  printf("Equivalent 12-hour time: %d:%02d %s\n", hours, minutes, abbreviation);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeed(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    119e <main+0x7e>
movl   $0xc,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e7 <main+0xc7>
cmpl   $0xc,-0x8(%rbp)
jge    11b5 <main+0x95>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e2 <main+0xc2>
cmpl   $0xc,-0x8(%rbp)
jne    11cc <main+0xac>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11dd <main+0xbd>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e2 <main+0xc2>
jmp    11e7 <main+0xc7>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    (%rsp),%esi
test   %esi,%esi
je     1167 <main+0x47>
cmp    $0xc,%esi
jge    117c <main+0x5c>
lea    0xe9b(%rip),%rcx
jmp    1192 <main+0x72>
movl   $0xc,(%rsp)
lea    0xe8b(%rip),%rcx
mov    $0xc,%esi
jmp    1192 <main+0x72>
lea    0xe80(%rip),%rcx
jne    118c <main+0x6c>
mov    $0xc,%esi
jmp    1192 <main+0x72>
add    $0xfffffff4,%esi
mov    %esi,(%rsp)
mov    0x4(%rsp),%edx
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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