#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 am_pm(int);
int convert_hour(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ is_hour(int);
scalar_t__ is_minute(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, const char *argv[]) {
  int hr, min;
  char op;
  do {
    printf("Digite as horas: ");
    scanf("%d", &hr);
    if (is_hour(hr) == 0) {
      printf("Valor invalido. \n");
    } else {
      printf("Digite os minutos: ");
      scanf("%d", &min);
      if (is_minute(min) == 0) {
        printf("Valor invalido. \n");
      } else {
        printf("%d:%d %c.M \n ", convert_hour(hr), min, am_pm(hr));
      }
    }
    printf("Deseja tentar novamente[s/n]: ");
    scanf(" %c", &op);
    fflush(stdin);
  } while (op == 's' || op == 'S');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x14(%rbp),%edi
call   1030 <is_hour@plt>
cmp    $0x0,%rax
jne    11cb <main+0x5b>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1244 <main+0xd4>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x18(%rbp),%edi
call   1060 <is_minute@plt>
cmp    $0x0,%rax
jne    1210 <main+0xa0>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123f <main+0xcf>
mov    -0x14(%rbp),%edi
call   1050 <convert_hour@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <am_pm@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1244 <main+0xd4>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x73,%ecx
mov    %al,-0x25(%rbp)
je     1291 <main+0x121>
movsbl -0x19(%rbp),%eax
cmp    $0x53,%eax
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1186 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe7d(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe96(%rip),%r14
lea    0xeae(%rip),%rbp
lea    0xf(%rsp),%rbx
mov    0x2e34(%rip),%r15
jmp    11fa <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    (%r15),%edi
call   1080 <fflush@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x53,%al
jne    12ab <main+0x12b>
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x10(%rsp),%edi
call   1030 <is_hour@plt>
test   %rax,%rax
je     11c0 <main+0x40>
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x14(%rsp),%edi
call   1070 <is_minute@plt>
test   %rax,%rax
je     11c0 <main+0x40>
mov    0x10(%rsp),%edi
call   1060 <convert_hour@plt>
mov    %r13,%rbx
mov    %r12,%r13
mov    %r14,%r12
mov    %eax,%r14d
mov    %r15,%rbp
mov    0x14(%rsp),%r15d
mov    0x10(%rsp),%edi
call   10a0 <am_pm@plt>
lea    0xdaa(%rip),%rdi
mov    %r14d,%esi
mov    %r12,%r14
mov    %r13,%r12
mov    %rbx,%r13
mov    %r15d,%edx
mov    %rbp,%r15
lea    0xf(%rsp),%rbx
lea    0xdb9(%rip),%rbp
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cc <main+0x4c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Digite as horas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Valor invalido. \0A\00"
@.str.3 = [20 x i8] c"Digite os minutos: \00"
@.str.4 = [14 x i8] c"%d:%d %c.M \0A \00"
@.str.5 = [31 x i8] c"Deseja tentar novamente[s/n]: \00"
@.str.6 = [4 x i8] c" %c\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %46, %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = call i64 @is_hour(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %33
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%20 = load i32, i32* %7
%21 = call i64 @is_minute(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %32
25: ; preds = %17
%26 = load i32, i32* %6
%27 = call i32 @convert_hour(i32 %26)
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = call i32 @am_pm(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %28, i32 %30)
br label %32
32: ; preds = %25, %23
br label %33
33: ; preds = %32, %15
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%36 = load i32, i32* @stdin
%37 = call i32 @fflush(i32 %36)
br label %38
38: ; preds = %33
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 115
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8, i8* %8
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 83
br label %46
46: ; preds = %42, %38
%47 = phi i1 [ true, %38 ], [ %45, %42 ]
br i1 %47, label %9, label %48
48: ; preds = %46
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [18 x i8] c"Digite as horas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Digite os minutos: \00"
@.str.4 = [14 x i8] c"%d:%d %c.M \0A \00"
@.str.5 = [31 x i8] c"Deseja tentar novamente[s/n]: \00"
@.str.6 = [4 x i8] c" %c\00"
@stdin = global i32 0
@str.7 = [17 x i8] c"Valor invalido. \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
br label %8
8: ; preds = %31, %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = call i64 @is_hour(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %31
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
%20 = call i64 @is_minute(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %31
24: ; preds = %16
%25 = load i32, i32* %3
%26 = call i32 @convert_hour(i32 %25)
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = call i32 @am_pm(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %27, i32 %29)
br label %31
31: ; preds = %22, %24, %14
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%34 = load i32, i32* @stdin
%35 = call i32 @fflush(i32 %34)
%36 = load i8, i8* %5
%37 = and i8 %36, -33
%38 = icmp eq i8 %37, 83
br i1 %38, label %8, label %39
39: ; preds = %31
ret i32 0
}