#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 number(int /*<<< orphan*/, int);
int puff(struct char_data *ch, int cmd, char *arg) {
  void do_say(struct char_data * ch, char *argument, int cmd);
  if (cmd)
    return (0);
  switch (number(0, 60)) {
  case 0:
    do_say(ch, "My god! It's full of stars!", 0);
    return (1);
  case 1:
    do_say(ch, "How'd all those fish get up here?", 0);
    return (1);
  case 2:
    do_say(ch, "I'm a very female dragon.", 0);
    return (1);
  case 3:
    do_say(ch, "I've got a peaceful, easy feeling.", 0);
    return (1);
  default:
    return (0);
  }
}


x86 assembly (clang, -O0):
<puff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1149 <puff+0x29>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <puff+0xd7>
xor    %edi,%edi
mov    $0x3c,%esi
call   1030 <number@plt>
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     11f0 <puff+0xd0>
mov    -0x28(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
xor    %edx,%edx
call   1040 <do_say@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <puff+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
xor    %edx,%edx
call   1040 <do_say@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <puff+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
xor    %edx,%edx
call   1040 <do_say@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <puff+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
xor    %edx,%edx
call   1040 <do_say@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <puff+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puff>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %esi,%esi
jne    115e <puff+0x3e>
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x3c,%esi
call   1030 <number@plt>
cmp    $0x3,%eax
ja     115e <puff+0x3e>
cltq
lea    0xf34(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <do_say@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.char_data = type { i32 }
@.str = [28 x i8] c"My god! It's full of stars!\00"
@.str.1 = [34 x i8] c"How'd all those fish get up here?\00"
@.str.2 = [26 x i8] c"I'm a very female dragon.\00"
@.str.3 = [35 x i8] c"I've got a peaceful, easy feeling.\00"
define i32 @puff(%struct.char_data* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.char_data*
%6 = alloca i32
%7 = alloca i8*
store %struct.char_data* %0, %struct.char_data** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 0, i32* %4
br label %22
11: ; preds = %3
%12 = call i32 @number(i32 0, i32 60)
switch i32 %12, label %21 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
i32 3, label %19
]
13: ; preds = %11
%14 = load %struct.char_data*, %struct.char_data** %5
store i32 1, i32* %4
br label %22
15: ; preds = %11
%16 = load %struct.char_data*, %struct.char_data** %5
store i32 1, i32* %4
br label %22
17: ; preds = %11
%18 = load %struct.char_data*, %struct.char_data** %5
store i32 1, i32* %4
br label %22
19: ; preds = %11
%20 = load %struct.char_data*, %struct.char_data** %5
store i32 1, i32* %4
br label %22
21: ; preds = %11
store i32 0, i32* %4
br label %22
22: ; preds = %21, %19, %17, %15, %13, %10
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
%struct.char_data = type { i32 }
@.str = [28 x i8] c"My god! It's full of stars!\00"
@.str.1 = [34 x i8] c"How'd all those fish get up here?\00"
@.str.2 = [26 x i8] c"I'm a very female dragon.\00"
@.str.3 = [35 x i8] c"I've got a peaceful, easy feeling.\00"
@reltable.puff = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.puff to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.puff to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.puff to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.puff to i64)) to i32)]
define i32 @puff(%struct.char_data* %0, i32 %1, i8* nocapture readnone %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %3
%6 = tail call i32 @number(i32 0, i32 60)
%7 = icmp ult i32 %6, 4
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = sext i32 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.puff to i8*), i64 %10)
tail call void @do_say(%struct.char_data* %0, i8* %11, i32 0)
br label %12
12: ; preds = %5, %8, %3
%13 = phi i32 [ 0, %3 ], [ 0, %5 ], [ 1, %8 ]
ret i32 %13
}