#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 */
struct timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ pulseOrSaveTS(int, struct timespec *, struct timespec *);
void pulseMilli(int gpio, int up, int down) {
  struct timespec tsUP, tsDOWN;
  tsUP.tv_sec = up / 1000;
  tsUP.tv_nsec = (up % 1000) * 1000000;
  tsDOWN.tv_sec = down / 1000;
  tsDOWN.tv_nsec = (down % 1000) * 1000000;
  pulseOrSaveTS(gpio, &tsUP, &tsDOWN);
}


x86 assembly (clang, -O0):
<pulseMilli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0xf4240,%edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0xf4240,%edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <pulseOrSaveTS@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pulseMilli>:
sub    $0x18,%rsp
movslq %esi,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rcx
add    %esi,%ecx
mov    %ecx,0x10(%rsp)
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   $0xf4240,%eax,%eax
mov    %eax,0x14(%rsp)
movslq %edx,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,0x8(%rsp)
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   $0xf4240,%eax,%eax
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <pulseOrSaveTS@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @pulseMilli(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.timespec
%8 = alloca %struct.timespec
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = sdiv i32 %9, 1000
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* %5
%13 = srem i32 %12, 1000
%14 = mul nsw i32 %13, 1000000
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
store i32 %14, i32* %15
%16 = load i32, i32* %6
%17 = sdiv i32 %16, 1000
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
store i32 %17, i32* %18
%19 = load i32, i32* %6
%20 = srem i32 %19, 1000
%21 = mul nsw i32 %20, 1000000
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
store i32 %21, i32* %22
%23 = load i32, i32* %4
%24 = call i32 @pulseOrSaveTS(i32 %23, %struct.timespec* %7, %struct.timespec* %8)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @pulseMilli(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = bitcast %struct.timespec* %4 to i8*
%7 = bitcast %struct.timespec* %5 to i8*
%8 = sdiv i32 %1, 1000
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
store i32 %8, i32* %9
%10 = srem i32 %1, 1000
%11 = mul nsw i32 %10, 1000000
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
store i32 %11, i32* %12
%13 = sdiv i32 %2, 1000
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store i32 %13, i32* %14
%15 = srem i32 %2, 1000
%16 = mul nsw i32 %15, 1000000
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i32 %16, i32* %17
%18 = call i32 @pulseOrSaveTS(i32 %0, %struct.timespec* %4, %struct.timespec* %5)
ret void
}