#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, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  int hh, mm, ss;
  char tt[3] = "";
  scanf("%d:%d:%d %[^\n]%*c", &hh, &mm, &ss, tt);
  hh = (strcmp(tt, "PM") == 0 && hh != 12) ? hh + 12 : hh;
  if (strcmp(tt, "AM") == 0 && hh == 12)
    hh = 0;
  printf("%02d:%02d:%02d", 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    0xe96(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
lea    -0x13(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ad <main+0x6d>
cmpl   $0xc,-0x8(%rbp)
je     11ad <main+0x6d>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x18(%rbp)
jmp    11b3 <main+0x73>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x13(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <main+0xa4>
cmpl   $0xc,-0x8(%rbp)
jne    11e4 <main+0xa4>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe24(%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,0x6(%rsp)
movw   $0x0,0x4(%rsp)
lea    0xeb8(%rip),%rdi
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%rbx
mov    %rbx,%r8
call   1050 <scanf@plt>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%ecx
lea    0xc(%rcx),%edx
cmp    $0xc,%ecx
cmove  %ecx,%edx
test   %rax,%rax
cmovne %ecx,%edx
mov    %edx,(%rsp)
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%esi
test   %rax,%rax
jne    11ab <main+0x7b>
cmp    $0xc,%esi
jne    11ab <main+0x7b>
movl   $0x0,(%rsp)
xor    %esi,%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe5e(%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"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [15 x i8] c"%02d:%02d:%02d\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 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %0
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 12
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 12
br label %20
18: ; preds = %12, %0
%19 = load i32, i32* %2
br label %20
20: ; preds = %18, %15
%21 = phi i32 [ %17, %15 ], [ %19, %18 ]
store i32 %21, i32* %2
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 12
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 0, i32* %2
br label %29
29: ; preds = %28, %25, %20
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"%d:%d:%d %[^\0A]%*c\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [15 x i8] c"%02d:%02d:%02d\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 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = load i32, i32* %1
%13 = icmp ne i32 %12, 12
%14 = select i1 %11, i1 %13, i1 false
%15 = add nsw i32 %12, 12
%16 = select i1 %14, i32 %15, i32 %12
store i32 %16, i32* %1
%17 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 12
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %23
22: ; preds = %0
store i32 0, i32* %1
br label %23
23: ; preds = %22, %0
%24 = phi i32 [ 0, %22 ], [ %19, %0 ]
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
ret i32 0
}