#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 ui {
  int dummy;
};
struct state {
  int dummy;
};
struct addrinfo {
  int dummy;
};

/* Variables and functions */
int client_process_input(struct state *, struct ui *, int, int,
                         struct addrinfo *);
int dialog_quit_confirm(struct state *, struct ui *);
int fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int update_from_input_client(struct state *st, struct ui *ui, int sfd,
                             struct addrinfo *srv_addr) {
  int c;
  char buf[1];
  int finished = 0;
  while (fread(buf, 1, 1, stdin) == 1) {
    c = buf[0];
    switch (c) {
    case 'q':
    case 'Q':
      finished = dialog_quit_confirm(st, ui);
      break;
    default:
      finished = client_process_input(st, ui, c, sfd, srv_addr);
    }
  }
  return finished;
}


x86 assembly (clang, -O0):
<update_from_input_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x25(%rbp),%rdi
mov    0x2e8f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11bf <update_from_input_client+0x8f>
movsbl -0x25(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
or     $0x20,%eax
sub    $0x71,%eax
je     118b <update_from_input_client+0x5b>
jmp    11a0 <update_from_input_client+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <dialog_quit_confirm@plt>
mov    %eax,-0x2c(%rbp)
jmp    11ba <update_from_input_client+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <client_process_input@plt>
mov    %eax,-0x2c(%rbp)
jmp    114e <update_from_input_client+0x1e>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_from_input_client>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%rbp
mov    0x2e95(%rip),%r14
mov    (%r14),%ecx
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
jne    11c5 <update_from_input_client+0x95>
lea    0xf(%rsp),%r12
jmp    11a9 <update_from_input_client+0x79>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%ecx
mov    0x10(%rsp),%r8
call   1040 <client_process_input@plt>
mov    %eax,%ebx
mov    (%r14),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11c5 <update_from_input_client+0x95>
movsbl 0xf(%rsp),%edx
mov    %edx,%eax
or     $0x20,%eax
mov    %rbp,%rdi
mov    %r13,%rsi
cmp    $0x71,%eax
jne    1180 <update_from_input_client+0x50>
call   1050 <dialog_quit_confirm@plt>
jmp    118d <update_from_input_client+0x5d>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.state = type { i32 }
%struct.ui = type { i32 }
%struct.addrinfo = type { i32 }
@stdin = global i32 0
define i32 @update_from_input_client(%struct.state* %0, %struct.ui* %1, i32 %2, %struct.addrinfo* %3) {
%5 = alloca %struct.state*
%6 = alloca %struct.ui*
%7 = alloca i32
%8 = alloca %struct.addrinfo*
%9 = alloca i32
%10 = alloca [1 x i8]
%11 = alloca i32
store %struct.state* %0, %struct.state** %5
store %struct.ui* %1, %struct.ui** %6
store i32 %2, i32* %7
store %struct.addrinfo* %3, %struct.addrinfo** %8
store i32 0, i32* %11
br label %12
12: ; preds = %33, %4
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fread(i8* %13, i32 1, i32 1, i32 %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %34
17: ; preds = %12
%18 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
store i32 %20, i32* %9
%21 = load i32, i32* %9
switch i32 %21, label %26 [
i32 113, label %22
i32 81, label %22
]
22: ; preds = %17, %17
%23 = load %struct.state*, %struct.state** %5
%24 = load %struct.ui*, %struct.ui** %6
%25 = call i32 @dialog_quit_confirm(%struct.state* %23, %struct.ui* %24)
store i32 %25, i32* %11
br label %33
26: ; preds = %17
%27 = load %struct.state*, %struct.state** %5
%28 = load %struct.ui*, %struct.ui** %6
%29 = load i32, i32* %9
%30 = load i32, i32* %7
%31 = load %struct.addrinfo*, %struct.addrinfo** %8
%32 = call i32 @client_process_input(%struct.state* %27, %struct.ui* %28, i32 %29, i32 %30, %struct.addrinfo* %31)
store i32 %32, i32* %11
br label %33
33: ; preds = %26, %22
br label %12
34: ; preds = %12
%35 = load i32, i32* %11
ret i32 %35
}

LLVM IR (-O2):
%struct.state = type { i32 }
%struct.ui = type { i32 }
%struct.addrinfo = type { i32 }
@stdin = global i32 0
define i32 @update_from_input_client(%struct.state* %0, %struct.ui* %1, i32 %2, %struct.addrinfo* %3) {
%5 = alloca [1 x i8]
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fread(i8* %6, i32 1, i32 1, i32 %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %4, %17
%11 = load i8, i8* %6
%12 = sext i8 %11 to i32
switch i32 %12, label %15 [
i32 113, label %13
i32 81, label %13
]
13: ; preds = %10, %10
%14 = call i32 @dialog_quit_confirm(%struct.state* %0, %struct.ui* %1)
br label %17
15: ; preds = %10
%16 = call i32 @client_process_input(%struct.state* %0, %struct.ui* %1, i32 %12, i32 %2, %struct.addrinfo* %3)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %16, %15 ], [ %14, %13 ]
%19 = load i32, i32* @stdin
%20 = call i32 @fread(i8* %6, i32 1, i32 1, i32 %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %10, label %22
22: ; preds = %17, %4
%23 = phi i32 [ 0, %4 ], [ %18, %17 ]
ret i32 %23
}