#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int tobcd(int);
void set_msf(uint8_t *p, uint32_t blk) {
  uint8_t m = blk / 4500;
  uint16_t sf = blk % 4500;
  uint8_t s = sf / 75;
  uint8_t f = sf % 75;
  p[0] = tobcd(m);
  p[1] = tobcd(s);
  p[2] = tobcd(f);
}


x86 assembly (clang, -O0):
<set_msf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x1194,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x1194,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4b,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4b,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <tobcd@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%edi
call   1030 <tobcd@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%edi
call   1030 <tobcd@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_msf>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
movslq %esi,%rax
imul   $0x7482296b,%rax,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
sar    $0x2b,%rdi
add    %ecx,%edi
imul   $0x1194,%edi,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0xffffda75,%ecx,%ecx
shr    $0x10,%ecx
add    %eax,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
sar    $0x6,%edx
add    %ecx,%edx
movswl %dx,%ebp
imul   $0x4b,%edx,%ecx
sub    %ecx,%eax
movswl %ax,%ebx
call   1030 <tobcd@plt>
mov    %eax,(%r14)
mov    %ebp,%edi
call   1030 <tobcd@plt>
mov    %eax,0x4(%r14)
mov    %ebx,%edi
call   1030 <tobcd@plt>
mov    %eax,0x8(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @set_msf(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = sdiv i32 %9, 4500
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = srem i32 %11, 4500
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = sdiv i32 %13, 75
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = srem i32 %15, 75
store i32 %16, i32* %8
%17 = load i32, i32* %5
%18 = call i32 @tobcd(i32 %17)
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %18, i32* %20
%21 = load i32, i32* %7
%22 = call i32 @tobcd(i32 %21)
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 1
store i32 %22, i32* %24
%25 = load i32, i32* %8
%26 = call i32 @tobcd(i32 %25)
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 2
store i32 %26, i32* %28
ret void
}

LLVM IR (-O2):
define void @set_msf(i32* nocapture writeonly %0, i32 %1) {
%3 = sdiv i32 %1, 4500
%4 = srem i32 %1, 4500
%5 = trunc i32 %4 to i16
%6 = sdiv i16 %5, 75
%7 = sext i16 %6 to i32
%8 = srem i16 %5, 75
%9 = sext i16 %8 to i32
%10 = tail call i32 @tobcd(i32 %3)
store i32 %10, i32* %0
%11 = tail call i32 @tobcd(i32 %7)
%12 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %11, i32* %12
%13 = tail call i32 @tobcd(i32 %9)
%14 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %13, i32* %14
ret void
}