#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 suseconds_t;

/* Variables and functions */
void set_msec(char *timestamp, suseconds_t msec) {
  timestamp[22] = '0' + msec % 10;
  timestamp[21] = '0' + (msec % 100) / 10;
  timestamp[20] = '0' + (msec % 1000) / 100;
}


x86 assembly (clang, -O0):
<set_msec>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x16(%rax)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x15(%rax)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x14(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_msec>:
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
add    $0x30,%dl
mov    %dl,0x16(%rdi)
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
movsbl %dl,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0xa,%edx
add    %cl,%dl
add    $0x30,%dl
mov    %dl,0x15(%rdi)
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
cwtl
imul   $0x147b,%eax,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x13,%eax
add    %ecx,%eax
add    $0x30,%al
mov    %al,0x14(%rdi)
ret

LLVM IR (-O0):
define void @set_msec(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = srem i32 %5, 10
%7 = add nsw i32 48, %6
%8 = trunc i32 %7 to i8
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 22
store i8 %8, i8* %10
%11 = load i32, i32* %4
%12 = srem i32 %11, 100
%13 = sdiv i32 %12, 10
%14 = add nsw i32 48, %13
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 21
store i8 %15, i8* %17
%18 = load i32, i32* %4
%19 = srem i32 %18, 1000
%20 = sdiv i32 %19, 100
%21 = add nsw i32 48, %20
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 20
store i8 %22, i8* %24
ret void
}

LLVM IR (-O2):
define void @set_msec(i8* nocapture writeonly %0, i32 %1) {
%3 = srem i32 %1, 10
%4 = trunc i32 %3 to i8
%5 = add nsw i8 %4, 48
%6 = getelementptr inbounds i8, i8* %0, i64 22
store i8 %5, i8* %6
%7 = srem i32 %1, 100
%8 = trunc i32 %7 to i8
%9 = sdiv i8 %8, 10
%10 = add nsw i8 %9, 48
%11 = getelementptr inbounds i8, i8* %0, i64 21
store i8 %10, i8* %11
%12 = srem i32 %1, 1000
%13 = trunc i32 %12 to i16
%14 = sdiv i16 %13, 100
%15 = trunc i16 %14 to i8
%16 = add nsw i8 %15, 48
%17 = getelementptr inbounds i8, i8* %0, i64 20
store i8 %16, i8* %17
ret void
}