#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 evbuffer {
  int dummy;
};
struct bufferevent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ bufferevent_free(struct bufferevent *);
struct evbuffer *bufferevent_get_output(struct bufferevent *);
scalar_t__ evbuffer_get_length(struct evbuffer *);
char *strrchr(char *, char);
void xkcp_mon_write_cb(struct bufferevent *bev, void *ctx) {
  struct evbuffer *output = bufferevent_get_output(bev);
  if (evbuffer_get_length(output) == 0) {
    _debug((strrchr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/liudf0716/xkcptun/refs/"
                    "heads/master/xkcp_mon.c",
                    '/')
                ? strrchr("/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                          "liudf0716/xkcptun/refs/heads/master/xkcp_mon.c",
                          '/') +
                      1
                : "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/liudf0716/xkcptun/refs/"
                  "heads/master/xkcp_mon.c"),
           137, LOG_INFO, "xkcp_mon_write_cb flush");
    bufferevent_free(bev);
  }
}


x86 assembly (clang, -O0):
<xkcp_mon_write_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <bufferevent_get_output@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <evbuffer_get_length@plt>
cmp    $0x0,%rax
jne    11f0 <xkcp_mon_write_cb+0xa0>
lea    0xe79(%rip),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
cmp    $0x0,%rax
je     11b9 <xkcp_mon_write_cb+0x69>
lea    0xe5e(%rip),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c9 <xkcp_mon_write_cb+0x79>
lea    0xe40(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c9 <xkcp_mon_write_cb+0x79>
mov    -0x20(%rbp),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
mov    $0x89,%esi
lea    0xea7(%rip),%rcx
call   1050 <_debug@plt>
mov    -0x8(%rbp),%rdi
call   1070 <bufferevent_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xkcp_mon_write_cb>:
push   %rbx
mov    %rdi,%rbx
call   1030 <bufferevent_get_output@plt>
mov    %rax,%rdi
call   1050 <evbuffer_get_length@plt>
test   %rax,%rax
je     1158 <xkcp_mon_write_cb+0x18>
pop    %rbx
ret
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
lea    0xf16(%rip),%rdi
lea    0xf1a(%rip),%rcx
mov    $0x89,%esi
call   1040 <_debug@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <bufferevent_free@plt>

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/liudf0716/xkcptun/refs/heads/master/xkcp_mon.c\00"
@LOG_INFO = global i32 0
@.str.1 = [24 x i8] c"xkcp_mon_write_cb flush\00"
define void @xkcp_mon_write_cb(%struct.bufferevent* %0, i8* %1) {
%3 = alloca %struct.bufferevent*
%4 = alloca i8*
%5 = alloca %struct.evbuffer*
store %struct.bufferevent* %0, %struct.bufferevent** %3
store i8* %1, i8** %4
%6 = load %struct.bufferevent*, %struct.bufferevent** %3
%7 = call %struct.evbuffer* @bufferevent_get_output(%struct.bufferevent* %6)
store %struct.evbuffer* %7, %struct.evbuffer** %5
%8 = load %struct.evbuffer*, %struct.evbuffer** %5
%9 = call i64 @evbuffer_get_length(%struct.evbuffer* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = call i8* @strrchr(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i8 signext 47)
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i8* @strrchr(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i8 signext 47)
%16 = getelementptr inbounds i8, i8* %15, i64 1
br label %18
17: ; preds = %11
br label %18
18: ; preds = %17, %14
%19 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), %17 ]
%20 = load i32, i32* @LOG_INFO
%21 = call i32 @_debug(i8* %19, i32 137, i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%22 = load %struct.bufferevent*, %struct.bufferevent** %3
%23 = call i32 @bufferevent_free(%struct.bufferevent* %22)
br label %24
24: ; preds = %18, %2
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/liudf0716/xkcptun/refs/heads/master/xkcp_mon.c\00"
@LOG_INFO = global i32 0
@.str.1 = [24 x i8] c"xkcp_mon_write_cb flush\00"
define void @xkcp_mon_write_cb(%struct.bufferevent* %0, i8* nocapture readnone %1) {
%3 = tail call %struct.evbuffer* @bufferevent_get_output(%struct.bufferevent* %0)
%4 = tail call i64 @evbuffer_get_length(%struct.evbuffer* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @LOG_INFO
%8 = tail call i32 @_debug(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 126), i32 137, i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @bufferevent_free(%struct.bufferevent* %0)
br label %10
10: ; preds = %6, %2
ret void
}