#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strstr(char *, char *);
char *strtok(char *, char *);
void time_convert(char *time) {
  char *hour;
  char *min;
  char *sec;
  char *pm_portion;
  bool PM;
  int hourNum;
  printf("%s->", time);
  hour = strtok(time, ":");
  min = strtok(NULL, ":");
  sec = strtok(NULL, ":");
  pm_portion = strstr(sec, "PM");
  if (pm_portion) {
    PM = true;
  } else {
    PM = false;
  }
  sec[2] = '\0';
  hourNum = atoi(hour);
  if (hourNum == 12) {
    if (!PM) {
      hourNum = 0;
    }
  } else if (PM) {
    hourNum = hourNum + 12;
  }
  printf("%02d:%s:%s\n", hourNum, min, sec);
}


x86 assembly (clang, -O0):
<time_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe88(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe74(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c5 <time_convert+0x85>
movl   $0x1,-0x2c(%rbp)
jmp    11cc <time_convert+0x8c>
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xc,-0x30(%rbp)
jne    1200 <time_convert+0xc0>
cmpl   $0x0,-0x2c(%rbp)
jne    11fb <time_convert+0xbb>
movl   $0x0,-0x30(%rbp)
jmp    1218 <time_convert+0xd8>
cmpl   $0x0,-0x2c(%rbp)
je     1213 <time_convert+0xd3>
mov    -0x30(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x30(%rbp)
jmp    1218 <time_convert+0xd8>
mov    -0x30(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_convert>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xead(%rip),%rdi
xor    %r13d,%r13d
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rax,%r12
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rax,%rbx
lea    0xe71(%rip),%rsi
mov    %rax,%rdi
call   1060 <strstr@plt>
mov    %rax,%r14
movb   $0x0,0x2(%rbx)
mov    %r12,%rdi
call   1050 <atoi@plt>
test   %r14,%r14
mov    $0xc,%ecx
cmove  %r13d,%ecx
lea    0xc(%rax),%esi
cmove  %eax,%esi
cmp    $0xc,%eax
cmove  %ecx,%esi
lea    0xe3e(%rip),%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s->\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [12 x i8] c"%02d:%s:%s\0A\00"
define void @time_convert(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %2
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %3
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %4
%14 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i8* @strstr(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %1
store i32 1, i32* %7
br label %21
20: ; preds = %1
store i32 0, i32* %7
br label %21
21: ; preds = %20, %19
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 0, i8* %23
%24 = load i8*, i8** %3
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp eq i32 %26, 12
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %28
store i32 0, i32* %8
br label %32
32: ; preds = %31, %28
br label %40
33: ; preds = %21
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 12
store i32 %38, i32* %8
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39, %32
%41 = load i32, i32* %8
%42 = load i8*, i8** %4
%43 = load i8*, i8** %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %42, i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s->\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [12 x i8] c"%02d:%s:%s\0A\00"
define void @time_convert(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i8* @strstr(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i8* %6, null
%8 = getelementptr inbounds i8, i8* %5, i64 2
store i8 0, i8* %8
%9 = tail call i32 @atoi(i8* %3)
%10 = icmp eq i32 %9, 12
%11 = select i1 %7, i32 0, i32 12
%12 = add nsw i32 %9, 12
%13 = select i1 %7, i32 %9, i32 %12
%14 = select i1 %10, i32 %11, i32 %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %14, i8* %4, i8* %5)
ret void
}