#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 size_t uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
uint32_t rte_min_pos_4_u16(uint16_t *x) {
  uint32_t pos0 = 0;
  uint32_t pos1 = 2;
  if (x[1] <= x[0])
    pos0 = 1;
  if (x[3] <= x[2])
    pos1 = 3;
  if (x[pos1] <= x[pos0])
    pos0 = pos1;
  return pos0;
}


x86 assembly (clang, -O0):
<rte_min_pos_4_u16>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jg     1135 <rte_min_pos_4_u16+0x35>
movq   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x10(%rcx),%rax
jg     1153 <rte_min_pos_4_u16+0x53>
movq   $0x3,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jg     1179 <rte_min_pos_4_u16+0x79>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rte_min_pos_4_u16>:
mov    0x8(%rdi),%rax
mov    0x18(%rdi),%rcx
xor    %edx,%edx
cmp    (%rdi),%rax
setle  %dl
xor    %eax,%eax
cmp    0x10(%rdi),%rcx
setg   %al
xor    $0x3,%rax
mov    (%rdi,%rax,8),%rcx
cmp    (%rdi,%rdx,8),%rcx
cmovg  %rdx,%rax
ret

LLVM IR (-O0):
define i64 @rte_min_pos_4_u16(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
store i64* %0, i64** %2
store i64 0, i64* %3
store i64 2, i64* %4
%5 = load i64*, i64** %2
%6 = getelementptr inbounds i64, i64* %5, i64 1
%7 = load i64, i64* %6
%8 = load i64*, i64** %2
%9 = getelementptr inbounds i64, i64* %8, i64 0
%10 = load i64, i64* %9
%11 = icmp sle i64 %7, %10
br i1 %11, label %12, label %13
12: ; preds = %1
store i64 1, i64* %3
br label %13
13: ; preds = %12, %1
%14 = load i64*, i64** %2
%15 = getelementptr inbounds i64, i64* %14, i64 3
%16 = load i64, i64* %15
%17 = load i64*, i64** %2
%18 = getelementptr inbounds i64, i64* %17, i64 2
%19 = load i64, i64* %18
%20 = icmp sle i64 %16, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i64 3, i64* %4
br label %22
22: ; preds = %21, %13
%23 = load i64*, i64** %2
%24 = load i64, i64* %4
%25 = getelementptr inbounds i64, i64* %23, i64 %24
%26 = load i64, i64* %25
%27 = load i64*, i64** %2
%28 = load i64, i64* %3
%29 = getelementptr inbounds i64, i64* %27, i64 %28
%30 = load i64, i64* %29
%31 = icmp sle i64 %26, %30
br i1 %31, label %32, label %34
32: ; preds = %22
%33 = load i64, i64* %4
store i64 %33, i64* %3
br label %34
34: ; preds = %32, %22
%35 = load i64, i64* %3
ret i64 %35
}

LLVM IR (-O2):
define i64 @rte_min_pos_4_u16(i64* nocapture %0) {
%2 = getelementptr inbounds i64, i64* %0, i64 1
%3 = load i64, i64* %2
%4 = load i64, i64* %0
%5 = icmp sle i64 %3, %4
%6 = zext i1 %5 to i64
%7 = getelementptr inbounds i64, i64* %0, i64 3
%8 = load i64, i64* %7
%9 = getelementptr inbounds i64, i64* %0, i64 2
%10 = load i64, i64* %9
%11 = icmp sgt i64 %8, %10
%12 = select i1 %11, i64 2, i64 3
%13 = getelementptr inbounds i64, i64* %0, i64 %12
%14 = load i64, i64* %13
%15 = getelementptr inbounds i64, i64* %0, i64 %6
%16 = load i64, i64* %15
%17 = icmp sgt i64 %14, %16
%18 = select i1 %17, i64 %6, i64 %12
ret i64 %18
}