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

/* Variables and functions */
short BEV_EVENT_TIMEOUT;
int /*<<< orphan*/ bufferevent_free(struct bufferevent *);
int /*<<< orphan*/ bufferevent_setcb(struct bufferevent *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ initial_read(struct bufferevent *, void *);
int /*<<< orphan*/ printf(char *);
void initial_error(struct bufferevent *bev, short error, void *ctx) {
  if (error & BEV_EVENT_TIMEOUT) {
    printf("Nothing received, timeout, assuming ssh\n");
    initial_read(bev, ctx);
    return;
  }
  bufferevent_setcb(bev, NULL, NULL, NULL, NULL);
  bufferevent_free(bev);
}


x86 assembly (clang, -O0):
<initial_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
movswl -0xa(%rbp),%eax
mov    0x2e7e(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     118e <initial_error+0x4e>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <initial_read@plt>
jmp    11ae <initial_error+0x6e>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1060 <bufferevent_setcb@plt>
mov    -0x8(%rbp),%rdi
call   1050 <bufferevent_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_error>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%rax
test   %si,(%rax)
je     1174 <initial_error+0x34>
mov    %rdx,%r14
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <initial_read@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <bufferevent_setcb@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <bufferevent_free@plt>

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
@BEV_EVENT_TIMEOUT = global i16 0
@.str = [41 x i8] c"Nothing received, timeout, assuming ssh\0A\00"
define void @initial_error(%struct.bufferevent* %0, i16 signext %1, i8* %2) {
%4 = alloca %struct.bufferevent*
%5 = alloca i16
%6 = alloca i8*
store %struct.bufferevent* %0, %struct.bufferevent** %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%7 = load i16, i16* %5
%8 = sext i16 %7 to i32
%9 = load i16, i16* @BEV_EVENT_TIMEOUT
%10 = sext i16 %9 to i32
%11 = and i32 %8, %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = load %struct.bufferevent*, %struct.bufferevent** %4
%16 = load i8*, i8** %6
%17 = call i32 @initial_read(%struct.bufferevent* %15, i8* %16)
br label %23
18: ; preds = %3
%19 = load %struct.bufferevent*, %struct.bufferevent** %4
%20 = call i32 @bufferevent_setcb(%struct.bufferevent* %19, i32* null, i32* null, i32* null, i32* null)
%21 = load %struct.bufferevent*, %struct.bufferevent** %4
%22 = call i32 @bufferevent_free(%struct.bufferevent* %21)
br label %23
23: ; preds = %18, %13
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
@BEV_EVENT_TIMEOUT = global i16 0
@str = [40 x i8] c"Nothing received, timeout, assuming ssh\00"
define void @initial_error(%struct.bufferevent* %0, i16 signext %1, i8* %2) {
%4 = load i16, i16* @BEV_EVENT_TIMEOUT
%5 = and i16 %4, %1
%6 = icmp eq i16 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @initial_read(%struct.bufferevent* %0, i8* %2)
br label %13
10: ; preds = %3
%11 = tail call i32 @bufferevent_setcb(%struct.bufferevent* %0, i32* null, i32* null, i32* null, i32* null)
%12 = tail call i32 @bufferevent_free(%struct.bufferevent* %0)
br label %13
13: ; preds = %10, %7
ret void
}