#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 SSH_CONN {
  int dummy;
};
struct SSH_BUFFER {
  int dummy;
};

/* Variables and functions */
scalar_t__ ssh_buf_write_cstring(struct SSH_BUFFER *, char const *);
scalar_t__ ssh_buf_write_u8(struct SSH_BUFFER *, int);
struct SSH_BUFFER *ssh_conn_new_packet(struct SSH_CONN *);
scalar_t__ ssh_conn_send_packet(struct SSH_CONN *);
int ssh_conn_send_ignore_msg(struct SSH_CONN *conn, const char *msg) {
  struct SSH_BUFFER *pack;
  pack = ssh_conn_new_packet(conn);
  if (pack == NULL)
    return -1;
  if (ssh_buf_write_u8(pack, 2) < 0 || ssh_buf_write_cstring(pack, msg))
    return -1;
  if (ssh_conn_send_packet(conn) < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<ssh_conn_send_ignore_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ssh_conn_new_packet@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1174 <ssh_conn_send_ignore_msg+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <ssh_conn_send_ignore_msg+0x95>
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1050 <ssh_buf_write_u8@plt>
cmp    $0x0,%rax
jl     11a3 <ssh_conn_send_ignore_msg+0x63>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ssh_buf_write_cstring@plt>
cmp    $0x0,%rax
je     11af <ssh_conn_send_ignore_msg+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <ssh_conn_send_ignore_msg+0x95>
mov    -0x10(%rbp),%rdi
call   1030 <ssh_conn_send_packet@plt>
cmp    $0x0,%rax
jge    11ce <ssh_conn_send_ignore_msg+0x8e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <ssh_conn_send_ignore_msg+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssh_conn_send_ignore_msg>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
call   1060 <ssh_conn_new_packet@plt>
mov    $0xffffffff,%r12d
test   %rax,%rax
je     1192 <ssh_conn_send_ignore_msg+0x52>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2,%esi
call   1050 <ssh_buf_write_u8@plt>
test   %rax,%rax
js     1192 <ssh_conn_send_ignore_msg+0x52>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <ssh_buf_write_cstring@plt>
test   %rax,%rax
jne    1192 <ssh_conn_send_ignore_msg+0x52>
mov    %r14,%rdi
call   1030 <ssh_conn_send_packet@plt>
mov    %rax,%r12
sar    $0x3f,%r12
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.SSH_CONN = type { i32 }
%struct.SSH_BUFFER = type { i32 }
define i32 @ssh_conn_send_ignore_msg(%struct.SSH_CONN* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.SSH_CONN*
%5 = alloca i8*
%6 = alloca %struct.SSH_BUFFER*
store %struct.SSH_CONN* %0, %struct.SSH_CONN** %4
store i8* %1, i8** %5
%7 = load %struct.SSH_CONN*, %struct.SSH_CONN** %4
%8 = call %struct.SSH_BUFFER* @ssh_conn_new_packet(%struct.SSH_CONN* %7)
store %struct.SSH_BUFFER* %8, %struct.SSH_BUFFER** %6
%9 = load %struct.SSH_BUFFER*, %struct.SSH_BUFFER** %6
%10 = icmp eq %struct.SSH_BUFFER* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %28
12: ; preds = %2
%13 = load %struct.SSH_BUFFER*, %struct.SSH_BUFFER** %6
%14 = call i64 @ssh_buf_write_u8(%struct.SSH_BUFFER* %13, i32 2)
%15 = icmp slt i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = load %struct.SSH_BUFFER*, %struct.SSH_BUFFER** %6
%18 = load i8*, i8** %5
%19 = call i64 @ssh_buf_write_cstring(%struct.SSH_BUFFER* %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16, %12
store i32 -1, i32* %3
br label %28
22: ; preds = %16
%23 = load %struct.SSH_CONN*, %struct.SSH_CONN** %4
%24 = call i64 @ssh_conn_send_packet(%struct.SSH_CONN* %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 -1, i32* %3
br label %28
27: ; preds = %22
store i32 0, i32* %3
br label %28
28: ; preds = %27, %26, %21, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.SSH_CONN = type { i32 }
%struct.SSH_BUFFER = type { i32 }
define i32 @ssh_conn_send_ignore_msg(%struct.SSH_CONN* %0, i8* %1) {
%3 = tail call %struct.SSH_BUFFER* @ssh_conn_new_packet(%struct.SSH_CONN* %0)
%4 = icmp eq %struct.SSH_BUFFER* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i64 @ssh_buf_write_u8(%struct.SSH_BUFFER* %3, i32 2)
%7 = icmp slt i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i64 @ssh_buf_write_cstring(%struct.SSH_BUFFER* %3, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i64 @ssh_conn_send_packet(%struct.SSH_CONN* %0)
%13 = ashr i64 %12, 63
%14 = trunc i64 %13 to i32
br label %15
15: ; preds = %11, %5, %8, %2
%16 = phi i32 [ -1, %2 ], [ -1, %8 ], [ -1, %5 ], [ %14, %11 ]
ret i32 %16
}