#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 /*<<< orphan*/ auth_isowner(char *);
int /*<<< orphan*/ ircproto_privmsg(char *, char *, ...);
int /*<<< orphan*/ plg_load(char *);
void load_lib(char *usr, char *src, char *msg, char **caps, int ncaps) {
  char *lib;
  if (!auth_isowner(usr)) {
    ircproto_privmsg(src, "err: not owner");
    return;
  }
  if (ncaps != 1) {
    ircproto_privmsg(src, "usage: load_lib <lib>");
    return;
  }
  lib = caps[0];
  ircproto_privmsg(src, "loading: %s", lib);
  plg_load(lib);
}


x86 assembly (clang, -O0):
<load_lib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <auth_isowner@plt>
cmp    $0x0,%eax
jne    1175 <load_lib+0x45>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <ircproto_privmsg@plt>
jmp    11c0 <load_lib+0x90>
cmpl   $0x1,-0x24(%rbp)
je     1196 <load_lib+0x66>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1040 <ircproto_privmsg@plt>
jmp    11c0 <load_lib+0x90>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1040 <ircproto_privmsg@plt>
mov    -0x30(%rbp),%rdi
call   1030 <plg_load@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_lib>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %rsi,%rbx
call   1050 <auth_isowner@plt>
test   %eax,%eax
je     116e <load_lib+0x3e>
cmp    $0x1,%ebp
jne    1177 <load_lib+0x47>
mov    (%r14),%rbp
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <ircproto_privmsg@plt>
mov    %rbp,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <plg_load@plt>
lea    0xe8b(%rip),%rsi
jmp    117e <load_lib+0x4e>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ircproto_privmsg@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"err: not owner\00"
@.str.1 = [22 x i8] c"usage: load_lib <lib>\00"
@.str.2 = [12 x i8] c"loading: %s\00"
define void @load_lib(i8* %0, i8* %1, i8* %2, i8** %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8** %3, i8*** %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = call i32 @auth_isowner(i8* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %5
%16 = load i8*, i8** %7
%17 = call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %33
18: ; preds = %5
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %7
%23 = call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %33
24: ; preds = %18
%25 = load i8**, i8*** %9
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
store i8* %27, i8** %11
%28 = load i8*, i8** %7
%29 = load i8*, i8** %11
%30 = call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %11
%32 = call i32 @plg_load(i8* %31)
br label %33
33: ; preds = %24, %21, %15
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"err: not owner\00"
@.str.1 = [22 x i8] c"usage: load_lib <lib>\00"
@.str.2 = [12 x i8] c"loading: %s\00"
define void @load_lib(i8* %0, i8* %1, i8* nocapture readnone %2, i8** nocapture %3, i32 %4) {
%6 = tail call i32 @auth_isowner(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %5
%11 = icmp eq i32 %4, 1
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %18
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = tail call i32 (i8*, i8*, ...) @ircproto_privmsg(i8* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @plg_load(i8* %15)
br label %18
18: ; preds = %14, %12, %8
ret void
}