#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 character_count(char, char *);
int /*<<< orphan*/ piece_inverse(char *, char, int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ timlib_strcmp(char *, char *);
char *date_remove_colon_from_time(char *time_string) {
  static char buffer[128];
  int str_len;
  char count;
  *buffer = '\0';
  if (timlib_strcmp(time_string, "null") == 0)
    return time_string;
  count = character_count(':', time_string);
  if (count == 0 || count > 2)
    return time_string;
  if (count == 2) {
    piece_inverse(time_string, ':', 2);
  }
  str_len = strlen(time_string);
  if (str_len == 4) {
    *buffer = '0';
    strncpy(buffer + 1, time_string, 1);
    strncpy(buffer + 2, time_string + 2, 2);
    *(buffer + 4) = '\0';
    return buffer;
  } else if (str_len == 5) {
    strncpy(buffer, time_string, 2);
    strncpy(buffer + 2, time_string + 3, 2);
    *(buffer + 4) = '\0';
    return buffer;
  } else {
    return (char *)0;
  }
}


x86 assembly (clang, -O0):
<date_remove_colon_from_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,0x2efd(%rip)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1070 <timlib_strcmp@plt>
cmp    $0x0,%rax
jne    118a <date_remove_colon_from_time+0x3a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a7 <date_remove_colon_from_time+0x157>
mov    -0x10(%rbp),%rsi
mov    $0x3a,%edi
call   1060 <character_count@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
je     11b5 <date_remove_colon_from_time+0x65>
movsbl -0x15(%rbp),%eax
cmp    $0x2,%eax
jle    11c2 <date_remove_colon_from_time+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a7 <date_remove_colon_from_time+0x157>
movsbl -0x15(%rbp),%eax
cmp    $0x2,%eax
jne    11e2 <date_remove_colon_from_time+0x92>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
mov    $0x2,%edx
call   1050 <piece_inverse@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jne    124c <date_remove_colon_from_time+0xfc>
movb   $0x30,0x2e61(%rip)
mov    -0x10(%rbp),%rsi
lea    0x2e56(%rip),%rdi
add    $0x1,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
lea    0x2e39(%rip),%rdi
add    $0x2,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2e28(%rip)
lea    0x2e1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a7 <date_remove_colon_from_time+0x157>
cmpl   $0x5,-0x14(%rbp)
jne    129f <date_remove_colon_from_time+0x14f>
mov    -0x10(%rbp),%rsi
lea    0x2dff(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rsi
add    $0x3,%rsi
lea    0x2de6(%rip),%rdi
add    $0x2,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2dd5(%rip)
lea    0x2dca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a7 <date_remove_colon_from_time+0x157>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_remove_colon_from_time>:
push   %rbx
mov    %rdi,%rbx
movb   $0x0,0x2f05(%rip)
lea    0xe9e(%rip),%rsi
call   1070 <timlib_strcmp@plt>
test   %rax,%rax
je     1217 <date_remove_colon_from_time+0xc7>
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1060 <character_count@plt>
test   %al,%al
je     1217 <date_remove_colon_from_time+0xc7>
cmp    $0x2,%al
jg     1217 <date_remove_colon_from_time+0xc7>
jne    11a1 <date_remove_colon_from_time+0x51>
mov    %rbx,%rdi
mov    $0x3a,%esi
mov    $0x2,%edx
call   1050 <piece_inverse@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x5,%eax
je     11d5 <date_remove_colon_from_time+0x85>
cmp    $0x4,%eax
jne    1215 <date_remove_colon_from_time+0xc5>
movb   $0x30,0x2ea6(%rip)
lea    0x2ea0(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    $0x2,%eax
jmp    11ee <date_remove_colon_from_time+0x9e>
lea    0x2e84(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    $0x3,%eax
add    %rax,%rbx
lea    0x2e6a(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    0x2e54(%rip),%rbx
movb   $0x0,0x2e51(%rip)
jmp    1217 <date_remove_colon_from_time+0xc7>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@date_remove_colon_from_time.buffer = internal global [128 x i8] zeroinitializer
@.str = [5 x i8] c"null\00"
define i8* @date_remove_colon_from_time(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0)
%6 = load i8*, i8** %3
%7 = call i64 @timlib_strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %3
store i8* %10, i8** %2
br label %51
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call signext i8 @character_count(i8 signext 58, i8* %12)
store i8 %13, i8* %5
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %11
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %17, %11
%22 = load i8*, i8** %3
store i8* %22, i8** %2
br label %51
23: ; preds = %17
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %3
%29 = call i32 @piece_inverse(i8* %28, i8 signext 58, i32 2)
br label %30
30: ; preds = %27, %23
%31 = load i8*, i8** %3
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %41
35: ; preds = %30
store i8 48, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0)
%36 = load i8*, i8** %3
%37 = call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 1), i8* %36, i32 1)
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 2
%40 = call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 2), i8* %39, i32 2)
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 4)
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0), i8** %2
br label %51
41: ; preds = %30
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 5
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i8*, i8** %3
%46 = call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0), i8* %45, i32 2)
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 3
%49 = call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 2), i8* %48, i32 2)
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 4)
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0), i8** %2
br label %51
50: ; preds = %41
store i8* null, i8** %2
br label %51
51: ; preds = %50, %44, %35, %21, %9
%52 = load i8*, i8** %2
ret i8* %52
}

LLVM IR (-O2):
@date_remove_colon_from_time.buffer = internal global [128 x i8] zeroinitializer
@.str = [5 x i8] c"null\00"
define i8* @date_remove_colon_from_time(i8* %0) {
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0)
%2 = tail call i64 @timlib_strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = tail call signext i8 @character_count(i8 signext 58, i8* %0)
%6 = icmp eq i8 %5, 0
%7 = icmp sgt i8 %5, 2
%8 = or i1 %6, %7
br i1 %8, label %23, label %9
9: ; preds = %4
%10 = icmp eq i8 %5, 2
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @piece_inverse(i8* %0, i8 signext 58, i32 2)
br label %13
13: ; preds = %11, %9
%14 = tail call i32 @strlen(i8* %0)
switch i32 %14, label %23 [
i32 4, label %15
i32 5, label %17
]
15: ; preds = %13
store i8 48, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0)
%16 = tail call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 1), i8* %0, i32 1)
br label %19
17: ; preds = %13
%18 = tail call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0), i8* %0, i32 2)
br label %19
19: ; preds = %15, %17
%20 = phi i64 [ 3, %17 ], [ 2, %15 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = tail call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 2), i8* %21, i32 2)
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 4)
br label %23
23: ; preds = %19, %13, %4, %1
%24 = phi i8* [ %0, %1 ], [ %0, %4 ], [ null, %13 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @date_remove_colon_from_time.buffer, i64 0, i64 0), %19 ]
ret i8* %24
}