#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 character_count(char, char *);
int /*<<< orphan*/ column(char *, int, char *);
int /*<<< orphan*/ piece_inverse(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ timlib_delete_character(char *, char);
char *to_hhmm(char *d, char *s) {
  char time_only[128];
  if (!column(time_only, 1, s))
    return (char *)0;
  if (character_count(':', time_only) == 2) {
    piece_inverse(time_only, ':', 2);
  }
  timlib_delete_character(time_only, ':');
  sprintf(d, "%04d", atoi(time_only));
  return d;
}


x86 assembly (clang, -O0):
<to_hhmm>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1,%esi
call   1050 <column@plt>
cmp    $0x0,%eax
jne    119e <to_hhmm+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    1213 <to_hhmm+0xb3>
lea    -0xa0(%rbp),%rsi
mov    $0x3a,%edi
call   1040 <character_count@plt>
cmp    $0x2,%eax
jne    11ce <to_hhmm+0x6e>
lea    -0xa0(%rbp),%rdi
mov    $0x3a,%esi
mov    $0x2,%edx
call   1030 <piece_inverse@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <timlib_delete_character@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1070 <atoi@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%edx
lea    0xdfa(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_hhmm>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
call   1050 <column@plt>
test   %eax,%eax
je     11d0 <to_hhmm+0x70>
mov    %rsp,%rsi
mov    $0x3a,%edi
call   1040 <character_count@plt>
cmp    $0x2,%eax
jne    11a5 <to_hhmm+0x45>
mov    %rsp,%rdi
mov    $0x3a,%esi
mov    $0x2,%edx
call   1030 <piece_inverse@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3a,%esi
call   1060 <timlib_delete_character@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
lea    0xe3c(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1080 <sprintf@plt>
jmp    11d2 <to_hhmm+0x72>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%04d\00"
define i8* @to_hhmm(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [128 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %5
%9 = call i32 @column(i8* %7, i32 1, i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i8* null, i8** %3
br label %27
12: ; preds = %2
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%14 = call i32 @character_count(i8 signext 58, i8* %13)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%18 = call i32 @piece_inverse(i8* %17, i8 signext 58, i32 2)
br label %19
19: ; preds = %16, %12
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%21 = call i32 @timlib_delete_character(i8* %20, i8 signext 58)
%22 = load i8*, i8** %4
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
%25 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %4
store i8* %26, i8** %3
br label %27
27: ; preds = %19, %11
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@.str = [5 x i8] c"%04d\00"
define i8* @to_hhmm(i8* writeonly %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = call i32 @column(i8* %4, i32 1, i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = call i32 @character_count(i8 signext 58, i8* %4)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @piece_inverse(i8* %4, i8 signext 58, i32 2)
br label %12
12: ; preds = %10, %7
%13 = call i32 @timlib_delete_character(i8* %4, i8 signext 58)
%14 = call i32 @atoi(i8* %4)
%15 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %2, %12
%17 = phi i8* [ %0, %12 ], [ null, %2 ]
ret i8* %17
}