#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ addChecksum(char *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ bzero(char *, int);
double degtodm(int /*<<< orphan*/);
int /*<<< orphan*/ fabs(float);
int /*<<< orphan*/ sprintf(char *, char *, double, char, double, char);
void gen_nmea0183_RMC(uint8_t *b, uint32_t *len, float lat, float lon) {
  char s[255];
  bzero(s, 255);
  sprintf(s, "$GPRMC,%09.4f,%c,%09.4f,%c", degtodm(fabs(lat)),
          ((lat > 0) ? 'N' : 'S'), degtodm(fabs(lon)), ((lon > 0) ? 'E' : 'W'));
  addChecksum(s, b, len);
}


x86 assembly (clang, -O0):
<gen_nmea0183_RMC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0xff,%esi
call   1050 <bzero@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x138(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1070 <degtodm@plt>
movsd  %xmm0,-0x128(%rbp)
ff
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0x53,%eax
mov    $0x4e,%ecx
ucomiss %xmm1,%xmm0
cmova  %ecx,%eax
mov    %al,-0x129(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1070 <degtodm@plt>
mov    -0x138(%rbp),%rdi
mov    -0x129(%rbp),%cl
movaps %xmm0,%xmm1
movsd  -0x128(%rbp),%xmm0
ff
movss  -0x18(%rbp),%xmm2
xorps  %xmm3,%xmm3
mov    $0x57,%eax
mov    $0x45,%edx
ucomiss %xmm3,%xmm2
cmova  %edx,%eax
lea    0xdf5(%rip),%rsi
movsbl %cl,%edx
movsbl %al,%ecx
call   1060 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <addChecksum@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_nmea0183_RMC>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0xff,%esi
call   1050 <bzero@plt>
movss  (%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1070 <degtodm@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
movss  (%rsp),%xmm0
ucomiss %xmm1,%xmm0
setbe  %bl
movss  0x4(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1070 <degtodm@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
ucomiss 0xe36(%rip),%xmm0
mov    $0x45,%eax
mov    $0x57,%ecx
cmova  %eax,%ecx
lea    (%rbx,%rbx,4),%edx
add    $0x4e,%edx
lea    0xe20(%rip),%rsi
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
call   1060 <sprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <addChecksum@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"$GPRMC,%09.4f,%c,%09.4f,%c\00"
define void @gen_nmea0183_RMC(i32* %0, i32* %1, float %2, float %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca float
%8 = alloca float
%9 = alloca [255 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store float %2, float* %7
store float %3, float* %8
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 255)
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%13 = load float, float* %7
%14 = call i32 @fabs(float %13)
%15 = call double @degtodm(i32 %14)
%16 = load float, float* %7
%17 = fcmp ogt float %16, 0.000000e+00
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 78, i32 83
%20 = trunc i32 %19 to i8
%21 = load float, float* %8
%22 = call i32 @fabs(float %21)
%23 = call double @degtodm(i32 %22)
%24 = load float, float* %8
%25 = fcmp ogt float %24, 0.000000e+00
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 69, i32 87
%28 = trunc i32 %27 to i8
%29 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %15, i8 signext %20, double %23, i8 signext %28)
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%31 = load i32*, i32** %5
%32 = load i32*, i32** %6
%33 = call i32 @addChecksum(i8* %30, i32* %31, i32* %32)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"$GPRMC,%09.4f,%c,%09.4f,%c\00"
define void @gen_nmea0183_RMC(i32* %0, i32* %1, float %2, float %3) {
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 255)
%8 = tail call i32 @fabs(float %2)
%9 = tail call double @degtodm(i32 %8)
%10 = fcmp ogt float %2, 0.000000e+00
%11 = select i1 %10, i8 78, i8 83
%12 = tail call i32 @fabs(float %3)
%13 = tail call double @degtodm(i32 %12)
%14 = fcmp ogt float %3, 0.000000e+00
%15 = select i1 %14, i8 69, i8 87
%16 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %9, i8 signext %11, double %13, i8 signext %15)
%17 = call i32 @addChecksum(i8* %6, i32* %0, i32* %1)
ret void
}