#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*/ CFG_MSG_ZDA;
typedef int /*<<< orphan*/ CFG_MSG_VTG;
typedef int /*<<< orphan*/ CFG_MSG_RMC;
typedef int /*<<< orphan*/ CFG_MSG_GSV;
typedef int /*<<< orphan*/ CFG_MSG_GSA;
typedef int /*<<< orphan*/ CFG_MSG_GLL;
typedef int /*<<< orphan*/ CFG_MSG_GGA;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int txMsg(char *, int, int, int);
int turnOffNMEA(int fd) {
  int n, success = 0;
  int nwrt = 0, doprint, i;
  char CFG_MSG_GLL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_ZDA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x08,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  char CFG_MSG_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  if (!(success = txMsg(CFG_MSG_GLL, sizeof(CFG_MSG_GLL), fd, 10)))
    printf("couldn't turn off GLL: %d\n", success);
  if (!(success = txMsg(CFG_MSG_GGA, sizeof(CFG_MSG_GGA), fd, 10)))
    printf("couldn't turn off GGA\n");
  if (!(success = txMsg(CFG_MSG_GSV, sizeof(CFG_MSG_GSV), fd, 10)))
    printf("couldn't turn off GSV\n");
  if (!(success = txMsg(CFG_MSG_GSA, sizeof(CFG_MSG_GSA), fd, 10)))
    printf("couldn't turn off GSA\n");
  if (!(success = txMsg(CFG_MSG_ZDA, sizeof(CFG_MSG_ZDA), fd, 10)))
    printf("couldn't turn off ZDA\n");
  if (!(success = txMsg(CFG_MSG_RMC, sizeof(CFG_MSG_RMC), fd, 10)))
    printf("couldn't turn off RMC\n");
  if (!(success = txMsg(CFG_MSG_VTG, sizeof(CFG_MSG_VTG), fd, 10)))
    printf("couldn't turn off VTG\n");
}


