#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void PrintTime(int milli_sec, FILE *file) {
  int v = milli_sec;
  int hours = v / (1000 * 60 * 60);
  v %= (1000 * 60 * 60);
  int minutes = v / (1000 * 60);
  v %= (1000 * 60);
  int seconds = v / 1000000;
  v %= 1000000;
  int milli_seconds = v / 1000;
  v %= 1000;
  ;
  int nano_seconds = v;
  int first = 1;
  fprintf(file, "%d[", milli_sec);
  if (hours) {
    if (!first)
      fprintf(file, ":");
    fprintf(file, "%dh", hours);
    first = 0;
  }
  if (minutes) {
    if (!first)
      fprintf(file, ":");
    fprintf(file, "%dm", minutes);
    first = 0;
  }
  if (seconds) {
    if (!first)
      fprintf(file, ":");
    fprintf(file, "%ds", seconds);
    first = 0;
  }
  if (milli_seconds) {
    if (!first)
      fprintf(file, ":");
    fprintf(file, "%dms", milli_seconds);
    first = 0;
  }
  if (nano_seconds) {
    if (!first)
      fprintf(file, ":");
    fprintf(file, "%dns", nano_seconds);
    first = 0;
  }
  fprintf(file, "]");
}


x86 assembly (clang, -O0):
<PrintTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x36ee80,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x36ee80,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xea60,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xea60,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x18(%rbp)
je     11f9 <PrintTime+0xe9>
cmpl   $0x0,-0x2c(%rbp)
jne    11dd <PrintTime+0xcd>
mov    -0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     123b <PrintTime+0x12b>
cmpl   $0x0,-0x2c(%rbp)
jne    121f <PrintTime+0x10f>
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     127d <PrintTime+0x16d>
cmpl   $0x0,-0x2c(%rbp)
jne    1261 <PrintTime+0x151>
mov    -0x10(%rbp),%rdi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12bf <PrintTime+0x1af>
cmpl   $0x0,-0x2c(%rbp)
jne    12a3 <PrintTime+0x193>
mov    -0x10(%rbp),%rdi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1301 <PrintTime+0x1f1>
cmpl   $0x0,-0x2c(%rbp)
jne    12e5 <PrintTime+0x1d5>
mov    -0x10(%rbp),%rdi
lea    0xd26(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rdx
movslq %edi,%rbp
imul   $0x4a90be59,%rbp,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x34,%rbx
add    %eax,%ebx
imul   $0x36ee80,%ebx,%eax
mov    %ebp,%r15d
sub    %eax,%r15d
movslq %r15d,%r14
imul   $0x45e7b273,%r14,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x2e,%r13
add    %eax,%r13d
imul   $0xea60,%r13d,%eax
sub    %eax,%r14d
movslq %r14d,%rcx
imul   $0x10624dd3,%rcx,%r12
mov    %r12,%rax
shr    $0x3f,%rax
sar    $0x26,%r12
add    %eax,%r12d
imul   $0x3e8,%r12d,%eax
sub    %eax,%ecx
mov    %rcx,0x10(%rsp)
lea    0xe5d(%rip),%rsi
mov    %rdx,0x8(%rsp)
mov    %rdx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x36ee7f,%ebp
cmp    $0x6ddcfe,%ebp
ja     11f9 <PrintTime+0xd9>
add    $0xea5f,%r15d
cmp    $0x1d4bf,%r15d
mov    0x8(%rsp),%rbx
jae    1231 <PrintTime+0x111>
add    $0x3e7,%r14d
cmp    $0x7cf,%r14d
mov    0x10(%rsp),%rbp
jae    1267 <PrintTime+0x147>
test   %ebp,%ebp
jne    128c <PrintTime+0x16c>
jmp    129f <PrintTime+0x17f>
lea    0xe04(%rip),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0xea5f,%r15d
cmp    $0x1d4bf,%r15d
mov    %rbp,%rbx
jb     1245 <PrintTime+0x125>
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xdd0(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x3e7,%r14d
cmp    $0x7cf,%r14d
mov    0x10(%rsp),%rbp
jb     127b <PrintTime+0x15b>
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xd9e(%rip),%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %ebp,%ebp
je     129f <PrintTime+0x17f>
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xd7e(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x5d,%edi
mov    %rbx,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d[\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [4 x i8] c"%dh\00"
@.str.3 = [4 x i8] c"%dm\00"
@.str.4 = [4 x i8] c"%ds\00"
@.str.5 = [5 x i8] c"%dms\00"
@.str.6 = [5 x i8] c"%dns\00"
@.str.7 = [2 x i8] c"]\00"
define void @PrintTime(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%12 = load i32, i32* %3
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sdiv i32 %13, 3600000
store i32 %14, i32* %6
%15 = load i32, i32* %5
%16 = srem i32 %15, 3600000
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = sdiv i32 %17, 60000
store i32 %18, i32* %7
%19 = load i32, i32* %5
%20 = srem i32 %19, 60000
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = sdiv i32 %21, 1000000
store i32 %22, i32* %8
%23 = load i32, i32* %5
%24 = srem i32 %23, 1000000
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = sdiv i32 %25, 1000
store i32 %26, i32* %9
%27 = load i32, i32* %5
%28 = srem i32 %27, 1000
store i32 %28, i32* %5
%29 = load i32, i32* %5
store i32 %29, i32* %10
store i32 1, i32* %11
%30 = load i32*, i32** %4
%31 = load i32, i32* %3
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %2
%36 = load i32, i32* %11
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32*, i32** %4
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %38, %35
%42 = load i32*, i32** %4
%43 = load i32, i32* %6
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
store i32 0, i32* %11
br label %45
45: ; preds = %41, %2
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i32, i32* %11
%50 = icmp ne i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32*, i32** %4
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %51, %48
%55 = load i32*, i32** %4
%56 = load i32, i32* %7
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %56)
store i32 0, i32* %11
br label %58
58: ; preds = %54, %45
%59 = load i32, i32* %8
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load i32, i32* %11
%63 = icmp ne i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %61
%65 = load i32*, i32** %4
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %67
67: ; preds = %64, %61
%68 = load i32*, i32** %4
%69 = load i32, i32* %8
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %69)
store i32 0, i32* %11
br label %71
71: ; preds = %67, %58
%72 = load i32, i32* %9
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %84
74: ; preds = %71
%75 = load i32, i32* %11
%76 = icmp ne i32 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i32*, i32** %4
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %80
80: ; preds = %77, %74
%81 = load i32*, i32** %4
%82 = load i32, i32* %9
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %82)
store i32 0, i32* %11
br label %84
84: ; preds = %80, %71
%85 = load i32, i32* %10
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %97
87: ; preds = %84
%88 = load i32, i32* %11
%89 = icmp ne i32 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = load i32*, i32** %4
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %93
93: ; preds = %90, %87
%94 = load i32*, i32** %4
%95 = load i32, i32* %10
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %95)
store i32 0, i32* %11
br label %97
97: ; preds = %93, %84
%98 = load i32*, i32** %4
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d[\00"
@.str.2 = [4 x i8] c"%dh\00"
@.str.3 = [4 x i8] c"%dm\00"
@.str.5 = [5 x i8] c"%dms\00"
@.str.6 = [5 x i8] c"%dns\00"
define void @PrintTime(i32 %0, i32* nocapture %1) {
%3 = srem i32 %0, 3600000
%4 = sdiv i32 %0, 3600000
%5 = sdiv i32 %3, 60000
%6 = srem i32 %3, 60000
%7 = sdiv i32 %6, 1000
%8 = srem i32 %6, 1000
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = add i32 %0, 3599999
%11 = icmp ult i32 %10, 7199999
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = add nsw i32 %3, 59999
%14 = icmp ult i32 %13, 119999
br i1 %14, label %26, label %21
15: ; preds = %2
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%17 = add nsw i32 %3, 59999
%18 = icmp ult i32 %17, 119999
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = tail call i32 @fputc(i32 58, i32* %1)
br label %21
21: ; preds = %12, %19
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %23
23: ; preds = %15, %21
%24 = add nsw i32 %6, 999
%25 = icmp ult i32 %24, 1999
br i1 %25, label %33, label %29
26: ; preds = %12
%27 = add nsw i32 %6, 999
%28 = icmp ult i32 %27, 1999
br i1 %28, label %35, label %31
29: ; preds = %23
%30 = tail call i32 @fputc(i32 58, i32* %1)
br label %31
31: ; preds = %26, %29
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %7)
br label %33
33: ; preds = %31, %23
%34 = icmp eq i32 %8, 0
br i1 %34, label %41, label %37
35: ; preds = %26
%36 = icmp eq i32 %8, 0
br i1 %36, label %41, label %39
37: ; preds = %33
%38 = tail call i32 @fputc(i32 58, i32* %1)
br label %39
39: ; preds = %35, %37
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %8)
br label %41
41: ; preds = %35, %39, %33
%42 = tail call i32 @fputc(i32 93, i32* %1)
ret void
}