#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 hours;
  int minutes;
  int seconds;
  char section[3];
  scanf("%d:%d:%d%2s", &hours, &minutes, &seconds, section);
  if (strcmp(section, "PM") == 0 && hours != 12) {
    hours += 12;
  } else if (strcmp(section, "AM") == 0 && hours == 12) {
    hours = 0;
  }
  printf("%02d:%02d:%02d", hours, minutes, seconds);
  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    0xea6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118d <main+0x5d>
cmpl   $0xc,-0x8(%rbp)
je     118d <main+0x5d>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
jmp    11bd <main+0x8d>
lea    -0x13(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <main+0x88>
cmpl   $0xc,-0x8(%rbp)
jne    11b8 <main+0x88>
movl   $0x0,-0x8(%rbp)
jmp    11bd <main+0x8d>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe45(%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    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    117a <main+0x4a>
mov    (%rsp),%esi
cmp    $0xc,%esi
je     117a <main+0x4a>
add    $0xc,%esi
mov    %esi,(%rsp)
jmp    11a1 <main+0x71>
lea    0xe8e(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
mov    (%rsp),%esi
test   %rax,%rax
jne    11a1 <main+0x71>
cmp    $0xc,%esi
jne    11a1 <main+0x71>
movl   $0x0,(%rsp)
xor    %esi,%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d:%d:%d%2s\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 ([12 x i8], [12 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 %26
17: ; preds = %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
br label %26
26: ; preds = %25, %14
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d:%d:%d%2s\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 ([12 x i8], [12 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 %24
17: ; preds = %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 = %17, %23, %15
%25 = phi i32 [ %20, %17 ], [ 0, %23 ], [ %16, %15 ]
%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
}