#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__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char *time = (char *)malloc(10240 * sizeof(char));
  scanf("%s", time);
  if (time[8] == 'A') {
    if (time[0] == '1' && time[1] == '2') {
      printf("00");
      for (int i = 2; i < 8; i++) {
        printf("%c", time[i]);
      }
    } else {
      for (int i = 0; i < 8; i++) {
        printf("%c", time[i]);
      }
    }
  } else {
    int hour = (time[0] - '0') * 10 + (time[1] - '0');
    if (hour != 12) {
      hour += 12;
    }
    printf("%d", hour);
    for (int i = 2; i < 8; i++) {
      printf("%c", time[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2800,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
movsbl 0x8(%rax),%eax
cmp    $0x41,%eax
jne    121e <main+0xee>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    11db <main+0xab>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x32,%eax
jne    11db <main+0xab>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11d6 <main+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x74>
jmp    1219 <main+0xe9>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1214 <main+0xe4>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e2 <main+0xb2>
jmp    1219 <main+0xe9>
jmp    129d <main+0x16d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
je     124e <main+0x11e>
mov    -0x1c(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jge    1298 <main+0x168>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1266 <main+0x136>
jmp    129d <main+0x16d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x2800,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rdi
mov    %rax,%rsi
call   1060 <scanf@plt>
cmpb   $0x41,0x8(%rbx)
movsbl (%rbx),%edi
jne    1182 <main+0x42>
cmp    $0x31,%dil
jne    11b1 <main+0x71>
cmpb   $0x32,0x1(%rbx)
jne    11b1 <main+0x71>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bf <main+0x7f>
lea    (%rdi,%rdi,4),%eax
movsbl 0x1(%rbx),%ecx
lea    (%rcx,%rax,2),%edx
cmp    $0x21c,%edx
lea    -0x204(%rcx,%rax,2),%eax
mov    $0xc,%esi
cmovne %eax,%esi
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bf <main+0x7f>
call   1030 <putchar@plt>
movsbl 0x1(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x2(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x3(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x4(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x5(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x6(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x7(%rbx),%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"00\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i64 @malloc(i32 10240)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 8
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 65
br i1 %15, label %16, label %62
16: ; preds = %0
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 49
br i1 %21, label %22, label %45
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 50
br i1 %27, label %28, label %45
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %30
30: ; preds = %41, %28
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 8
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %33
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %30
44: ; preds = %30
br label %61
45: ; preds = %22, %16
store i32 0, i32* %4
br label %46
46: ; preds = %57, %45
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 8
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load i8*, i8** %2
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %49
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %46
60: ; preds = %46
br label %61
61: ; preds = %60, %44
br label %98
62: ; preds = %0
%63 = load i8*, i8** %2
%64 = getelementptr inbounds i8, i8* %63, i64 0
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = sub nsw i32 %66, 48
%68 = mul nsw i32 %67, 10
%69 = load i8*, i8** %2
%70 = getelementptr inbounds i8, i8* %69, i64 1
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = sub nsw i32 %72, 48
%74 = add nsw i32 %68, %73
store i32 %74, i32* %5
%75 = load i32, i32* %5
%76 = icmp ne i32 %75, 12
br i1 %76, label %77, label %80
77: ; preds = %62
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 12
store i32 %79, i32* %5
br label %80
80: ; preds = %77, %62
%81 = load i32, i32* %5
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %81)
store i32 2, i32* %6
br label %83
83: ; preds = %94, %80
%84 = load i32, i32* %6
%85 = icmp slt i32 %84, 8
br i1 %85, label %86, label %97
86: ; preds = %83
%87 = load i8*, i8** %2
%88 = load i32, i32* %6
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %86
%95 = load i32, i32* %6
%96 = add nsw i32 %95, 1
store i32 %96, i32* %6
br label %83
97: ; preds = %83
br label %98
98: ; preds = %97, %61
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"00\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 10240)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = getelementptr inbounds i8, i8* %2, i64 8
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 65
%7 = load i8, i8* %2
br i1 %6, label %8, label %23
8: ; preds = %0
%9 = icmp eq i8 %7, 49
br i1 %9, label %10, label %16
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %2, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 50
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %34
16: ; preds = %10, %8
%17 = sext i8 %7 to i32
%18 = tail call i32 @putchar(i32 %17)
%19 = getelementptr inbounds i8, i8* %2, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = tail call i32 @putchar(i32 %21)
br label %34
23: ; preds = %0
%24 = sext i8 %7 to i32
%25 = mul nsw i32 %24, 10
%26 = getelementptr inbounds i8, i8* %2, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = add nsw i32 %25, %28
%30 = icmp eq i32 %29, 540
%31 = add nsw i32 %29, -516
%32 = select i1 %30, i32 12, i32 %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %23, %16, %14
%35 = getelementptr inbounds i8, i8* %2, i64 2
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = tail call i32 @putchar(i32 %37)
%39 = getelementptr inbounds i8, i8* %2, i64 3
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = tail call i32 @putchar(i32 %41)
%43 = getelementptr inbounds i8, i8* %2, i64 4
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 @putchar(i32 %45)
%47 = getelementptr inbounds i8, i8* %2, i64 5
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = tail call i32 @putchar(i32 %49)
%51 = getelementptr inbounds i8, i8* %2, i64 6
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = tail call i32 @putchar(i32 %53)
%55 = getelementptr inbounds i8, i8* %2, i64 7
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = tail call i32 @putchar(i32 %57)
ret i32 0
}