#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 *, unsigned int *, unsigned int *);
int main() {
  unsigned int hh, mm;
  printf("Escribir hora(formato hh:mm )\n");
  scanf("%d:%d", &hh, &mm);
  if (hh >= 0 && hh <= 24 && mm >= 0 && mm < 60) {
    if (hh == 0)
      printf("%02d:%02d AM\n", 12, mm);
    else if (hh > 12)
      printf("%02d:%02d PM\n", hh - 12, mm);
    else if (hh == 12)
      printf("%02d:%02d PM\n", hh, mm);
    else
      printf("%02d:%02d AM\n", hh, mm);
  } else {
    printf("Formato incorrecto");
  }
}


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    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jb     120a <main+0xea>
cmpl   $0x18,-0x8(%rbp)
ja     120a <main+0xea>
cmpl   $0x0,-0xc(%rbp)
jb     120a <main+0xea>
cmpl   $0x3c,-0xc(%rbp)
jae    120a <main+0xea>
cmpl   $0x0,-0x8(%rbp)
jne    119e <main+0x7e>
mov    -0xc(%rbp),%edx
lea    0xe98(%rip),%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <main+0xe5>
cmpl   $0xc,-0x8(%rbp)
jbe    11c4 <main+0xa4>
mov    -0x8(%rbp),%esi
sub    $0xc,%esi
mov    -0xc(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <main+0xe0>
cmpl   $0xc,-0x8(%rbp)
jne    11e7 <main+0xc7>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <main+0xdb>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <main+0xe0>
jmp    1205 <main+0xe5>
jmp    1218 <main+0xf8>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x18,%esi
ja     1177 <main+0x47>
mov    (%rsp),%edx
cmp    $0x3b,%edx
ja     1177 <main+0x47>
test   %esi,%esi
je     1187 <main+0x57>
cmp    $0xd,%esi
jb     1190 <main+0x60>
add    $0xfffffff4,%esi
lea    0xe9f(%rip),%rdi
jmp    11aa <main+0x7a>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b1 <main+0x81>
lea    0xe78(%rip),%rdi
jmp    119c <main+0x6c>
cmp    $0xc,%esi
jne    11a3 <main+0x73>
lea    0xe78(%rip),%rdi
mov    $0xc,%esi
jmp    11aa <main+0x7a>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Escribir hora(formato hh:mm )\0A\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [14 x i8] c"%02d:%02d AM\0A\00"
@.str.3 = [14 x i8] c"%02d:%02d PM\0A\00"
@.str.4 = [19 x i8] c"Formato incorrecto\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 ([31 x i8], [31 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 uge i32 %6, 0
br i1 %7, label %8, label %45
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp ule i32 %9, 24
br i1 %10, label %11, label %45
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp uge i32 %12, 0
br i1 %13, label %14, label %45
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp ult i32 %15, 60
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 %21)
br label %44
23: ; preds = %17
%24 = load i32, i32* %2
%25 = icmp ugt i32 %24, 12
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32, i32* %2
%28 = sub i32 %27, 12
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
br label %43
31: ; preds = %23
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 12
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36)
br label %42
38: ; preds = %31
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38, %34
br label %43
43: ; preds = %42, %26
br label %44
44: ; preds = %43, %20
br label %47
45: ; preds = %14, %11, %8, %0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %44
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [14 x i8] c"%02d:%02d AM\0A\00"
@.str.3 = [14 x i8] c"%02d:%02d PM\0A\00"
@.str.4 = [19 x i8] c"Formato incorrecto\00"
@str = [30 x i8] c"Escribir hora(formato hh:mm )\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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 ult i32 %7, 25
%9 = load i32, i32* %2
%10 = icmp ult i32 %9, 60
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %27
12: ; preds = %0
%13 = icmp eq i32 %7, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 %9)
br label %29
16: ; preds = %12
%17 = icmp ugt i32 %7, 12
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = add nsw i32 %7, -12
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %9)
br label %29
21: ; preds = %16
%22 = icmp eq i32 %7, 12
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 12, i32 %9)
br label %29
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %9)
br label %29
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %14, %23, %25, %18, %27
ret i32 0
}