#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 char_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ act(char *, int /*<<< orphan*/, struct char_data *,
                       int /*<<< orphan*/, struct char_data *, int);
struct char_data *get_char_room_vis(struct char_data *, char *);
int /*<<< orphan*/ half_chop(char *, char *, char *);
int /*<<< orphan*/ send_to_char(char *, struct char_data *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void do_ask(struct char_data *ch, char *argument, int cmd) {
  struct char_data *vict;
  char name[100], message[4096], buf[4096];
  half_chop(argument, name, message);
  if (!*name || !*message)
    send_to_char("Who do you want to ask something.. and what??\n\r", ch);
  else if (!(vict = get_char_room_vis(ch, name)))
    send_to_char("No-one by that name here..\n\r", ch);
  else if (vict == ch) {
    act("$n quietly asks $mself a question.", 0, ch, 0, 0, 0);
    send_to_char("You think about it for a while...\n\r", ch);
  } else {
    sprintf(buf, "$n asks you '%s'", message);
    act(buf, 0, ch, 0, vict, 1);
    send_to_char("Ok.\n\r", ch);
    act("$n asks $N a question.", 0, ch, 0, vict, 2);
  }
}


x86 assembly (clang, -O0):
<do_ask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2090,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x1090(%rbp),%rdx
call   1050 <half_chop@plt>
cmpb   $0x0,-0x90(%rbp)
je     1197 <do_ask+0x47>
cmpb   $0x0,-0x1090(%rbp)
jne    11ac <do_ask+0x5c>
mov    -0x8(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1060 <send_to_char@plt>
jmp    1290 <do_ask+0x140>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <get_char_room_vis@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11df <do_ask+0x8f>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <send_to_char@plt>
jmp    128b <do_ask+0x13b>
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1220 <do_ask+0xd0>
mov    -0x8(%rbp),%rdx
lea    0xe55(%rip),%rdi
xor    %r9d,%r9d
xor    %eax,%eax
mov    %eax,%r8d
mov    %r9d,%esi
mov    %r9d,%ecx
call   1040 <act@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1060 <send_to_char@plt>
jmp    1286 <do_ask+0x136>
lea    -0x2090(%rbp),%rdi
lea    -0x1090(%rbp),%rdx
lea    0xe5f(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x2090(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%r8
xor    %ecx,%ecx
mov    $0x1,%r9d
mov    %ecx,%esi
call   1040 <act@plt>
mov    -0x8(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1060 <send_to_char@plt>
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%r8
lea    0xe34(%rip),%rdi
xor    %ecx,%ecx
mov    $0x2,%r9d
mov    %ecx,%esi
call   1040 <act@plt>
jmp    128b <do_ask+0x13b>
jmp    1290 <do_ask+0x140>
add    $0x2090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_ask>:
push   %r15
push   %r14
push   %rbx
sub    $0x2070,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
mov    %rsp,%rsi
lea    0x70(%rsp),%rdx
mov    %rax,%rdi
call   1050 <half_chop@plt>
cmpb   $0x0,(%rsp)
je     11fc <do_ask+0xac>
cmpb   $0x0,0x70(%rsp)
je     11fc <do_ask+0xac>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <get_char_room_vis@plt>
test   %rax,%rax
je     1205 <do_ask+0xb5>
mov    %rax,%r14
cmp    %rbx,%rax
je     120e <do_ask+0xbe>
lea    0xef2(%rip),%rsi
lea    0x1070(%rsp),%r15
lea    0x70(%rsp),%rdx
mov    %r15,%rdi
call   1070 <sprintf@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x1,%r9d
call   1040 <act@plt>
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
call   1060 <send_to_char@plt>
lea    0xec6(%rip),%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x2,%r9d
call   1040 <act@plt>
jmp    1236 <do_ask+0xe6>
lea    0xdfd(%rip),%rdi
jmp    122e <do_ask+0xde>
lea    0xe24(%rip),%rdi
jmp    122e <do_ask+0xde>
lea    0xe38(%rip),%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <act@plt>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
call   1060 <send_to_char@plt>
add    $0x2070,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.char_data = type { i32 }
@.str = [48 x i8] c"Who do you want to ask something.. and what??\0A\0D\00"
@.str.1 = [29 x i8] c"No-one by that name here..\0A\0D\00"
@.str.2 = [35 x i8] c"$n quietly asks $mself a question.\00"
@.str.3 = [36 x i8] c"You think about it for a while...\0A\0D\00"
@.str.4 = [17 x i8] c"$n asks you '%s'\00"
@.str.5 = [6 x i8] c"Ok.\0A\0D\00"
@.str.6 = [23 x i8] c"$n asks $N a question.\00"
define void @do_ask(%struct.char_data* %0, i8* %1, i32 %2) {
%4 = alloca %struct.char_data*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.char_data*
%8 = alloca [100 x i8]
%9 = alloca [4096 x i8]
%10 = alloca [4096 x i8]
store %struct.char_data* %0, %struct.char_data** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %5
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%14 = call i32 @half_chop(i8* %11, i8* %12, i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %3
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18, %3
%23 = load %struct.char_data*, %struct.char_data** %4
%24 = call i32 @send_to_char(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), %struct.char_data* %23)
br label %57
25: ; preds = %18
%26 = load %struct.char_data*, %struct.char_data** %4
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%28 = call %struct.char_data* @get_char_room_vis(%struct.char_data* %26, i8* %27)
store %struct.char_data* %28, %struct.char_data** %7
%29 = icmp ne %struct.char_data* %28, null
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load %struct.char_data*, %struct.char_data** %4
%32 = call i32 @send_to_char(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %struct.char_data* %31)
br label %56
33: ; preds = %25
%34 = load %struct.char_data*, %struct.char_data** %7
%35 = load %struct.char_data*, %struct.char_data** %4
%36 = icmp eq %struct.char_data* %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load %struct.char_data*, %struct.char_data** %4
%39 = call i32 @act(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 0, %struct.char_data* %38, i32 0, %struct.char_data* null, i32 0)
%40 = load %struct.char_data*, %struct.char_data** %4
%41 = call i32 @send_to_char(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), %struct.char_data* %40)
br label %55
42: ; preds = %33
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%45 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%47 = load %struct.char_data*, %struct.char_data** %4
%48 = load %struct.char_data*, %struct.char_data** %7
%49 = call i32 @act(i8* %46, i32 0, %struct.char_data* %47, i32 0, %struct.char_data* %48, i32 1)
%50 = load %struct.char_data*, %struct.char_data** %4
%51 = call i32 @send_to_char(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %struct.char_data* %50)
%52 = load %struct.char_data*, %struct.char_data** %4
%53 = load %struct.char_data*, %struct.char_data** %7
%54 = call i32 @act(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 0, %struct.char_data* %52, i32 0, %struct.char_data* %53, i32 2)
br label %55
55: ; preds = %42, %37
br label %56
56: ; preds = %55, %30
br label %57
57: ; preds = %56, %22
ret void
}

LLVM IR (-O2):
%struct.char_data = type { i32 }
@.str = [48 x i8] c"Who do you want to ask something.. and what??\0A\0D\00"
@.str.1 = [29 x i8] c"No-one by that name here..\0A\0D\00"
@.str.2 = [35 x i8] c"$n quietly asks $mself a question.\00"
@.str.3 = [36 x i8] c"You think about it for a while...\0A\0D\00"
@.str.4 = [17 x i8] c"$n asks you '%s'\00"
@.str.5 = [6 x i8] c"Ok.\0A\0D\00"
@.str.6 = [23 x i8] c"$n asks $N a question.\00"
define void @do_ask(%struct.char_data* %0, i8* %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%10 = call i32 @half_chop(i8* %1, i8* %7, i8* %8)
%11 = load i8, i8* %7
%12 = icmp ne i8 %11, 0
%13 = load i8, i8* %8
%14 = icmp ne i8 %13, 0
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = call i32 @send_to_char(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), %struct.char_data* %0)
br label %33
18: ; preds = %3
%19 = call %struct.char_data* @get_char_room_vis(%struct.char_data* %0, i8* %7)
%20 = icmp eq %struct.char_data* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @send_to_char(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %struct.char_data* %0)
br label %33
23: ; preds = %18
%24 = icmp eq %struct.char_data* %19, %0
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = call i32 @act(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 0, %struct.char_data* %0, i32 0, %struct.char_data* null, i32 0)
%27 = call i32 @send_to_char(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), %struct.char_data* %0)
br label %33
28: ; preds = %23
%29 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%30 = call i32 @act(i8* %9, i32 0, %struct.char_data* %0, i32 0, %struct.char_data* %19, i32 1)
%31 = call i32 @send_to_char(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %struct.char_data* %0)
%32 = call i32 @act(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 0, %struct.char_data* %0, i32 0, %struct.char_data* %19, i32 2)
br label %33
33: ; preds = %21, %28, %25, %16
ret void
}