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

/* Variables and functions */
int /*<<< orphan*/ computeHexNMEAChecksum(char const *, size_t);
int /*<<< orphan*/ ubloxLLDWrite(void *, char const *, int);
void sendNMEAMsgAndChecksum(void *serialPort, const char *msg, size_t size) {
  ubloxLLDWrite(serialPort, msg, size);
  uint16_t chksum = computeHexNMEAChecksum(msg + 1, size - 2);
  ubloxLLDWrite(serialPort, (const char *)&chksum, 2);
  ubloxLLDWrite(serialPort, "\r\n", 2);
}


x86 assembly (clang, -O0):
<sendNMEAMsgAndChecksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
call   1030 <ubloxLLDWrite@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
sub    $0x2,%rsi
call   1040 <computeHexNMEAChecksum@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x2,%edx
call   1030 <ubloxLLDWrite@plt>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x2,%edx
call   1030 <ubloxLLDWrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendNMEAMsgAndChecksum>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <ubloxLLDWrite@plt>
add    $0x1,%rbx
add    $0xfffffffffffffffe,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <computeHexNMEAChecksum@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <ubloxLLDWrite@plt>
lea    0xe99(%rip),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <ubloxLLDWrite@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
define void @sendNMEAMsgAndChecksum(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = trunc i64 %10 to i32
%12 = call i32 @ubloxLLDWrite(i8* %8, i8* %9, i32 %11)
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i64, i64* %6
%16 = sub i64 %15, 2
%17 = call i32 @computeHexNMEAChecksum(i8* %14, i64 %16)
store i32 %17, i32* %7
%18 = load i8*, i8** %4
%19 = bitcast i32* %7 to i8*
%20 = call i32 @ubloxLLDWrite(i8* %18, i8* %19, i32 2)
%21 = load i8*, i8** %4
%22 = call i32 @ubloxLLDWrite(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define void @sendNMEAMsgAndChecksum(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = trunc i64 %2 to i32
%6 = tail call i32 @ubloxLLDWrite(i8* %0, i8* %1, i32 %5)
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = add i64 %2, -2
%10 = tail call i32 @computeHexNMEAChecksum(i8* %8, i64 %9)
store i32 %10, i32* %4
%11 = call i32 @ubloxLLDWrite(i8* %0, i8* %7, i32 2)
%12 = call i32 @ubloxLLDWrite(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
ret void
}