#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int scanf(char *, int *, int *, int *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main() {
  int hh, mm, ss;
  char tt[3] = "";
  if (scanf("%d:%d:%d %[^\n]%*c", &hh, &mm, &ss, tt) != 4) {
    fprintf(stderr, "error: invalid read of time.\n");
  }
  hh = (strcmp(tt, "PM") == 0 && hh != 12) ? hh + 12 : hh;
  if (strcmp(tt, "AM") == 0 && hh == 12)
    hh = 0;
  printf("%02d:%02d:%02d\n", hh, mm, ss);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x13(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
lea    -0x13(%rbp),%r8
lea    0xe86(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1070 <scanf@plt>
cmp    $0x4,%eax
je     11a9 <main+0x59>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x13(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11db <main+0x8b>
cmpl   $0xc,-0x8(%rbp)
je     11db <main+0x8b>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x18(%rbp)
jmp    11e1 <main+0x91>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x13(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1212 <main+0xc2>
cmpl   $0xc,-0x8(%rbp)
jne    1212 <main+0xc2>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0x2(%rsp)
movw   $0x0,(%rsp)
lea    0xea9(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
call   1060 <scanf@plt>
cmp    $0x4,%eax
je     1188 <main+0x48>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xea1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    0x4(%rsp),%ecx
lea    0xc(%rcx),%edx
cmp    $0xc,%ecx
cmove  %ecx,%edx
test   %rax,%rax
cmovne %ecx,%edx
mov    %edx,0x4(%rsp)
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    0x4(%rsp),%esi
test   %rax,%rax
jne    11d8 <main+0x98>
cmp    $0xc,%esi
jne    11d8 <main+0x98>
movl   $0x0,0x4(%rsp)
xor    %esi,%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%d:%d:%d %[^\0A]%*c\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"error: invalid read of time.\0A\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [3 x i8] c"AM\00"
@.str.4 = [16 x i8] c"%02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [3 x i8]
store i32 0, i32* %1
%6 = bitcast [3 x i8]* %5 to i8*
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i8* %7)
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %10, %0
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 12
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 12
br label %25
23: ; preds = %17, %13
%24 = load i32, i32* %2
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ %22, %20 ], [ %24, %23 ]
store i32 %26, i32* %2
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 12
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 0, i32* %2
br label %34
34: ; preds = %33, %30, %25
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"%d:%d:%d %[^\0A]%*c\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"error: invalid read of time.\0A\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [3 x i8] c"AM\00"
@.str.4 = [16 x i8] c"%02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i8* %8)
%10 = icmp eq i32 %9, 4
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %0
%15 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* %1
%18 = icmp ne i32 %17, 12
%19 = select i1 %16, i1 %18, i1 false
%20 = add nsw i32 %17, 12
%21 = select i1 %19, i32 %20, i32 %17
store i32 %21, i32* %1
%22 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 12
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %27, label %28
27: ; preds = %14
store i32 0, i32* %1
br label %28
28: ; preds = %27, %14
%29 = phi i32 [ 0, %27 ], [ %24, %14 ]
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
ret i32 0
}