#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 */

/* Variables and functions */
int ircsend(int, char *, char *, ...);
scalar_t__ shout_countname(char *, long long *);
char *strchr(char *, char);
int count(int sock, char **user, char *msg, char *replyto) {
  char *parm = strchr(msg, ' ');
  if (!parm || !(++parm))
    parm = user[0];
  long long numbered = 0;
  if (shout_countname(parm, &numbered))
    return ircsend(sock,
                   "PRIVMSG %s "
                   ":An error occured in the sqlite3 interface, "
                   "please contact owner",
                   replyto);
  return ircsend(sock,
                 "PRIVMSG %s "
                 ":There is a total of %lld quotes recorded from %s",
                 replyto, numbered, parm);
}


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117a <count+0x4a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1185 <count+0x55>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <shout_countname@plt>
cmp    $0x0,%rax
je     11c1 <count+0x91>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rdx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1050 <ircsend@plt>
mov    %eax,-0x4(%rbp)
jmp    11e1 <count+0xb1>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1050 <ircsend@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rsi,%rbp
mov    %edi,%r15d
mov    %rdx,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115b <count+0x2b>
mov    %rax,%rbx
add    $0x1,%rbx
jmp    115f <count+0x2f>
mov    0x0(%rbp),%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <shout_countname@plt>
test   %rax,%rax
je     118d <count+0x5d>
lea    0xe82(%rip),%rsi
mov    %r15d,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <ircsend@plt>
jmp    11a8 <count+0x78>
mov    (%rsp),%rcx
lea    0xeb4(%rip),%rsi
mov    %r15d,%edi
mov    %r14,%rdx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <ircsend@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [76 x i8] c"PRIVMSG %s :An error occured in the sqlite3 interface, please contact owner\00"
@.str.1 = [61 x i8] c"PRIVMSG %s :There is a total of %lld quotes recorded from %s\00"
define i32 @count(i32 %0, i8** %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%12 = load i8*, i8** %8
%13 = call i8* @strchr(i8* %12, i8 signext 32)
store i8* %13, i8** %10
%14 = load i8*, i8** %10
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %4
%17 = load i8*, i8** %10
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %10
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %16, %4
%21 = load i8**, i8*** %7
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
store i8* %23, i8** %10
br label %24
24: ; preds = %20, %16
store i64 0, i64* %11
%25 = load i8*, i8** %10
%26 = call i64 @shout_countname(i8* %25, i64* %11)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %6
%30 = load i8*, i8** %9
%31 = call i32 (i32, i8*, i8*, ...) @ircsend(i32 %29, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %30)
store i32 %31, i32* %5
br label %38
32: ; preds = %24
%33 = load i32, i32* %6
%34 = load i8*, i8** %9
%35 = load i64, i64* %11
%36 = load i8*, i8** %10
%37 = call i32 (i32, i8*, i8*, ...) @ircsend(i32 %33, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %34, i64 %35, i8* %36)
store i32 %37, i32* %5
br label %38
38: ; preds = %32, %28
%39 = load i32, i32* %5
ret i32 %39
}

LLVM IR (-O2):
@.str = [76 x i8] c"PRIVMSG %s :An error occured in the sqlite3 interface, please contact owner\00"
@.str.1 = [61 x i8] c"PRIVMSG %s :There is a total of %lld quotes recorded from %s\00"
define i32 @count(i32 %0, i8** nocapture %1, i8* %2, i8* %3) {
%5 = alloca i64
%6 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 32)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
br label %12
10: ; preds = %4
%11 = load i8*, i8** %1
br label %12
12: ; preds = %8, %10
%13 = phi i8* [ %9, %8 ], [ %11, %10 ]
%14 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%15 = call i64 @shout_countname(i8* %13, i64* %5)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 (i32, i8*, i8*, ...) @ircsend(i32 %0, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %22
19: ; preds = %12
%20 = load i64, i64* %5
%21 = call i32 (i32, i8*, i8*, ...) @ircsend(i32 %0, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %3, i64 %20, i8* %13)
br label %22
22: ; preds = %19, %17
%23 = phi i32 [ %18, %17 ], [ %21, %19 ]
ret i32 %23
}