#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
char *send_command(char *, char *);
int /*<<< orphan*/ send_command2(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main() {
  char command[128];
  send_command("localhost", "GET_VERSION");
  printf("\nEnter the command you wish to send PREDICT.\n\n");
  printf("Enter command, or QUIT to exit >> ");
  fgets(command, 80, stdin);
  while (strncmp(command, "QUIT", 4) && strncmp(command, "quit", 4) &&
         strncmp(command, "EXIT", 4) && strncmp(command, "exit", 4)) {
    command[strlen(command) - 1] = 0;
    if (strncmp(command, "PREDICT", 7) == 0 ||
        strncmp(command, "GET_SAT_POS", 11) == 0)
      send_command2("localhost", command);
    else if (command[0])
      printf("%s\n", send_command("localhost", command));
    printf("Enter command, or QUIT to exit >> ");
    fgets(command, 80, stdin);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <send_command@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1060 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x91(%rbp)
je     1277 <main+0x107>
lea    -0x90(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x91(%rbp)
je     1277 <main+0x107>
lea    -0x90(%rbp),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x91(%rbp)
je     1277 <main+0x107>
lea    -0x90(%rbp),%rdi
lea    0xe17(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    128a <main+0x11a>
jmp    1362 <main+0x1f2>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
lea    -0x90(%rbp),%rdi
lea    0xdcb(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12e7 <main+0x177>
lea    -0x90(%rbp),%rdi
lea    0xdb1(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ff <main+0x18f>
lea    -0x90(%rbp),%rsi
lea    0xd0b(%rip),%rdi
call   1070 <send_command2@plt>
jmp    1335 <main+0x1c5>
cmpb   $0x0,-0x90(%rbp)
je     1330 <main+0x1c0>
lea    -0x90(%rbp),%rsi
lea    0xce6(%rip),%rdi
call   1080 <send_command@plt>
mov    %rax,%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1335 <main+0x1c5>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2c97(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1060 <fgets@plt>
jmp    11cb <main+0x5b>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe68(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <send_command@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1070 <fgets@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11f7 <main+0x77>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xe45(%rip),%r15
lea    0xe43(%rip),%r12
lea    0xe41(%rip),%r13
lea    0xe03(%rip),%rbp
lea    0xe1f(%rip),%r14
jmp    1264 <main+0xe4>
nopl   0x0(%rax)
lea    0xdd9(%rip),%rdi
mov    %rbx,%rsi
call   1080 <send_command2@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %rbx,%rdi
lea    0xdd0(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1220 <main+0xa0>
mov    %rbx,%rdi
lea    0xd70(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1220 <main+0xa0>
cmpb   $0x0,(%rsp)
je     122f <main+0xaf>
lea    0xcf7(%rip),%rdi
mov    %rbx,%rsi
call   1090 <send_command@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
jmp    122f <main+0xaf>

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [12 x i8] c"GET_VERSION\00"
@.str.2 = [47 x i8] c"\0AEnter the command you wish to send PREDICT.\0A\0A\00"
@.str.3 = [35 x i8] c"Enter command, or QUIT to exit >> \00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"QUIT\00"
@.str.5 = [5 x i8] c"quit\00"
@.str.6 = [5 x i8] c"EXIT\00"
@.str.7 = [5 x i8] c"exit\00"
@.str.8 = [8 x i8] c"PREDICT\00"
@.str.9 = [12 x i8] c"GET_SAT_POS\00"
@.str.10 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = call i8* @send_command(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 80, i32 %7)
br label %9
9: ; preds = %52, %0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%15 = call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %21, %17, %13, %9
%26 = phi i1 [ false, %17 ], [ false, %13 ], [ false, %9 ], [ %24, %21 ]
br i1 %26, label %27, label %57
27: ; preds = %25
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %31
store i8 0, i8* %32
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%34 = call i64 @strncmp(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %27
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 11)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36, %27
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%42 = call i32 @send_command2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %41)
br label %52
43: ; preds = %36
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%49 = call i8* @send_command(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %43
br label %52
52: ; preds = %51, %40
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%55 = load i32, i32* @stdin
%56 = call i32 @fgets(i8* %54, i32 80, i32 %55)
br label %9
57: ; preds = %25
%58 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [12 x i8] c"GET_VERSION\00"
@.str.3 = [35 x i8] c"Enter command, or QUIT to exit >> \00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"QUIT\00"
@.str.5 = [5 x i8] c"quit\00"
@.str.6 = [5 x i8] c"EXIT\00"
@.str.7 = [5 x i8] c"exit\00"
@.str.8 = [8 x i8] c"PREDICT\00"
@.str.9 = [12 x i8] c"GET_SAT_POS\00"
@str = [46 x i8] c"\0AEnter the command you wish to send PREDICT.\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @send_command(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 80, i32 %6)
%8 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %43, label %10
10: ; preds = %0, %37
%11 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %43, label %13
13: ; preds = %10
%14 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %43, label %16
16: ; preds = %13
%17 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %43, label %19
19: ; preds = %16
%20 = call i32 @strlen(i8* %2)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 11)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26, %19
%30 = call i32 @send_command2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %37
31: ; preds = %26
%32 = load i8, i8* %2
%33 = icmp eq i8 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = call i8* @send_command(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
%36 = call i32 @puts(i8* dereferenceable(1) %35)
br label %37
37: ; preds = %31, %34, %29
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @stdin
%40 = call i32 @fgets(i8* %2, i32 80, i32 %39)
%41 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %10
43: ; preds = %16, %13, %10, %37, %0
%44 = call i32 @exit(i32 0)
unreachable
}