#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 long long int64_t;

/* Variables and functions */
void hazer_format_nanominutes2position(int64_t nanominutes, int *degreesp,
                                       int *minutesp, int *secondsp,
                                       int *thousandthsp, int *directionp) {
  if (nanominutes < 0) {
    nanominutes = -nanominutes;
    *directionp = -1;
  } else {
    *directionp = 1;
  }
  *degreesp = nanominutes / 60000000000LL;
  nanominutes = nanominutes % 60000000000LL;
  *minutesp = nanominutes / 1000000000LL;
  nanominutes = nanominutes % 1000000000LL;
  ;
  nanominutes *= 60LL;
  *secondsp = nanominutes / 1000000000LL;
  nanominutes = nanominutes % 1000000000LL;
  *thousandthsp = (nanominutes * 1000LL) / 1000000000LL;
}


x86 assembly (clang, -O0):
<hazer_format_nanominutes2position>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    1140 <hazer_format_nanominutes2position+0x40>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    114a <hazer_format_nanominutes2position+0x4a>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movabs $0xdf8475800,%rcx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movabs $0xdf8475800,%rcx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
imul   $0x3c,-0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
imul   $0x3e8,-0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<hazer_format_nanominutes2position>:
push   %rbx
mov    %rdx,%r10
xor    %eax,%eax
test   %rdi,%rdi
setns  %al
add    %eax,%eax
add    $0xffffffff,%eax
mov    %rdi,%r11
neg    %r11
cmovs  %rdi,%r11
mov    %eax,(%r9)
mov    %r11,%rax
shr    $0xb,%rax
movabs $0x9299ff347e9e9,%rdx
mul    %rdx
mov    %rdx,%r9
shr    $0xc,%r9
movabs $0xdf8475800,%rax
imul   %r9,%rax
sub    %rax,%r11
mov    %r11,%rax
shr    $0x9,%rax
movabs $0x44b82fa09b5a53,%rbx
mul    %rbx
mov    %rdx,%rdi
mov    %r9d,(%rsi)
shr    $0xb,%rdi
imul   $0x3b9aca00,%rdi,%rax
sub    %rax,%r11
imul   $0x3c,%r11,%rsi
mov    %rsi,%rax
shr    $0x9,%rax
mul    %rbx
mov    %edi,(%r10)
shr    $0xb,%rdx
mov    %edx,(%rcx)
imul   $0x3b9aca00,%rdx,%rax
sub    %rax,%rsi
imul   $0x431bde83,%rsi,%rax
shr    $0x32,%rax
mov    %eax,(%r8)
pop    %rbx
ret

LLVM IR (-O0):
define void @hazer_format_nanominutes2position(i64 %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
store i64 %0, i64* %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%13 = load i64, i64* %7
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %6
%16 = load i64, i64* %7
%17 = sub nsw i64 0, %16
store i64 %17, i64* %7
%18 = load i32*, i32** %12
store i32 -1, i32* %18
br label %21
19: ; preds = %6
%20 = load i32*, i32** %12
store i32 1, i32* %20
br label %21
21: ; preds = %19, %15
%22 = load i64, i64* %7
%23 = sdiv i64 %22, 60000000000
%24 = trunc i64 %23 to i32
%25 = load i32*, i32** %8
store i32 %24, i32* %25
%26 = load i64, i64* %7
%27 = srem i64 %26, 60000000000
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = sdiv i64 %28, 1000000000
%30 = trunc i64 %29 to i32
%31 = load i32*, i32** %9
store i32 %30, i32* %31
%32 = load i64, i64* %7
%33 = srem i64 %32, 1000000000
store i64 %33, i64* %7
%34 = load i64, i64* %7
%35 = mul nsw i64 %34, 60
store i64 %35, i64* %7
%36 = load i64, i64* %7
%37 = sdiv i64 %36, 1000000000
%38 = trunc i64 %37 to i32
%39 = load i32*, i32** %10
store i32 %38, i32* %39
%40 = load i64, i64* %7
%41 = srem i64 %40, 1000000000
store i64 %41, i64* %7
%42 = load i64, i64* %7
%43 = mul nsw i64 %42, 1000
%44 = sdiv i64 %43, 1000000000
%45 = trunc i64 %44 to i32
%46 = load i32*, i32** %11
store i32 %45, i32* %46
ret void
}

LLVM IR (-O2):
define void @hazer_format_nanominutes2position(i64 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = icmp slt i64 %0, 0
%8 = sub nsw i64 0, %0
%9 = select i1 %7, i32 -1, i32 1
%10 = select i1 %7, i64 %8, i64 %0
store i32 %9, i32* %5
%11 = udiv i64 %10, 60000000000
%12 = trunc i64 %11 to i32
store i32 %12, i32* %1
%13 = urem i64 %10, 60000000000
%14 = udiv i64 %13, 1000000000
%15 = trunc i64 %14 to i32
store i32 %15, i32* %2
%16 = urem i64 %13, 1000000000
%17 = mul nuw nsw i64 %16, 60
%18 = udiv i64 %17, 1000000000
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
%20 = urem i64 %17, 1000000000
%21 = trunc i64 %20 to i32
%22 = udiv i32 %21, 1000000
store i32 %22, i32* %4
ret void
}