#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 snprintf(char *, int, char *, ...);
int old_time_helper(char *dst, unsigned long long t, unsigned long long rel) {
  if (!t)
    return snprintf(dst, 240, "    -");
  if (t == ~0ULL)
    return snprintf(dst, 240, "   xx");
  if ((long long)(t -= rel) < 0)
    t = 0ULL;
  if (t > 9999ULL)
    return snprintf(dst, 240, "%5Lu", t / 100ULL);
  else
    return snprintf(dst, 240, "%2u.%02u", (unsigned)t / 100U,
                    (unsigned)t % 100U);
}


x86 assembly (clang, -O0):
<old_time_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <old_time_helper+0x3e>
mov    -0x10(%rbp),%rdi
mov    $0xf0,%esi
lea    0xec1(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <old_time_helper+0x100>
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    1178 <old_time_helper+0x68>
mov    -0x10(%rbp),%rdi
mov    $0xf0,%esi
lea    0xe9d(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <old_time_helper+0x100>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    1199 <old_time_helper+0x89>
movq   $0x0,-0x18(%rbp)
cmpq   $0x270f,-0x18(%rbp)
jbe    11d7 <old_time_helper+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    $0xf0,%esi
lea    0xe44(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <old_time_helper+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    $0x64,%esi
xor    %edx,%edx
div    %esi
mov    %edx,%r8d
mov    $0xf0,%esi
lea    0xe0b(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<old_time_helper>:
cmp    $0xffffffffffffffff,%rsi
je     1124 <old_time_helper+0x14>
test   %rsi,%rsi
jne    1137 <old_time_helper+0x27>
lea    0xede(%rip),%rdx
jmp    112b <old_time_helper+0x1b>
lea    0xedb(%rip),%rdx
mov    $0xf0,%esi
xor    %eax,%eax
jmp    1030 <snprintf@plt>
xor    %eax,%eax
sub    %rdx,%rsi
cmovns %rsi,%rax
cmp    $0x2710,%rax
jb     1173 <old_time_helper+0x63>
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
mul    %rcx
mov    %rdx,%rcx
shr    $0x2,%rcx
lea    0xea5(%rip),%rdx
mov    $0xf0,%esi
xor    %eax,%eax
jmp    1030 <snprintf@plt>
movzwl %ax,%ecx
shr    $0x2,%ecx
imul   $0x147b,%ecx,%ecx
shr    $0x11,%ecx
imul   $0x64,%ecx,%edx
sub    %edx,%eax
movzwl %ax,%r8d
lea    0xe7f(%rip),%rdx
mov    $0xf0,%esi
xor    %eax,%eax
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c" -\00"
@.str.1 = [6 x i8] c" xx\00"
@.str.2 = [5 x i8] c"%5Lu\00"
@.str.3 = [9 x i8] c"%2u.%02u\00"
define i32 @old_time_helper(i8* %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %6
%9 = icmp ne i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 240, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %4
br label %42
13: ; preds = %3
%14 = load i64, i64* %6
%15 = icmp eq i64 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i8*, i8** %5
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %17, i32 240, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %4
br label %42
19: ; preds = %13
%20 = load i64, i64* %7
%21 = load i64, i64* %6
%22 = sub i64 %21, %20
store i64 %22, i64* %6
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i64 0, i64* %6
br label %25
25: ; preds = %24, %19
%26 = load i64, i64* %6
%27 = icmp ugt i64 %26, 9999
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i8*, i8** %5
%30 = load i64, i64* %6
%31 = udiv i64 %30, 100
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %29, i32 240, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %31)
store i32 %32, i32* %4
br label %42
33: ; preds = %25
%34 = load i8*, i8** %5
%35 = load i64, i64* %6
%36 = trunc i64 %35 to i32
%37 = udiv i32 %36, 100
%38 = load i64, i64* %6
%39 = trunc i64 %38 to i32
%40 = urem i32 %39, 100
%41 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %34, i32 240, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %40)
store i32 %41, i32* %4
br label %42
42: ; preds = %33, %28, %16, %10
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c" -\00"
@.str.1 = [6 x i8] c" xx\00"
@.str.2 = [5 x i8] c"%5Lu\00"
@.str.3 = [9 x i8] c"%2u.%02u\00"
define i32 @old_time_helper(i8* %0, i64 %1, i64 %2) {
switch i64 %1, label %8 [
i64 0, label %4
i64 -1, label %6
]
4: ; preds = %3
%5 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 240, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %23
6: ; preds = %3
%7 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 240, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %23
8: ; preds = %3
%9 = sub i64 %1, %2
%10 = icmp sgt i64 %9, 0
%11 = select i1 %10, i64 %9, i64 0
%12 = icmp ugt i64 %11, 9999
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = udiv i64 %11, 100
%15 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 240, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %14)
br label %23
16: ; preds = %8
%17 = trunc i64 %11 to i16
%18 = udiv i16 %17, 100
%19 = zext i16 %18 to i32
%20 = urem i16 %17, 100
%21 = zext i16 %20 to i32
%22 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 240, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %21)
br label %23
23: ; preds = %16, %13, %6, %4
%24 = phi i32 [ %7, %6 ], [ %15, %13 ], [ %22, %16 ], [ %5, %4 ]
ret i32 %24
}