#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__ calloc(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char *time = (char *)malloc(11 * sizeof(char));
  char *time_24 = (char *)calloc(9, sizeof(char));
  scanf("%s", time);
  if (time[8] == 'A') {
    strncpy(time_24, time, 8);
    if (strncmp(time, "12", 2) == 0) {
      strncpy(time_24, "00", 2);
    }
  } else {
    int hour, h1, h2;
    h1 = time[0] - '0';
    h2 = time[1] - '0';
    hour = (h1 * 10) + h2 + 12;
    strncpy(time_24, time, 8);
    if (strncmp(time, "12", 2) == 0) {
      strncpy(time_24, "12", 2);
    } else {
      time_24[0] = (hour / 10) + '0';
      time_24[1] = (hour % 10) + '0';
    }
  }
  printf("%s\n", time_24);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xb,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x9,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rax
movsbl 0x8(%rax),%eax
cmp    $0x41,%eax
jne    11fc <main+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11f7 <main+0x97>
mov    -0x18(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
jmp    12a1 <main+0x141>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
imul   $0xa,-0x20(%rbp),%eax
add    -0x24(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xdc2(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    126f <main+0x10f>
mov    -0x18(%rbp),%rdi
lea    0xda3(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
jmp    129c <main+0x13c>
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
jmp    12a1 <main+0x141>
mov    -0x18(%rbp),%rsi
lea    0xd5d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xb,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x9,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cmpb   $0x41,0x8(%rbx)
jne    11d1 <main+0x71>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1250 <main+0xf0>
lea    0xe37(%rip),%rsi
jmp    1243 <main+0xe3>
movsbl (%rbx),%r15d
movsbl 0x1(%rbx),%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     123c <main+0xdc>
movswl %bp,%eax
movswl %r15w,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rax,%rcx,2),%eax
add    $0xfffffdfc,%eax
movswl %ax,%ecx
imul   $0x6667,%ecx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x12,%ecx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,(%r14)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x1(%r14)
jmp    1250 <main+0xf0>
lea    0xdc0(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    0xdb2(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"12\00"
@.str.2 = [3 x i8] c"00\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i64 @malloc(i32 11)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %2
%9 = call i64 @calloc(i32 9, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
%11 = load i8*, i8** %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 8
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 65
br i1 %17, label %18, label %29
18: ; preds = %0
%19 = load i8*, i8** %3
%20 = load i8*, i8** %2
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 8)
%22 = load i8*, i8** %2
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = call i32 @strncpy(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %28
28: ; preds = %25, %18
br label %68
29: ; preds = %0
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
store i32 %34, i32* %5
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 48
store i32 %39, i32* %6
%40 = load i32, i32* %5
%41 = mul nsw i32 %40, 10
%42 = load i32, i32* %6
%43 = add nsw i32 %41, %42
%44 = add nsw i32 %43, 12
store i32 %44, i32* %4
%45 = load i8*, i8** %3
%46 = load i8*, i8** %2
%47 = call i32 @strncpy(i8* %45, i8* %46, i32 8)
%48 = load i8*, i8** %2
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %29
%52 = load i8*, i8** %3
%53 = call i32 @strncpy(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %67
54: ; preds = %29
%55 = load i32, i32* %4
%56 = sdiv i32 %55, 10
%57 = add nsw i32 %56, 48
%58 = trunc i32 %57 to i8
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 0
store i8 %58, i8* %60
%61 = load i32, i32* %4
%62 = srem i32 %61, 10
%63 = add nsw i32 %62, 48
%64 = trunc i32 %63 to i8
%65 = load i8*, i8** %3
%66 = getelementptr inbounds i8, i8* %65, i64 1
store i8 %64, i8* %66
br label %67
67: ; preds = %54, %51
br label %68
68: ; preds = %67, %28
%69 = load i8*, i8** %3
%70 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"12\00"
@.str.2 = [3 x i8] c"00\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 11)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @calloc(i32 9, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = getelementptr inbounds i8, i8* %2, i64 8
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 65
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = tail call i32 @strncpy(i8* %4, i8* %2, i32 8)
%11 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = tail call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %37
15: ; preds = %0
%16 = load i8, i8* %2
%17 = getelementptr inbounds i8, i8* %2, i64 1
%18 = load i8, i8* %17
%19 = tail call i32 @strncpy(i8* %4, i8* %2, i32 8)
%20 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = tail call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %37
24: ; preds = %15
%25 = sext i8 %18 to i16
%26 = add nsw i16 %25, -516
%27 = sext i8 %16 to i16
%28 = mul nsw i16 %27, 10
%29 = add nsw i16 %26, %28
%30 = sdiv i16 %29, 10
%31 = trunc i16 %30 to i8
%32 = add i8 %31, 48
store i8 %32, i8* %4
%33 = srem i16 %29, 10
%34 = trunc i16 %33 to i8
%35 = add nsw i8 %34, 48
%36 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %35, i8* %36
br label %37
37: ; preds = %22, %24, %9, %13
%38 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}