#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;
  int mm;
  int ss;
  char ampm[2];
  scanf("%d:%d:%d%s", &hh, &mm, &ss, ampm);
  if (strcmp(ampm, "AM") == 0) {
    if (hh == 12) {
      hh = 0;
    }
    printf("%02d:%02d:%02d", hh, mm, ss);
  } else if (strcmp(ampm, "PM") == 0) {
    if (hh < 12) {
      hh += 12;
    }
    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    -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    11a0 <main+0x70>
cmpl   $0xc,-0x8(%rbp)
jne    1186 <main+0x56>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
lea    -0x12(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <main+0xb2>
cmpl   $0xc,-0x8(%rbp)
jge    11cd <main+0x9d>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
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
je     1190 <main+0x60>
lea    0xeac(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11b5 <main+0x85>
mov    (%rsp),%esi
cmp    $0xb,%esi
jg     11a1 <main+0x71>
add    $0xc,%esi
mov    %esi,(%rsp)
jmp    11a1 <main+0x71>
mov    (%rsp),%esi
cmp    $0xc,%esi
jne    11a1 <main+0x71>
movl   $0x0,(%rsp)
xor    %esi,%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe5e(%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 = [15 x i8] c"%02d:%02d:%02d\00"
@.str.3 = [3 x i8] c"PM\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 = 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 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 %20
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 12
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %2
br label %15
15: ; preds = %14, %11
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
br label %36
20: ; preds = %0
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 12
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 12
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
br label %35
35: ; preds = %30, %20
br label %36
36: ; preds = %35, %15
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 = [15 x i8] c"%02d:%02d:%02d\00"
@.str.3 = [3 x i8] c"PM\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 = 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
br i1 %11, label %12, label %21
12: ; preds = %0
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 12
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %1
br label %16
16: ; preds = %15, %12
%17 = phi i32 [ 0, %15 ], [ %13, %12 ]
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
br label %34
21: ; preds = %0
%22 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %1
%26 = icmp slt i32 %25, 12
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = add nsw i32 %25, 12
store i32 %28, i32* %1
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %28, %27 ], [ %25, %24 ]
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %21, %29, %16
ret i32 0
}