#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 */
typedef int uint32_t;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ conv32network_endian(int *, int);
size_t cmd_read_datafifo(uint32_t **bufio, uint32_t n) {
  uint32_t *buf;
  buf = *bufio;
  if (buf == NULL) {
    buf = (uint32_t *)calloc(1, sizeof(uint32_t));
    if (buf == NULL)
      return -1;
    *bufio = buf;
  }
  buf[0] = (0xffff0000 & (0x0019 << 16)) | (0x0000ffff & n);
  conv32network_endian(buf, 1);
  return 1 * sizeof(uint32_t);
}


x86 assembly (clang, -O0):
<cmd_read_datafifo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117b <cmd_read_datafifo+0x5b>
mov    $0x1,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1170 <cmd_read_datafifo+0x50>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11a6 <cmd_read_datafifo+0x86>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%ecx
and    $0xffff,%ecx
or     $0x190000,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1040 <conv32network_endian@plt>
movq   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_read_datafifo>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
jne    114a <cmd_read_datafifo+0x2a>
mov    $0x1,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
test   %rax,%rax
je     116a <cmd_read_datafifo+0x4a>
mov    %rax,%rdi
mov    %rax,(%rbx)
movzwl %bp,%eax
or     $0x190000,%eax
mov    %eax,(%rdi)
mov    $0x1,%esi
call   1040 <conv32network_endian@plt>
mov    $0x4,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0xffffffffffffffff,%rax
jmp    1163 <cmd_read_datafifo+0x43>

LLVM IR (-O0):
define i64 @cmd_read_datafifo(i32** %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32*
store i32** %0, i32*** %4
store i32 %1, i32* %5
%7 = load i32**, i32*** %4
%8 = load i32*, i32** %7
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = call i64 @calloc(i32 1, i32 4)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %11
store i64 -1, i64* %3
br label %28
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = load i32**, i32*** %4
store i32* %18, i32** %19
br label %20
20: ; preds = %17, %2
%21 = load i32, i32* %5
%22 = and i32 65535, %21
%23 = or i32 1638400, %22
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 %23, i32* %25
%26 = load i32*, i32** %6
%27 = call i32 @conv32network_endian(i32* %26, i32 1)
store i64 4, i64* %3
br label %28
28: ; preds = %20, %16
%29 = load i64, i64* %3
ret i64 %29
}

LLVM IR (-O2):
define i64 @cmd_read_datafifo(i32** nocapture %0, i32 %1) {
%3 = load i32*, i32** %0
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i64 @calloc(i32 1, i32 4)
%7 = inttoptr i64 %6 to i32*
%8 = icmp eq i64 %6, 0
br i1 %8, label %15, label %9
9: ; preds = %5
store i32* %7, i32** %0
br label %10
10: ; preds = %9, %2
%11 = phi i32* [ %7, %9 ], [ %3, %2 ]
%12 = and i32 %1, 65535
%13 = or i32 %12, 1638400
store i32 %13, i32* %11
%14 = tail call i32 @conv32network_endian(i32* %11, i32 1)
br label %15
15: ; preds = %5, %10
%16 = phi i64 [ 4, %10 ], [ -1, %5 ]
ret i64 %16
}