#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 */
scalar_t__ cmprstrs(char *, char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, char *);
int main() {
  int hrs, mins, secs;
  char dur[3];
  scanf("%d:%d:%d%s", &hrs, &mins, &secs, dur);
  if (0 == cmprstrs(dur, "AM")) {
    printf("%0.2d:%0.2d:%0.2d", hrs % 12, mins, secs);
  } else {
    printf("%d:%0.2d:%0.2d", 12 + hrs % 12, mins, secs);
  }
  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 <cmprstrs@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    119d <main+0x6d>
mov    -0x8(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11bf <main+0x8f>
mov    -0x8(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0xc,%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe66(%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
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
lea    0xd(%rsp),%rbx
mov    %rbx,%r8
call   1050 <scanf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <cmprstrs@plt>
movslq 0x8(%rsp),%rsi
imul   $0x2aaaaaab,%rsi,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%esi
test   %rax,%rax
je     119e <main+0x6e>
add    $0xc,%esi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
lea    0xe84(%rip),%rdi
jmp    11ac <main+0x7c>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
lea    0xe62(%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"AM\00"
@.str.2 = [18 x i8] c"%0.2d:%0.2d:%0.2d\00"
@.str.3 = [15 x i8] c"%d:%0.2d:%0.2d\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 @cmprstrs(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 0, %9
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = load i32, i32* %2
%13 = srem i32 %12, 12
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
br label %24
17: ; preds = %0
%18 = load i32, i32* %2
%19 = srem i32 %18, 12
%20 = add nsw i32 12, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
br label %24
24: ; preds = %17, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%d:%d:%d%s\00"
@.str.1 = [3 x i8] c"AM\00"
@.str.2 = [18 x i8] c"%0.2d:%0.2d:%0.2d\00"
@.str.3 = [15 x i8] c"%d:%0.2d:%0.2d\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 @cmprstrs(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 = srem i32 %12, 12
br i1 %11, label %14, label %18
14: ; preds = %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %15, i32 %16)
br label %23
18: ; preds = %0
%19 = add nsw i32 %13, 12
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
br label %23
23: ; preds = %18, %14
ret i32 0
}