#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 */
struct cntrl {
  int dummy;
};

/* Variables and functions */
char *GetString();
struct cntrl *initControl();
int /*<<< orphan*/ printf(char *);
char *sendMessage(struct cntrl *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main() {
  struct cntrl *p;
  char *query, *reply;
  p = initControl();
  while (1) {
    printf("> ");
    query = GetString();
    if (!strncmp(query, "exit", 4))
      break;
    if (query[0] != '\0') {
      reply = sendMessage(p, query);
      printf(reply);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initControl@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <GetString@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a4 <main+0x54>
jmp    11d3 <main+0x83>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ce <main+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <sendMessage@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <printf@plt>
jmp    116a <main+0x1a>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initControl@plt>
mov    %rax,%r14
lea    0xe97(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <GetString@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11e0 <main+0x90>
lea    0xe69(%rip),%r15
lea    0xe65(%rip),%r12
jmp    11c6 <main+0x76>
mov    %r15,%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <GetString@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11e0 <main+0x90>
cmpb   $0x0,(%rbx)
je     11a0 <main+0x50>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <sendMessage@plt>
mov    %rax,%rdi
call   1060 <printf@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cntrl = type { i32 }
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.cntrl*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call %struct.cntrl* (...) @initControl()
store %struct.cntrl* %5, %struct.cntrl** %2
br label %6
6: ; preds = %0, %25
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = call i8* (...) @GetString()
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %6
br label %26
13: ; preds = %6
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load %struct.cntrl*, %struct.cntrl** %2
%21 = load i8*, i8** %3
%22 = call i8* @sendMessage(%struct.cntrl* %20, i8* %21)
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = call i32 @printf(i8* %23)
br label %25
25: ; preds = %19, %13
br label %6
26: ; preds = %12
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
%struct.cntrl = type { i32 }
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = tail call %struct.cntrl* (...) @initControl()
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* (...) @GetString()
%4 = tail call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%5 = icmp eq i32 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %0, %13
%7 = phi i8* [ %15, %13 ], [ %3, %0 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i8* @sendMessage(%struct.cntrl* %1, i8* %7)
%12 = tail call i32 @printf(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %6
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = tail call i8* (...) @GetString()
%16 = tail call i32 @strncmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %13, %0
ret i32 0
}