#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 main() {
  int h, m, s;
  printf("Ingrese la hora (0 - 23): ");
  scanf("%d", &h);
  if (h > 23 || h < 0) {
    printf("Hora invalida\n");
    return -1;
  }
  printf("Ingrese los minutos (0 - 59): ");
  scanf("%d", &m);
  if (m > 59 || m < 0) {
    printf("Minutos invalidos\n");
    return -1;
  }
  printf("Ingrese los segundos (0 - 59): ");
  scanf("%d", &s);
  if (s > 59 || s < 0) {
    printf("Segundos invalidos\n");
    return -1;
  }
  s = (s + 1) % 60;
  if (s == 0) {
    m = (m + 1) % 60;
    if (m == 0)
      h = (h + 1) % 24;
  }
  printf("%02d:%02d:%02d\n", h, m, s);
  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    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x17,-0x8(%rbp)
jg     1161 <main+0x41>
cmpl   $0x0,-0x8(%rbp)
jge    117b <main+0x5b>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <main+0x15d>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3b,-0xc(%rbp)
jg     11ad <main+0x8d>
cmpl   $0x0,-0xc(%rbp)
jge    11c7 <main+0xa7>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <main+0x15d>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3b,-0x10(%rbp)
jg     11f9 <main+0xd9>
cmpl   $0x0,-0x10(%rbp)
jge    1213 <main+0xf3>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <main+0x15d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    125f <main+0x13f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    125a <main+0x13a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
jmp    125f <main+0x13f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x18,0x4(%rsp)
jb     1164 <main+0x34>
lea    0xf30(%rip),%rdi
jmp    11c2 <main+0x92>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x3c,0x8(%rsp)
jb     1193 <main+0x63>
lea    0xeef(%rip),%rdi
jmp    11c2 <main+0x92>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3c,%eax
jb     11d4 <main+0xa4>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
add    $0x1,%al
movzbl %al,%eax
imul   $0x89,%eax,%ecx
shr    $0xd,%ecx
imul   $0x3c,%ecx,%ecx
sub    %cl,%al
movzbl %al,%ecx
mov    %ecx,0xc(%rsp)
mov    0x8(%rsp),%edx
test   %cl,%cl
jne    1257 <main+0x127>
mov    %edx,%eax
add    $0x1,%eax
cltq
imul   $0xffffffff88888889,%rax,%rsi
shr    $0x20,%rsi
add    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x3c,%edx,%edx
sub    %edx,%eax
mov    %eax,0x8(%rsp)
mov    %eax,%edx
jne    1257 <main+0x127>
mov    0x4(%rsp),%eax
mov    %eax,%edx
add    $0x1,%edx
movslq %edx,%rdx
imul   $0x2aaaaaab,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x22,%rdx
add    %esi,%edx
shl    $0x3,%edx
lea    (%rdx,%rdx,2),%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
xor    %edx,%edx
mov    0x4(%rsp),%esi
lea    0xdfb(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11cc <main+0x9c>

LLVM IR (-O0):
@.str = [27 x i8] c"Ingrese la hora (0 - 23): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Hora invalida\0A\00"
@.str.3 = [31 x i8] c"Ingrese los minutos (0 - 59): \00"
@.str.4 = [19 x i8] c"Minutos invalidos\0A\00"
@.str.5 = [32 x i8] c"Ingrese los segundos (0 - 59): \00"
@.str.6 = [20 x i8] c"Segundos invalidos\0A\00"
@.str.7 = [16 x i8] c"%02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 23
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %56
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 59
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19, %14
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %56
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 59
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29, %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %1
br label %56
34: ; preds = %29
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
%37 = srem i32 %36, 60
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %34
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
%43 = srem i32 %42, 60
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %40
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
%49 = srem i32 %48, 24
store i32 %49, i32* %2
br label %50
50: ; preds = %46, %40
br label %51
51: ; preds = %50, %34
%52 = load i32, i32* %2
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %52, i32 %53, i32 %54)
store i32 0, i32* %1
br label %56
56: ; preds = %51, %32, %22, %12
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str = [27 x i8] c"Ingrese la hora (0 - 23): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"Ingrese los minutos (0 - 59): \00"
@.str.5 = [32 x i8] c"Ingrese los segundos (0 - 59): \00"
@.str.7 = [16 x i8] c"%02d:%02d:%02d\0A\00"
@str = [19 x i8] c"Segundos invalidos\00"
@str.8 = [18 x i8] c"Minutos invalidos\00"
@str.9 = [14 x i8] c"Hora invalida\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp ugt i32 %9, 23
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
br label %46
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp ugt i32 %16, 59
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %46
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = icmp ugt i32 %23, 59
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %46
27: ; preds = %20
%28 = trunc i32 %23 to i8
%29 = add nuw nsw i8 %28, 1
%30 = urem i8 %29, 60
%31 = zext i8 %30 to i32
store i32 %31, i32* %3
%32 = icmp eq i8 %30, 0
%33 = load i32, i32* %2
br i1 %32, label %34, label %42
34: ; preds = %27
%35 = add nsw i32 %33, 1
%36 = srem i32 %35, 60
store i32 %36, i32* %2
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
%41 = srem i32 %40, 24
store i32 %41, i32* %1
br label %42
42: ; preds = %27, %34, %38
%43 = phi i32 [ %36, %34 ], [ 0, %38 ], [ %33, %27 ]
%44 = load i32, i32* %1
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %44, i32 %43, i32 %31)
br label %46
46: ; preds = %42, %25, %18, %11
%47 = phi i32 [ -1, %11 ], [ -1, %18 ], [ -1, %25 ], [ 0, %42 ]
ret i32 %47
}