#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 t12[3];
  scanf("%d:%d:%d%s", &hh, &mm, &ss, t12);
  if (strcmp(t12, "PM") == 0 && hh != 12)
    hh += 12;
  if (strcmp(t12, "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),%r8
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x13(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1188 <main+0x58>
cmpl   $0xc,-0x8(%rbp)
je     1188 <main+0x58>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
lea    -0x13(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b3 <main+0x83>
cmpl   $0xc,-0x8(%rbp)
jne    11b3 <main+0x83>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe4e(%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    0x5(%rsp),%rbx
mov    %rbx,%r8
call   1050 <scanf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1178 <main+0x48>
mov    (%rsp),%eax
cmp    $0xc,%eax
je     1178 <main+0x48>
add    $0xc,%eax
mov    %eax,(%rsp)
lea    0xe8f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%esi
test   %rax,%rax
jne    119f <main+0x6f>
cmp    $0xc,%esi
jne    119f <main+0x6f>
movl   $0x0,(%rsp)
xor    %esi,%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe63(%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 = [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 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%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 [3 x i8], [3 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 %17
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 12
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 12
store i32 %16, i32* %2
br label %17
17: ; preds = %14, %11, %0
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 12
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %2
br label %25
25: ; preds = %24, %21, %17
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
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 = [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 ([11 x i8], [11 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
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = add nsw i32 %12, 12
store i32 %16, i32* %1
br label %17
17: ; preds = %15, %0
%18 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 12
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 0, i32* %1
br label %24
24: ; preds = %23, %17
%25 = phi i32 [ 0, %23 ], [ %20, %17 ]
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
ret i32 0
}