#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*/ IPC_disconnect();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void stdinHnd(int fd, void *clientData) {
#pragma unused(fd)
  char inputLine[81];
  fgets(inputLine, 80, stdin);
  switch (inputLine[0]) {
  case 'q':
  case 'Q':
    IPC_disconnect();
    exit(0);
  default:
    printf("stdinHnd [%s]: Received %s", (char *)clientData, inputLine);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<stdinHnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
lea    -0x70(%rbp),%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
movsbl -0x70(%rbp),%eax
or     $0x20,%eax
sub    $0x71,%eax
je     118b <stdinHnd+0x3b>
jmp    1199 <stdinHnd+0x49>
mov    $0x0,%al
call   1030 <IPC_disconnect@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdinHnd>:
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
movsbl (%rsp),%eax
or     $0x20,%eax
cmp    $0x71,%eax
je     11a0 <stdinHnd+0x50>
lea    0xe7f(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x60,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <IPC_disconnect@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [27 x i8] c"stdinHnd [%s]: Received %s\00"
@stdout = global i32 0
define void @stdinHnd(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [81 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 80, i32 %7)
%9 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %15 [
i32 113, label %12
i32 81, label %12
]
12: ; preds = %2, %2
%13 = call i32 (...) @IPC_disconnect()
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
br label %21
21: ; preds = %15
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [27 x i8] c"stdinHnd [%s]: Received %s\00"
@stdout = global i32 0
define void @stdinHnd(i32 %0, i8* %1) {
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 80, i32 %5)
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
switch i32 %8, label %12 [
i32 113, label %9
i32 81, label %9
]
9: ; preds = %2, %2
%10 = call i32 (...) @IPC_disconnect()
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %4)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
ret void
}