#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 */

/* Variables and functions */
unsigned char *addnum(unsigned char *, long, int, char);
void asdms1(unsigned char *r, double v, long max, unsigned char degsym) {
  long d, m, s;
  if (v < 0) {
    *r++ = '-';
    v = -v;
  }
  s = (long)(3600 * v + 0.5);
  if (s > max)
    s = max;
  d = s / 3600;
  r = addnum(r, d, 0, degsym);
  s %= 3600;
  if (s) {
    m = s / 60;
    r = addnum(r, m, 1, '\'');
    s %= 60;
    if (s)
      r = addnum(r, s, 1, '\"');
  }
}


x86 assembly (clang, -O0):
<asdms1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116b <asdms1+0x5b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2d,(%rax)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe84(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    11a7 <asdms1+0x97>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
movsbl -0x19(%rbp),%ecx
call   1030 <addnum@plt>
mov    %rax,-0x8(%rbp)
mov    -0x38(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1257 <asdms1+0x147>
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x1,%edx
mov    $0x27,%ecx
call   1030 <addnum@plt>
mov    %rax,-0x8(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1252 <asdms1+0x142>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x1,%edx
mov    $0x22,%ecx
call   1030 <addnum@plt>
mov    %rax,-0x8(%rbp)
jmp    1257 <asdms1+0x147>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asdms1>:
push   %r14
push   %rbx
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    112d <asdms1+0x1d>
movb   $0x2d,(%rdi)
add    $0x1,%rdi
xorpd  0xed3(%rip),%xmm0
mulsd  0xedb(%rip),%xmm0
addsd  0xedb(%rip),%xmm0
cvttsd2si %xmm0,%r14
cmp    %rsi,%r14
cmovg  %rsi,%r14
movsbl %dl,%ecx
movabs $0x48d159e26af37c05,%rdx
59 d1 48
mov    %r14,%rax
imul   %rdx
mov    %rdx,%rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xa,%rbx
add    %rax,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <addnum@plt>
imul   $0xe10,%rbx,%rcx
sub    %rcx,%r14
je     11dd <asdms1+0xcd>
movswl %r14w,%ecx
imul   $0xffff8889,%ecx,%ecx
shr    $0x10,%ecx
add    %r14d,%ecx
movzwl %cx,%ecx
movswl %cx,%ebx
shr    $0xf,%ecx
sar    $0x5,%ebx
add    %ecx,%ebx
movswq %bx,%rsi
mov    %rax,%rdi
mov    $0x1,%edx
mov    $0x27,%ecx
call   1030 <addnum@plt>
imul   $0x3c,%ebx,%ecx
sub    %cx,%r14w
je     11dd <asdms1+0xcd>
movswq %r14w,%rsi
mov    %rax,%rdi
mov    $0x1,%edx
mov    $0x22,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <addnum@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @asdms1(i8* %0, double %1, i64 %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca double
%7 = alloca i64
%8 = alloca i8
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %5
store double %1, double* %6
store i64 %2, i64* %7
store i8 %3, i8* %8
%12 = load double, double* %6
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %19
14: ; preds = %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
store i8 45, i8* %15
%17 = load double, double* %6
%18 = fneg double %17
store double %18, double* %6
br label %19
19: ; preds = %14, %4
%20 = load double, double* %6
%21 = call double @llvm.fmuladd.f64(double 3.600000e+03, double %20, double 5.000000e-01)
%22 = fptosi double %21 to i64
store i64 %22, i64* %11
%23 = load i64, i64* %11
%24 = load i64, i64* %7
%25 = icmp sgt i64 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i64, i64* %7
store i64 %27, i64* %11
br label %28
28: ; preds = %26, %19
%29 = load i64, i64* %11
%30 = sdiv i64 %29, 3600
store i64 %30, i64* %9
%31 = load i8*, i8** %5
%32 = load i64, i64* %9
%33 = load i8, i8* %8
%34 = call i8* @addnum(i8* %31, i64 %32, i32 0, i8 signext %33)
store i8* %34, i8** %5
%35 = load i64, i64* %11
%36 = srem i64 %35, 3600
store i64 %36, i64* %11
%37 = load i64, i64* %11
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %28
%40 = load i64, i64* %11
%41 = sdiv i64 %40, 60
store i64 %41, i64* %10
%42 = load i8*, i8** %5
%43 = load i64, i64* %10
%44 = call i8* @addnum(i8* %42, i64 %43, i32 1, i8 signext 39)
store i8* %44, i8** %5
%45 = load i64, i64* %11
%46 = srem i64 %45, 60
store i64 %46, i64* %11
%47 = load i64, i64* %11
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %39
%50 = load i8*, i8** %5
%51 = load i64, i64* %11
%52 = call i8* @addnum(i8* %50, i64 %51, i32 1, i8 signext 34)
store i8* %52, i8** %5
br label %53
53: ; preds = %49, %39
br label %54
54: ; preds = %53, %28
ret void
}

LLVM IR (-O2):
define void @asdms1(i8* %0, double %1, i64 %2, i8 zeroext %3) {
%5 = fcmp olt double %1, 0.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8 45, i8* %0
%8 = fneg double %1
br label %9
9: ; preds = %6, %4
%10 = phi double [ %8, %6 ], [ %1, %4 ]
%11 = phi i8* [ %7, %6 ], [ %0, %4 ]
%12 = tail call double @llvm.fmuladd.f64(double %10, double 3.600000e+03, double 5.000000e-01)
%13 = fptosi double %12 to i64
%14 = icmp sgt i64 %13, %2
%15 = select i1 %14, i64 %2, i64 %13
%16 = sdiv i64 %15, 3600
%17 = tail call i8* @addnum(i8* %11, i64 %16, i32 0, i8 signext %3)
%18 = srem i64 %15, 3600
%19 = icmp eq i64 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %9
%21 = trunc i64 %18 to i16
%22 = sdiv i16 %21, 60
%23 = sext i16 %22 to i64
%24 = tail call i8* @addnum(i8* %17, i64 %23, i32 1, i8 signext 39)
%25 = srem i16 %21, 60
%26 = icmp eq i16 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = sext i16 %25 to i64
%29 = tail call i8* @addnum(i8* %24, i64 %28, i32 1, i8 signext 34)
br label %30
30: ; preds = %20, %27, %9
ret void
}