#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int E_ReadTypeAndTimeStamp(int /*<<< orphan*/ *, double *);
int E_GetCronNextData(FILE **descr, size_t size, int *idx, int *msg_type) {
  double mini_stamp = -1.0;
  double stamp;
  int i, type;
  int first = 1;
  *idx = -1;
  *msg_type = -1;
  for (i = 0; i < size; i++) {
    if ((type = E_ReadTypeAndTimeStamp(descr[i], &stamp)) == -1) {
      return 0;
    }
    if (stamp < mini_stamp || first) {
      mini_stamp = stamp;
      *idx = i;
      *msg_type = type;
      first = 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<E_GetCronNextData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11e6 <E_GetCronNextData+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <E_ReadTypeAndTimeStamp@plt>
mov    %eax,-0x40(%rbp)
cmp    $0xffffffff,%eax
jne    1192 <E_GetCronNextData+0x82>
movl   $0x0,-0x4(%rbp)
jmp    11ed <E_GetCronNextData+0xdd>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11b0 <E_GetCronNextData+0xa0>
cmpl   $0x0,-0x44(%rbp)
je     11d3 <E_GetCronNextData+0xc3>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x44(%rbp)
jmp    11d8 <E_GetCronNextData+0xc8>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1157 <E_GetCronNextData+0x47>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E_GetCronNextData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0xffffffff,(%rdx)
movl   $0xffffffff,(%rcx)
mov    $0x1,%eax
test   %rsi,%rsi
je     11b3 <E_GetCronNextData+0xa3>
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%r13b
xor    %r14d,%r14d
jmp    116c <E_GetCronNextData+0x5c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
xor    %r13d,%r13d
cmp    %r14,%rbx
je     11aa <E_GetCronNextData+0x9a>
mov    0x0(%rbp,%r14,8),%rdi
lea    0x10(%rsp),%rsi
call   1030 <E_ReadTypeAndTimeStamp@plt>
cmp    $0xffffffff,%eax
je     11b1 <E_GetCronNextData+0xa1>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setbe  %cl
not    %r13b
test   %cl,%r13b
jne    1160 <E_GetCronNextData+0x50>
mov    %r14d,(%r12)
mov    %eax,(%r15)
movsd  %xmm0,0x8(%rsp)
jmp    1160 <E_GetCronNextData+0x50>
mov    $0x1,%eax
jmp    11b3 <E_GetCronNextData+0xa3>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @E_GetCronNextData(i32** %0, i64 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32** %0, i32*** %6
store i64 %1, i64* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store double -1.000000e+00, double* %10
store i32 1, i32* %14
%15 = load i32*, i32** %8
store i32 -1, i32* %15
%16 = load i32*, i32** %9
store i32 -1, i32* %16
store i32 0, i32* %12
br label %17
17: ; preds = %45, %4
%18 = load i32, i32* %12
%19 = sext i32 %18 to i64
%20 = load i64, i64* %7
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %48
22: ; preds = %17
%23 = load i32**, i32*** %6
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
%27 = load i32*, i32** %26
%28 = call i32 @E_ReadTypeAndTimeStamp(i32* %27, double* %11)
store i32 %28, i32* %13
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 0, i32* %5
br label %49
31: ; preds = %22
%32 = load double, double* %11
%33 = load double, double* %10
%34 = fcmp olt double %32, %33
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = load i32, i32* %14
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %35, %31
%39 = load double, double* %11
store double %39, double* %10
%40 = load i32, i32* %12
%41 = load i32*, i32** %8
store i32 %40, i32* %41
%42 = load i32, i32* %13
%43 = load i32*, i32** %9
store i32 %42, i32* %43
store i32 0, i32* %14
br label %44
44: ; preds = %38, %35
br label %45
45: ; preds = %44
%46 = load i32, i32* %12
%47 = add nsw i32 %46, 1
store i32 %47, i32* %12
br label %17
48: ; preds = %17
store i32 1, i32* %5
br label %49
49: ; preds = %48, %30
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
define i32 @E_GetCronNextData(i32** nocapture %0, i64 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca double
%6 = bitcast double* %5 to i8*
store i32 -1, i32* %2
store i32 -1, i32* %3
%7 = icmp eq i64 %1, 0
br i1 %7, label %26, label %8
8: ; preds = %4, %22
%9 = phi i64 [ %24, %22 ], [ 0, %4 ]
%10 = phi i1 [ false, %22 ], [ true, %4 ]
%11 = phi double [ %23, %22 ], [ -1.000000e+00, %4 ]
%12 = getelementptr inbounds i32*, i32** %0, i64 %9
%13 = load i32*, i32** %12
%14 = call i32 @E_ReadTypeAndTimeStamp(i32* %13, double* %5)
%15 = icmp eq i32 %14, -1
br i1 %15, label %26, label %16
16: ; preds = %8
%17 = load double, double* %5
%18 = fcmp olt double %17, %11
%19 = or i1 %10, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = trunc i64 %9 to i32
store i32 %21, i32* %2
store i32 %14, i32* %3
br label %22
22: ; preds = %20, %16
%23 = phi double [ %17, %20 ], [ %11, %16 ]
%24 = add nuw i64 %9, 1
%25 = icmp eq i64 %24, %1
br i1 %25, label %26, label %8
26: ; preds = %8, %22, %4
%27 = phi i32 [ 1, %4 ], [ 1, %22 ], [ 0, %8 ]
ret i32 %27
}