#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 hour;
  int minute;
  int second;
  char m[2];
  scanf("%d:%d:%d%s", &hour, &minute, &second, &m);
  if (strcmp(m, "PM") == 0 && hour != 12 || strcmp(m, "AM") == 0 && hour == 12)
    hour += 12;
  hour %= 24;
  printf("%02d:%02d:%02d\n", hour, minute, second);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x12(%rbp),%r8
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x12(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117f <main+0x4f>
cmpl   $0xc,-0x8(%rbp)
jne    11a3 <main+0x73>
lea    -0x12(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <main+0x7c>
cmpl   $0xc,-0x8(%rbp)
jne    11ac <main+0x7c>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe47(%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
lea    0xec4(%rip),%rdi
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x6(%rsp),%rbx
mov    %rbx,%r8
call   1050 <scanf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1172 <main+0x42>
mov    (%rsp),%eax
cmp    $0xc,%eax
jne    1195 <main+0x65>
lea    0xe95(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%ecx
test   %rax,%rax
jne    119a <main+0x6a>
mov    $0xc,%eax
cmp    $0xc,%ecx
jne    119a <main+0x6a>
add    $0xc,%eax
mov    %eax,%ecx
movslq %ecx,%rsi
imul   $0x2aaaaaab,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x22,%rax
add    %ecx,%eax
shl    $0x3,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%esi
mov    %esi,(%rsp)
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%d:%d:%d%s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [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 [2 x i8]
store i32 0, i32* %1
%6 = bitcast [2 x i8]* %5 to i8**
%7 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i8** %6)
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 12
br i1 %13, label %21, label %14
14: ; preds = %11, %0
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 12
br i1 %20, label %21, label %24
21: ; preds = %18, %11
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 12
store i32 %23, i32* %2
br label %24
24: ; preds = %21, %18, %14
%25 = load i32, i32* %2
%26 = srem i32 %25, 24
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%d:%d:%d%s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [16 x i8] c"%02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%9 = bitcast [2 x i8]* %4 to i8**
%10 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i8** %9)
%11 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 12
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %22, label %16
16: ; preds = %0
%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 %25
22: ; preds = %16, %0
%23 = phi i32 [ 12, %16 ], [ %13, %0 ]
%24 = add nsw i32 %23, 12
br label %25
25: ; preds = %22, %16
%26 = phi i32 [ %24, %22 ], [ %19, %16 ]
%27 = srem i32 %26, 24
store i32 %27, i32* %1
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
ret i32 0
}