#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 fgetnf(int /*<<< orphan*/ *, int, float *, int);
int fgettransform(FILE *file, int ntrans, float *trans, int binary) {
  register float *T;
  int nt;
  for (nt = 0; nt < ntrans; nt++) {
    T = trans + 16 * nt;
    switch (fgetnf(file, 16, T, binary)) {
    case 16:
      break;
    case 0:
      return nt;
    default:
      return -1;
    }
  }
  return ntrans;
}


x86 assembly (clang, -O0):
<fgettransform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <fgettransform+0xa5>
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x4,%ecx
movslq %ecx,%rcx
lea    (%rax,%rcx,4),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x10,%esi
call   1030 <fgetnf@plt>
mov    %eax,%ecx
mov    %ecx,-0x38(%rbp)
test   %eax,%eax
je     118b <fgettransform+0x7b>
jmp    1175 <fgettransform+0x65>
mov    -0x38(%rbp),%eax
sub    $0x10,%eax
jne    1196 <fgettransform+0x86>
jmp    1186 <fgettransform+0x76>
jmp    11a2 <fgettransform+0x92>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <fgettransform+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <fgettransform+0xab>
jmp    11a7 <fgettransform+0x97>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    112d <fgettransform+0x1d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgettransform>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
test   %esi,%esi
jle    1163 <fgettransform+0x53>
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rdi,%r15
mov    %ebx,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x10,%esi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1030 <fgetnf@plt>
cmp    $0x10,%eax
jne    115a <fgettransform+0x4a>
add    $0x1,%rbx
add    $0x40,%rbp
cmp    %rbx,%r12
jne    1130 <fgettransform+0x20>
mov    %r12d,%ebx
jmp    1163 <fgettransform+0x53>
test   %eax,%eax
je     1163 <fgettransform+0x53>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fgettransform(i32* %0, i32 %1, float* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store float* %2, float** %8
store i32 %3, i32* %9
store i32 0, i32* %11
br label %12
12: ; preds = %31, %4
%13 = load i32, i32* %11
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load float*, float** %8
%18 = load i32, i32* %11
%19 = mul nsw i32 16, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %17, i64 %20
store float* %21, float** %10
%22 = load i32*, i32** %6
%23 = load float*, float** %10
%24 = load i32, i32* %9
%25 = call i32 @fgetnf(i32* %22, i32 16, float* %23, i32 %24)
switch i32 %25, label %29 [
i32 16, label %26
i32 0, label %27
]
26: ; preds = %16
br label %30
27: ; preds = %16
%28 = load i32, i32* %11
store i32 %28, i32* %5
br label %36
29: ; preds = %16
store i32 -1, i32* %5
br label %36
30: ; preds = %26
br label %31
31: ; preds = %30
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %12
34: ; preds = %12
%35 = load i32, i32* %7
store i32 %35, i32* %5
br label %36
36: ; preds = %34, %29, %27
%37 = load i32, i32* %5
ret i32 %37
}

LLVM IR (-O2):
define i32 @fgettransform(i32* %0, i32 %1, float* %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %18
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %13
%9 = phi i64 [ 0, %6 ], [ %14, %13 ]
%10 = shl nsw i64 %9, 4
%11 = getelementptr inbounds float, float* %2, i64 %10
%12 = tail call i32 @fgetnf(i32* %0, i32 16, float* %11, i32 %3)
switch i32 %12, label %18 [
i32 16, label %13
i32 0, label %16
]
13: ; preds = %8
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %18, label %8
16: ; preds = %8
%17 = trunc i64 %9 to i32
br label %18
18: ; preds = %13, %8, %16, %4
%19 = phi i32 [ %1, %4 ], [ %17, %16 ], [ -1, %8 ], [ %1, %13 ]
ret i32 %19
}