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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ info_log(char *, char const *, char const *, ...);
char *malloc(int);
int /*<<< orphan*/ privmsg(int /*<<< orphan*/, char const *, char *, ...);
int strlen(char *);
char *strtok(char *, char *);
int /*<<< orphan*/ unick(struct userlist *);
int /*<<< orphan*/ usinfo(struct userlist *);
int msg_peluche(const char *replyto, struct userlist *user, char *data) {
  char *message, *msg;
  int i;
  if (data != NULL) {
    message = strtok(data, "");
    if (*(message + strlen(message) - 1) == ' ')
      *(message + strlen(message) - 1) = '\0';
    msg = malloc(sizeof(char) * strlen(data) + 1);
    for (i = 0; i < strlen(data); i++)
      *(msg + i) = '=';
    *(msg + strlen(data)) = '\0';
    info_log("Peluche %s on %s by %s\n", message, replyto, unick(user));
    privmsg(usinfo(user), replyto, "%s: 8%sD", message, msg);
    free(msg);
  } else {
    info_log("Peluche on %s by %s\n", replyto, unick(user));
    privmsg(usinfo(user), replyto, "8=============D");
  }
  return (0);
}


x86 assembly (clang, -O0):
<msg_peluche>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12d7 <msg_peluche+0x157>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11fa <msg_peluche+0x7a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    1255 <msg_peluche+0xd5>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x3d,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    121f <msg_peluche+0x9f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <unick@plt>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    %eax,%ecx
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1060 <info_log@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <usinfo@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xd56(%rip),%rdx
mov    $0x0,%al
call   1080 <privmsg@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    131a <msg_peluche+0x19a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <unick@plt>
mov    -0x68(%rbp),%rsi
movslq %eax,%rdx
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1060 <info_log@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <usinfo@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
lea    0xd23(%rip),%rdx
mov    $0x0,%al
call   1080 <privmsg@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_peluche>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
test   %rdx,%rdx
je     1272 <msg_peluche+0xf2>
mov    %rdx,%rbx
lea    0xe91(%rip),%rsi
mov    %rdx,%rdi
call   1090 <strtok@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x20,-0x1(%r12,%rax,1)
jne    11d1 <msg_peluche+0x51>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%r12,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1219 <msg_peluche+0x99>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x3d,0x0(%r13,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1200 <msg_peluche+0x80>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,0x0(%r13,%rax,1)
mov    %r15,%rdi
call   1050 <unick@plt>
lea    0xdc8(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <info_log@plt>
mov    %r15,%rdi
call   10a0 <usinfo@plt>
lea    0xdc2(%rip),%rdx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r12,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1080 <privmsg@plt>
mov    %r13,%rdi
call   1030 <free@plt>
jmp    12a9 <msg_peluche+0x129>
mov    %r15,%rdi
call   1050 <unick@plt>
movslq %eax,%rdx
lea    0xd9d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <info_log@plt>
mov    %r15,%rdi
call   10a0 <usinfo@plt>
lea    0xd99(%rip),%rdx
mov    %eax,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <privmsg@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.userlist = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [24 x i8] c"Peluche %s on %s by %s\0A\00"
@.str.2 = [9 x i8] c"%s: 8%sD\00"
@.str.3 = [21 x i8] c"Peluche on %s by %s\0A\00"
@.str.4 = [16 x i8] c"8=============D\00"
define i32 @msg_peluche(i8* %0, %struct.userlist* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.userlist*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store %struct.userlist* %1, %struct.userlist** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %71
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = load i8*, i8** %7
%17 = call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br i1 %23, label %24, label %31
24: ; preds = %12
%25 = load i8*, i8** %7
%26 = load i8*, i8** %7
%27 = call i32 @strlen(i8* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 -1
store i8 0, i8* %30
br label %31
31: ; preds = %24, %12
%32 = load i8*, i8** %6
%33 = call i32 @strlen(i8* %32)
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = add i64 %35, 1
%37 = trunc i64 %36 to i32
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %8
store i32 0, i32* %9
br label %39
39: ; preds = %49, %31
%40 = load i32, i32* %9
%41 = load i8*, i8** %6
%42 = call i32 @strlen(i8* %41)
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %52
44: ; preds = %39
%45 = load i8*, i8** %8
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 61, i8* %48
br label %49
49: ; preds = %44
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %39
52: ; preds = %39
%53 = load i8*, i8** %8
%54 = load i8*, i8** %6
%55 = call i32 @strlen(i8* %54)
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
store i8 0, i8* %57
%58 = load i8*, i8** %7
%59 = load i8*, i8** %4
%60 = load %struct.userlist*, %struct.userlist** %5
%61 = call i32 @unick(%struct.userlist* %60)
%62 = call i32 (i8*, i8*, i8*, ...) @info_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %58, i8* %59, i32 %61)
%63 = load %struct.userlist*, %struct.userlist** %5
%64 = call i32 @usinfo(%struct.userlist* %63)
%65 = load i8*, i8** %4
%66 = load i8*, i8** %7
%67 = load i8*, i8** %8
%68 = call i32 (i32, i8*, i8*, ...) @privmsg(i32 %64, i8* %65, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %66, i8* %67)
%69 = load i8*, i8** %8
%70 = call i32 @free(i8* %69)
br label %82
71: ; preds = %3
%72 = load i8*, i8** %4
%73 = load %struct.userlist*, %struct.userlist** %5
%74 = call i32 @unick(%struct.userlist* %73)
%75 = sext i32 %74 to i64
%76 = inttoptr i64 %75 to i8*
%77 = call i32 (i8*, i8*, i8*, ...) @info_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %72, i8* %76)
%78 = load %struct.userlist*, %struct.userlist** %5
%79 = call i32 @usinfo(%struct.userlist* %78)
%80 = load i8*, i8** %4
%81 = call i32 (i32, i8*, i8*, ...) @privmsg(i32 %79, i8* %80, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %71, %52
ret i32 0
}

LLVM IR (-O2):
%struct.userlist = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [24 x i8] c"Peluche %s on %s by %s\0A\00"
@.str.2 = [9 x i8] c"%s: 8%sD\00"
@.str.3 = [21 x i8] c"Peluche on %s by %s\0A\00"
@.str.4 = [16 x i8] c"8=============D\00"
define i32 @msg_peluche(i8* %0, %struct.userlist* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %40, label %5
5: ; preds = %3
%6 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %13, label %18
13: ; preds = %5
%14 = tail call i32 @strlen(i8* %6)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %6, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -1
store i8 0, i8* %17
br label %18
18: ; preds = %13, %5
%19 = tail call i32 @strlen(i8* %2)
%20 = add i32 %19, 1
%21 = tail call i8* @malloc(i32 %20)
%22 = tail call i32 @strlen(i8* %2)
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %18, %24
%25 = phi i64 [ %27, %24 ], [ 0, %18 ]
%26 = getelementptr inbounds i8, i8* %21, i64 %25
store i8 61, i8* %26
%27 = add nuw nsw i64 %25, 1
%28 = tail call i32 @strlen(i8* %2)
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %24, label %31
31: ; preds = %24, %18
%32 = tail call i32 @strlen(i8* %2)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %21, i64 %33
store i8 0, i8* %34
%35 = tail call i32 @unick(%struct.userlist* %1)
%36 = tail call i32 (i8*, i8*, i8*, ...) @info_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %0, i32 %35)
%37 = tail call i32 @usinfo(%struct.userlist* %1)
%38 = tail call i32 (i32, i8*, i8*, ...) @privmsg(i32 %37, i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %21)
%39 = tail call i32 @free(i8* %21)
br label %47
40: ; preds = %3
%41 = tail call i32 @unick(%struct.userlist* %1)
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i8*
%44 = tail call i32 (i8*, i8*, i8*, ...) @info_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %43)
%45 = tail call i32 @usinfo(%struct.userlist* %1)
%46 = tail call i32 (i32, i8*, i8*, ...) @privmsg(i32 %45, i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %40, %31
ret i32 0
}