#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 *);
int /*<<< orphan*/ strcmp(char *, char *);
int main() {
  int h = 0, m = 0, s = 0;
  char c[2];
  scanf("%d:%d:%d%s", &h, &m, &s, c);
  if (!strcmp(c, "PM") && h != 12)
    h += 12;
  if (!strcmp(c, "AM") && h == 12)
    h = 0;
  printf("%02d:%02d:%02d", h, m, s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x12(%rbp),%r8
lea    0xea1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x12(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119c <main+0x6c>
cmpl   $0xc,-0x8(%rbp)
je     119c <main+0x6c>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c6 <main+0x96>
cmpl   $0xc,-0x8(%rbp)
jne    11c6 <main+0x96>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe3b(%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
movl   $0x0,(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xead(%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    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%ebx
test   %eax,%eax
jne    118e <main+0x5e>
cmp    $0xc,%ebx
je     118e <main+0x5e>
add    $0xc,%ebx
mov    %ebx,(%rsp)
lea    0xe79(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11b1 <main+0x81>
cmp    $0xc,%ebx
jne    11b1 <main+0x81>
movl   $0x0,(%rsp)
xor    %ebx,%ebx
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe51(%rip),%rdi
mov    %ebx,%esi
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 [2 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%6 = getelementptr inbounds [2 x i8], [2 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 [2 x i8], [2 x i8]* %5, i64 0, i64 0
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %17, label %11
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 [2 x i8], [2 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
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 [2 x i8]
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = getelementptr inbounds [2 x i8], [2 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 i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %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 = phi i32 [ %16, %15 ], [ %12, %0 ]
%19 = call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
%21 = icmp eq i32 %18, 12
%22 = select i1 %20, 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 ], [ %18, %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
}