x86 assembly (clang, -O0):
<turnOffNMEA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xea2(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    120f <turnOffNMEA+0xef>
mov    -0x10(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    123f <turnOffNMEA+0x11f>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    126f <turnOffNMEA+0x14f>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    129f <turnOffNMEA+0x17f>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    12cf <turnOffNMEA+0x1af>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    12ff <turnOffNMEA+0x1df>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x10,%esi
mov    $0xa,%ecx
call   1040 <txMsg@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    1332 <turnOffNMEA+0x212>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turnOffNMEA>:
push   %rbx
sub    $0x70,%rsp
mov    %edi,%ebx
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x60(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    11b4 <turnOffNMEA+0x84>
lea    0xec5(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x50(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    11da <turnOffNMEA+0xaa>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    1200 <turnOffNMEA+0xd0>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0x40(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    1226 <turnOffNMEA+0xf6>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    124c <turnOffNMEA+0x11c>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    1272 <turnOffNMEA+0x142>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x10,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
call   1050 <txMsg@plt>
test   %eax,%eax
jne    1296 <turnOffNMEA+0x166>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.turnOffNMEA.CFG_MSG_GLL = [16 x i8] c"\B5b\06\01\08\00\F0\01\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GGA = [16 x i8] c"\B5b\06\01\08\00\F0\00\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GSA = [16 x i8] c"\B5b\06\01\08\00\F0\02\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GSV = [16 x i8] c"\B5b\06\01\08\00\F0\03\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_ZDA = [16 x i8] c"\B5b\06\01\08\00\F0\08\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_RMC = [16 x i8] c"\B5b\06\01\08\00\F0\04\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_VTG = [16 x i8] c"\B5b\06\01\08\00\F0\05\00\00\00\00\00\01\00\00"
@.str = [27 x i8] c"couldn't turn off GLL: %d\0A\00"
@.str.1 = [23 x i8] c"couldn't turn off GGA\0A\00"
@.str.2 = [23 x i8] c"couldn't turn off GSV\0A\00"
@.str.3 = [23 x i8] c"couldn't turn off GSA\0A\00"
@.str.4 = [23 x i8] c"couldn't turn off ZDA\0A\00"
@.str.5 = [23 x i8] c"couldn't turn off RMC\0A\00"
@.str.6 = [23 x i8] c"couldn't turn off VTG\0A\00"
define i32 @turnOffNMEA(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [16 x i8]
%10 = alloca [16 x i8]
%11 = alloca [16 x i8]
%12 = alloca [16 x i8]
%13 = alloca [16 x i8]
%14 = alloca [16 x i8]
%15 = alloca [16 x i8]
store i32 %0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
%16 = bitcast [16 x i8]* %9 to i8*
%17 = bitcast [16 x i8]* %10 to i8*
%18 = bitcast [16 x i8]* %11 to i8*
%19 = bitcast [16 x i8]* %12 to i8*
%20 = bitcast [16 x i8]* %13 to i8*
%21 = bitcast [16 x i8]* %14 to i8*
%22 = bitcast [16 x i8]* %15 to i8*
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i32 @txMsg(i8* %23, i32 16, i32 %24, i32 10)
store i32 %25, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %1
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %1
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%32 = load i32, i32* %3
%33 = call i32 @txMsg(i8* %31, i32 16, i32 %32, i32 10)
store i32 %33, i32* %5
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%39 = load i32, i32* %3
%40 = call i32 @txMsg(i8* %38, i32 16, i32 %39, i32 10)
store i32 %40, i32* %5
%41 = icmp ne i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%46 = load i32, i32* %3
%47 = call i32 @txMsg(i8* %45, i32 16, i32 %46, i32 10)
store i32 %47, i32* %5
%48 = icmp ne i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %49, %44
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%53 = load i32, i32* %3
%54 = call i32 @txMsg(i8* %52, i32 16, i32 %53, i32 10)
store i32 %54, i32* %5
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %51
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%60 = load i32, i32* %3
%61 = call i32 @txMsg(i8* %59, i32 16, i32 %60, i32 10)
store i32 %61, i32* %5
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%67 = load i32, i32* %3
%68 = call i32 @txMsg(i8* %66, i32 16, i32 %67, i32 10)
store i32 %68, i32* %5
%69 = icmp ne i32 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %65
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
%73 = load i32, i32* %2
ret i32 %73
}

LLVM IR (-O2):
@__const.turnOffNMEA.CFG_MSG_GLL = [16 x i8] c"\B5b\06\01\08\00\F0\01\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GGA = [16 x i8] c"\B5b\06\01\08\00\F0\00\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GSA = [16 x i8] c"\B5b\06\01\08\00\F0\02\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_GSV = [16 x i8] c"\B5b\06\01\08\00\F0\03\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_ZDA = [16 x i8] c"\B5b\06\01\08\00\F0\08\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_RMC = [16 x i8] c"\B5b\06\01\08\00\F0\04\00\00\00\00\00\01\00\00"
@__const.turnOffNMEA.CFG_MSG_VTG = [16 x i8] c"\B5b\06\01\08\00\F0\05\00\00\00\00\00\01\00\00"
@.str = [27 x i8] c"couldn't turn off GLL: %d\0A\00"
@str = [22 x i8] c"couldn't turn off GGA\00"
@str.7 = [22 x i8] c"couldn't turn off GSV\00"
@str.8 = [22 x i8] c"couldn't turn off GSA\00"
@str.9 = [22 x i8] c"couldn't turn off ZDA\00"
@str.10 = [22 x i8] c"couldn't turn off RMC\00"
@str.11 = [22 x i8] c"couldn't turn off VTG\00"
define i32 @turnOffNMEA(i32 %0) {
%2 = alloca [16 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = alloca [16 x i8]
%6 = alloca [16 x i8]
%7 = alloca [16 x i8]
%8 = alloca [16 x i8]
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%16 = call i32 @txMsg(i8* %9, i32 16, i32 %0, i32 10)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 0)
br label %20
20: ; preds = %18, %1
%21 = call i32 @txMsg(i8* %10, i32 16, i32 %0, i32 10)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = call i32 @txMsg(i8* %12, i32 16, i32 %0, i32 10)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i32 @txMsg(i8* %11, i32 16, i32 %0, i32 10)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
%36 = call i32 @txMsg(i8* %13, i32 16, i32 %0, i32 10)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = call i32 @txMsg(i8* %14, i32 16, i32 %0, i32 10)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = call i32 @txMsg(i8* %15, i32 16, i32 %0, i32 10)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
ret i32 undef
}