#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 strlen(char const *);
void plugin_script_get_function_and_data(void *callback_data,
                                         const char **function,
                                         const char **data) {
  const char *string, *ptr_data;
  string = (const char *)callback_data;
  if (string) {
    *function = string;
    ptr_data = string + strlen(string) + 1;
    *data = (ptr_data[0]) ? ptr_data : NULL;
  } else {
    *function = NULL;
    *data = NULL;
  }
}


x86 assembly (clang, -O0):
<plugin_script_get_function_and_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119f <plugin_script_get_function_and_data+0x8f>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1184 <plugin_script_get_function_and_data+0x74>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    118f <plugin_script_get_function_and_data+0x7f>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    118f <plugin_script_get_function_and_data+0x7f>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11b5 <plugin_script_get_function_and_data+0xa5>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plugin_script_get_function_and_data>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
test   %rdi,%rdi
je     113f <plugin_script_get_function_and_data+0x2f>
mov    %rdi,%rbx
mov    %rdi,(%rsi)
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    (%rbx,%rcx,1),%rdx
add    $0x1,%rdx
xor    %eax,%eax
cmpb   $0x0,0x1(%rbx,%rcx,1)
cmovne %rdx,%rax
jmp    1148 <plugin_script_get_function_and_data+0x38>
movq   $0x0,(%rsi)
xor    %eax,%eax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @plugin_script_get_function_and_data(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %32
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = load i8**, i8*** %5
store i8* %13, i8** %14
%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
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %12
%27 = load i8*, i8** %8
br label %29
28: ; preds = %12
br label %29
29: ; preds = %28, %26
%30 = phi i8* [ %27, %26 ], [ null, %28 ]
%31 = load i8**, i8*** %6
store i8* %30, i8** %31
br label %35
32: ; preds = %3
%33 = load i8**, i8*** %5
store i8* null, i8** %33
%34 = load i8**, i8*** %6
store i8* null, i8** %34
br label %35
35: ; preds = %32, %29
ret void
}

LLVM IR (-O2):
define void @plugin_script_get_function_and_data(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %13, label %5
5: ; preds = %3
store i8* %0, i8** %1
%6 = tail call i32 @strlen(i8* %0)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, i8* null, i8* %9
br label %14
13: ; preds = %3
store i8* null, i8** %1
br label %14
14: ; preds = %13, %5
%15 = phi i8* [ null, %13 ], [ %12, %5 ]
store i8* %15, i8** %2
ret void
}