#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int toupper(char);
int main(void) {
  int hour, minute;
  char ch;
  printf("enter a 12-hour time:(xx:xx)\n");
  scanf("%d:%d", &hour, &minute);
  while ((ch = getchar()) == ' ') {
    ;
  }
  switch (toupper(ch)) {
  case 'A':
    hour += 0;
    break;
  case 'P':
    hour += 12;
    break;
  }
  printf("24-hour time is: %d:%d\n", hour, minute);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    118c <main+0x4c>
jmp    1171 <main+0x31>
movsbl -0xd(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0x41,%eax
je     11b9 <main+0x79>
jmp    11a8 <main+0x68>
mov    -0x14(%rbp),%eax
sub    $0x50,%eax
je     11c7 <main+0x87>
jmp    11d0 <main+0x90>
mov    -0x8(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x8(%rbp)
jmp    11d0 <main+0x90>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9c(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1070 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x20,%al
je     1180 <main+0x30>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    (%rsp),%esi
cmp    $0x50,%eax
jne    11a1 <main+0x51>
add    $0xc,%esi
mov    %esi,(%rsp)
mov    0x4(%rsp),%edx
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"enter a 12-hour time:(xx:xx)\0A\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [24 x i8] c"24-hour time is: %d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
br label %7
7: ; preds = %11, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 32
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = load i8, i8* %4
%14 = call i32 @toupper(i8 signext %13)
switch i32 %14, label %21 [
i32 65, label %15
i32 80, label %18
]
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 0
store i32 %17, i32* %2
br label %21
18: ; preds = %12
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 12
store i32 %20, i32* %2
br label %21
21: ; preds = %12, %18, %15
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [24 x i8] c"24-hour time is: %d:%d\0A\00"
@str = [29 x i8] c"enter a 12-hour time:(xx:xx)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
br label %7
7: ; preds = %7, %0
%8 = call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 32
br i1 %9, label %7, label %10
10: ; preds = %7
%11 = call i32 @toupper(i8 signext %8)
%12 = icmp eq i32 %11, 80
%13 = load i32, i32* %1
br i1 %12, label %14, label %16
14: ; preds = %10
%15 = add nsw i32 %13, 12
store i32 %15, i32* %1
br label %16
16: ; preds = %10, %14
%17 = phi i32 [ %15, %14 ], [ %13, %10 ]
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}