#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*/, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ send_to_char(char *, struct char_data *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void do_say(struct char_data *ch, char *argument, int cmd) {
  int i;
  static char buf[4096];
  for (i = 0; *(argument + i) == ' '; i++)
    ;
  if (!*(argument + i))
    send_to_char("Yes, but WHAT do you want to say?\r\n", ch);
  else {
    sprintf(buf, "$n says '%s'", argument + i);
    act(buf, 0, ch, 0, 0, 0);
    send_to_char("Ok.\r\n", ch);
  }
}


x86 assembly (clang, -O0):
<do_say>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1172 <do_say+0x42>
jmp    1164 <do_say+0x34>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <do_say+0x1a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    1199 <do_say+0x69>
mov    -0x8(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <send_to_char@plt>
jmp    11e3 <do_say+0xb3>
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
lea    0x2ea5(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdx
lea    0x2e8e(%rip),%rdi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1030 <act@plt>
mov    -0x8(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <send_to_char@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_say>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rbx
xor    %eax,%eax
nopl   0x0(%rax)
movzbl (%rdx,%rax,1),%ecx
cmp    $0x20,%cl
jne    114f <do_say+0x1f>
add    $0x1,%rax
jmp    1140 <do_say+0x10>
test   %cl,%cl
jne    115c <do_say+0x2c>
lea    0xea6(%rip),%rdi
jmp    1193 <do_say+0x63>
mov    %eax,%eax
add    %rax,%rdx
lea    0x2ee8(%rip),%r14
lea    0xeb5(%rip),%rsi
mov    %r14,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <act@plt>
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <send_to_char@plt>

LLVM IR (-O0):
%struct.char_data = type { i32 }
@do_say.buf = internal global [4096 x i8] zeroinitializer
@.str = [36 x i8] c"Yes, but WHAT do you want to say?\0D\0A\00"
@.str.1 = [13 x i8] c"$n says '%s'\00"
@.str.2 = [6 x i8] c"Ok.\0D\0A\00"
define void @do_say(%struct.char_data* %0, i8* %1, i32 %2) {
%4 = alloca %struct.char_data*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store %struct.char_data* %0, %struct.char_data** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %17, %3
%9 = load i8*, i8** %5
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %20
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %8
20: ; preds = %8
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = icmp ne i8 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = load %struct.char_data*, %struct.char_data** %4
%29 = call i32 @send_to_char(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), %struct.char_data* %28)
br label %40
30: ; preds = %20
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = call i32 @sprintf(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @do_say.buf, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load %struct.char_data*, %struct.char_data** %4
%37 = call i32 @act(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @do_say.buf, i64 0, i64 0), i32 0, %struct.char_data* %36, i32 0, i32 0, i32 0)
%38 = load %struct.char_data*, %struct.char_data** %4
%39 = call i32 @send_to_char(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %struct.char_data* %38)
br label %40
40: ; preds = %30, %27
ret void
}

LLVM IR (-O2):
%struct.char_data = type { i32 }
@do_say.buf = internal global [4096 x i8] zeroinitializer
@.str = [36 x i8] c"Yes, but WHAT do you want to say?\0D\0A\00"
@.str.1 = [13 x i8] c"$n says '%s'\00"
@.str.2 = [6 x i8] c"Ok.\0D\0A\00"
define void @do_say(%struct.char_data* %0, i8* %1, i32 %2) {
br label %4
4: ; preds = %8, %3
%5 = phi i64 [ %9, %8 ], [ 0, %3 ]
%6 = getelementptr inbounds i8, i8* %1, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %10 [
i8 32, label %8
i8 0, label %15
]
8: ; preds = %4
%9 = add nuw i64 %5, 1
br label %4
10: ; preds = %4
%11 = and i64 %5, 4294967295
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([4096 x i8], [4096 x i8]* @do_say.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @act(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @do_say.buf, i64 0, i64 0), i32 0, %struct.char_data* %0, i32 0, i32 0, i32 0)
br label %15
15: ; preds = %4, %10
%16 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), %4 ]
%17 = tail call i32 @send_to_char(i8* %16, %struct.char_data* %0)
ret void
}