#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 */
int /*<<< orphan*/ sprintf(char *, char *, double);
void format_latlon(double lat, double lon, char *slat, char *slon) {
  if (lat < 0.)
    sprintf(slat, "%6.2fS", -lat);
  else
    sprintf(slat, "%6.2fN", lat);
  if (lon < 0.)
    sprintf(slon, "%7.2fW", -lon);
  else
    sprintf(slon, "%7.2fE", lon);
}


x86 assembly (clang, -O0):
<format_latlon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1169 <format_latlon+0x59>
mov    -0x18(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
lea    0xea1(%rip),%rsi
call   1030 <sprintf@plt>
jmp    117e <format_latlon+0x6e>
mov    -0x18(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
lea    0xe8e(%rip),%rsi
call   1030 <sprintf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11bd <format_latlon+0xad>
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
lea    0xe5b(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11d2 <format_latlon+0xc2>
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xe48(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_latlon>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movapd %xmm1,(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1138 <format_latlon+0x28>
xorpd  0xed1(%rip),%xmm0
lea    0xeda(%rip),%rsi
jmp    113f <format_latlon+0x2f>
lea    0xed8(%rip),%rsi
call   1030 <sprintf@plt>
xorpd  %xmm0,%xmm0
movapd (%rsp),%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm1,%xmm0
jbe    1168 <format_latlon+0x58>
xorpd  0xea1(%rip),%xmm0
lea    0xeb8(%rip),%rsi
jmp    116f <format_latlon+0x5f>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%6.2fS\00"
@.str.1 = [7 x i8] c"%6.2fN\00"
@.str.2 = [7 x i8] c"%7.2fW\00"
@.str.3 = [7 x i8] c"%7.2fE\00"
define void @format_latlon(double %0, double %1, i8* %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i8*
%8 = alloca i8*
store double %0, double* %5
store double %1, double* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load double, double* %5
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i8*, i8** %7
%13 = load double, double* %5
%14 = fneg double %13
%15 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %14)
br label %20
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = load double, double* %5
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %18)
br label %20
20: ; preds = %16, %11
%21 = load double, double* %6
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %8
%25 = load double, double* %6
%26 = fneg double %25
%27 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %32
28: ; preds = %20
%29 = load i8*, i8** %8
%30 = load double, double* %6
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %30)
br label %32
32: ; preds = %28, %23
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%6.2fS\00"
@.str.1 = [7 x i8] c"%6.2fN\00"
@.str.2 = [7 x i8] c"%7.2fW\00"
@.str.3 = [7 x i8] c"%7.2fE\00"
define void @format_latlon(double %0, double %1, i8* nocapture writeonly %2, i8* nocapture writeonly %3) {
%5 = fcmp olt double %0, 0.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = fneg double %0
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %7)
br label %11
9: ; preds = %4
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %0)
br label %11
11: ; preds = %9, %6
%12 = fcmp olt double %1, 0.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = fneg double %1
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %14)
br label %18
16: ; preds = %11
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %1)
br label %18
18: ; preds = %16, %13
ret void
}