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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int, int);
int setcns(int, int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int cmd_gps_clear(int argc, char **argv) {
  char data[9];
  data[0] = 0;
  data[1] = 1;
  int i, j;
  memset(data + 2, argc ? 0x00 : 0x01, 7);
  static struct {
    int off;
    char *key;
  } keys[] = {{2, "ephemeris"}, {3, "almanac"}, {4, "position"},  {5, "sldb"},
              {6, "ssdb"},      {7, "timeref"}, {8, "throttling"}};
  for (i = 0; i < argc; i++)
    for (j = 0; j < sizeof(keys) / sizeof(*keys); j++)
      if (!strcmp(argv[i], keys[i].key))
        data[keys[i].off] = 0x01;
  return setcns(0x0F20, 9, data);
}


x86 assembly (clang, -O0):
<cmd_gps_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x19(%rbp)
movb   $0x1,-0x18(%rbp)
lea    -0x19(%rbp),%rdi
add    $0x2,%rdi
mov    -0x4(%rbp),%ecx
mov    $0x1,%esi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    $0x7,%edx
call   1030 <memset@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1201 <cmd_gps_clear+0xd1>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x7,%rax
jae    11ee <cmd_gps_clear+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x20(%rbp),%rcx
lea    0x2e98(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11db <cmd_gps_clear+0xab>
movslq -0x20(%rbp),%rcx
lea    0x2e74(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq (%rax),%rax
movb   $0x1,-0x19(%rbp,%rax,1)
jmp    11e0 <cmd_gps_clear+0xb0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <cmd_gps_clear+0x53>
jmp    11f3 <cmd_gps_clear+0xc3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1170 <cmd_gps_clear+0x40>
lea    -0x19(%rbp),%rdx
mov    $0xf20,%edi
mov    $0x9,%esi
call   1050 <setcns@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_gps_clear>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,%ebx
movw   $0x100,0x7(%rsp)
lea    0x9(%rsp),%rdi
xor    %esi,%esi
test   %ebx,%ebx
sete   %sil
mov    $0x7,%edx
call   1030 <memset@plt>
test   %ebx,%ebx
jle    1250 <cmd_gps_clear+0x120>
mov    %ebx,%r12d
shl    $0x3,%r12
xor    %ebx,%ebx
lea    0x2c35(%rip),%rbp
jmp    118d <cmd_gps_clear+0x5d>
nopl   (%rax)
add    $0x8,%rbx
cmp    %rbx,%r12
je     1250 <cmd_gps_clear+0x120>
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,1),%r15
lea    (%rbx,%rbx,1),%r14
mov    0x8(%rbp,%rbx,2),%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11b7 <cmd_gps_clear+0x87>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11cf <cmd_gps_clear+0x9f>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11e7 <cmd_gps_clear+0xb7>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11ff <cmd_gps_clear+0xcf>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1217 <cmd_gps_clear+0xe7>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    122f <cmd_gps_clear+0xff>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1180 <cmd_gps_clear+0x50>
movslq (%r14,%rbp,1),%rax
movb   $0x1,0x7(%rsp,%rax,1)
jmp    1180 <cmd_gps_clear+0x50>
lea    0x7(%rsp),%rdx
mov    $0xf20,%edi
mov    $0x9,%esi
call   1050 <setcns@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@cmd_gps_clear.keys = internal global [7 x %struct.anon] [%struct.anon { i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0) }]
@.str = [10 x i8] c"ephemeris\00"
@.str.1 = [8 x i8] c"almanac\00"
@.str.2 = [9 x i8] c"position\00"
@.str.3 = [5 x i8] c"sldb\00"
@.str.4 = [5 x i8] c"ssdb\00"
@.str.5 = [8 x i8] c"timeref\00"
@.str.6 = [11 x i8] c"throttling\00"
define i32 @cmd_gps_clear(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [9 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
store i8 0, i8* %8
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 1
store i8 1, i8* %9
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds i8, i8* %10, i64 2
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 0, i32 1
%16 = call i32 @memset(i8* %11, i32 %15, i32 7)
store i32 0, i32* %6
br label %17
17: ; preds = %52, %2
%18 = load i32, i32* %6
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %55
21: ; preds = %17
store i32 0, i32* %7
br label %22
22: ; preds = %48, %21
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %24, 7
br i1 %25, label %26, label %51
26: ; preds = %22
%27 = load i8**, i8*** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @cmd_gps_clear.keys, i64 0, i64 %33
%35 = getelementptr inbounds %struct.anon, %struct.anon* %34, i32 0, i32 1
%36 = load i8*, i8** %35
%37 = call i32 @strcmp(i8* %31, i8* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %47, label %39
39: ; preds = %26
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @cmd_gps_clear.keys, i64 0, i64 %41
%43 = getelementptr inbounds %struct.anon, %struct.anon* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %45
store i8 1, i8* %46
br label %47
47: ; preds = %39, %26
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %22
51: ; preds = %22
br label %52
52: ; preds = %51
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %17
55: ; preds = %17
%56 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%57 = call i32 @setcns(i32 3872, i32 9, i8* %56)
ret i32 %57
}

LLVM IR (-O2):
%struct.anon = type { i32, i8* }
@cmd_gps_clear.keys = internal unnamed_addr constant [7 x %struct.anon] [%struct.anon { i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0) }]
@.str = [10 x i8] c"ephemeris\00"
@.str.1 = [8 x i8] c"almanac\00"
@.str.2 = [9 x i8] c"position\00"
@.str.3 = [5 x i8] c"sldb\00"
@.str.4 = [5 x i8] c"ssdb\00"
@.str.5 = [8 x i8] c"timeref\00"
@.str.6 = [11 x i8] c"throttling\00"
define i32 @cmd_gps_clear(i32 %0, i8** nocapture %1) {
%3 = alloca [9 x i8]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 1
store i8 1, i8* %5
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 2
%7 = icmp eq i32 %0, 0
%8 = zext i1 %7 to i32
%9 = call i32 @memset(i8* %6, i32 %8, i32 7)
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %71
11: ; preds = %2
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %68
%14 = phi i64 [ 0, %11 ], [ %69, %68 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @cmd_gps_clear.keys, i64 0, i64 %14, i32 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @cmd_gps_clear.keys, i64 0, i64 %14, i32 0
%20 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = load i32, i32* %19
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %24
store i8 1, i8* %25
br label %26
26: ; preds = %13, %22
%27 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %19
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %31
store i8 1, i8* %32
br label %33
33: ; preds = %29, %26
%34 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %19
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %38
store i8 1, i8* %39
br label %40
40: ; preds = %36, %33
%41 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32, i32* %19
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %45
store i8 1, i8* %46
br label %47
47: ; preds = %43, %40
%48 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32, i32* %19
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %52
store i8 1, i8* %53
br label %54
54: ; preds = %50, %47
%55 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = load i32, i32* %19
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %59
store i8 1, i8* %60
br label %61
61: ; preds = %57, %54
%62 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %18)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load i32, i32* %19
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %66
store i8 1, i8* %67
br label %68
68: ; preds = %64, %61
%69 = add nuw nsw i64 %14, 1
%70 = icmp eq i64 %69, %12
br i1 %70, label %71, label %13
71: ; preds = %68, %2
%72 = call i32 @setcns(i32 3872, i32 9, i8* %4)
ret i32 %72
}