#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 netchannel {
  int dummy;
};
struct nc_buff {
  int dummy;
};

/* Variables and functions */
struct nc_buff *atcp_process_in_ncb(struct netchannel *, unsigned int *);
int /*<<< orphan*/ ncb_put(struct nc_buff *);
int netchannel_recv_raw(struct netchannel *, unsigned int);
int atcp_out_read(struct netchannel *nc, unsigned int tm) {
  struct nc_buff *ncb;
  unsigned int init_len;
  int err;
  err = netchannel_recv_raw(nc, tm);
  ncb = atcp_process_in_ncb(nc, &init_len);
  if (ncb) {
    ncb_put(ncb);
    return 1;
  }
  return err;
}


x86 assembly (clang, -O0):
<atcp_out_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <netchannel_recv_raw@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <atcp_process_in_ncb@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     117f <atcp_out_read+0x4f>
mov    -0x20(%rbp),%rdi
call   1040 <ncb_put@plt>
movl   $0x1,-0x4(%rbp)
jmp    1185 <atcp_out_read+0x55>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atcp_out_read>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <netchannel_recv_raw@plt>
mov    %eax,%ebp
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <atcp_process_in_ncb@plt>
test   %rax,%rax
je     115c <atcp_out_read+0x2c>
mov    %rax,%rdi
call   1040 <ncb_put@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.netchannel = type { i32 }
%struct.nc_buff = type { i32 }
define i32 @atcp_out_read(%struct.netchannel* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.netchannel*
%5 = alloca i32
%6 = alloca %struct.nc_buff*
%7 = alloca i32
%8 = alloca i32
store %struct.netchannel* %0, %struct.netchannel** %4
store i32 %1, i32* %5
%9 = load %struct.netchannel*, %struct.netchannel** %4
%10 = load i32, i32* %5
%11 = call i32 @netchannel_recv_raw(%struct.netchannel* %9, i32 %10)
store i32 %11, i32* %8
%12 = load %struct.netchannel*, %struct.netchannel** %4
%13 = call %struct.nc_buff* @atcp_process_in_ncb(%struct.netchannel* %12, i32* %7)
store %struct.nc_buff* %13, %struct.nc_buff** %6
%14 = load %struct.nc_buff*, %struct.nc_buff** %6
%15 = icmp ne %struct.nc_buff* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load %struct.nc_buff*, %struct.nc_buff** %6
%18 = call i32 @ncb_put(%struct.nc_buff* %17)
store i32 1, i32* %3
br label %21
19: ; preds = %2
%20 = load i32, i32* %8
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %16
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.netchannel = type { i32 }
%struct.nc_buff = type { i32 }
define i32 @atcp_out_read(%struct.netchannel* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @netchannel_recv_raw(%struct.netchannel* %0, i32 %1)
%6 = call %struct.nc_buff* @atcp_process_in_ncb(%struct.netchannel* %0, i32* %3)
%7 = icmp eq %struct.nc_buff* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @ncb_put(%struct.nc_buff* %6)
br label %10
10: ; preds = %2, %8
%11 = phi i32 [ 1, %8 ], [ %5, %2 ]
ret i32 %11
}