#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 */

/* Variables and functions */
scalar_t__ check_malloc(int);
int /*<<< orphan*/ close(int);
int croptrfile(char *);
int /*<<< orphan*/ endpar();
float float_swap(char *);
int /*<<< orphan*/ getpar(char *, char *, int *);
int long_swap(char *);
int /*<<< orphan*/ mstpar(char *, char *, char *);
int opfile_ro(char *);
int /*<<< orphan*/ reed(int, ...);
int /*<<< orphan*/ rite(int, ...);
int /*<<< orphan*/ setpar(int, char **);
main(int ac, char **av) {
  int fdr, fdw, ntswap, i, ndat;
  float *fbuf;
  char *cbuf;
  char infile[128];
  char outfile[128];
  int nt = -1;
  setpar(ac, av);
  mstpar("infile", "s", infile);
  mstpar("outfile", "s", outfile);
  getpar("nt", "d", &nt);
  endpar();
  fdr = opfile_ro(infile);
  if (nt < 0) {
    reed(fdr, &nt, sizeof(int));
    ndat = 8 * nt + 6;
    cbuf = (char *)check_malloc(ndat * sizeof(float));
    fbuf = (float *)check_malloc(ndat * sizeof(float));
  } else {
    ndat = 8 * nt + 6;
    cbuf = (char *)check_malloc(ndat * sizeof(float));
    fbuf = (float *)check_malloc(ndat * sizeof(float));
    reed(fdr, &nt, sizeof(int));
  }
  reed(fdr, cbuf, ndat * sizeof(float));
  close(fdr);
  ntswap = long_swap((char *)(&nt));
  for (i = 0; i < ndat; i++)
    fbuf[i] = float_swap(cbuf + (i * 4));
  fdw = croptrfile(outfile);
  rite(fdw, &ntswap, sizeof(int));
  rite(fdw, fbuf, ndat * sizeof(float));
  close(fdw);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x144(%rbp)
ff ff ff
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <setpar@plt>
lea    -0xc0(%rbp),%rdx
lea    0xe03(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1060 <mstpar@plt>
lea    -0x140(%rbp),%rdx
lea    0xdf2(%rip),%rdi
lea    0xde9(%rip),%rsi
call   1060 <mstpar@plt>
lea    0xde7(%rip),%rdi
lea    0xde3(%rip),%rsi
lea    -0x144(%rbp),%rdx
call   10c0 <getpar@plt>
mov    $0x0,%al
call   10d0 <endpar@plt>
lea    -0xc0(%rbp),%rdi
call   1080 <opfile_ro@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x144(%rbp)
jge    12b0 <main+0xf0>
mov    -0x14(%rbp),%edi
lea    -0x144(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <reed@plt>
mov    -0x144(%rbp),%eax
shl    $0x3,%eax
add    $0x6,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <check_malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <check_malloc@plt>
mov    %rax,-0x30(%rbp)
jmp    12fb <main+0x13b>
mov    -0x144(%rbp),%eax
shl    $0x3,%eax
add    $0x6,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <check_malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <check_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x144(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <reed@plt>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rdx
shl    $0x2,%rdx
mov    $0x0,%al
call   1030 <reed@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    -0x144(%rbp),%rdi
call   10a0 <long_swap@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    136a <main+0x1aa>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
cltq
add    %rax,%rdi
call   10e0 <float_swap@plt>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    132f <main+0x16f>
lea    -0x140(%rbp),%rdi
call   1050 <croptrfile@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1070 <rite@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rdx
shl    $0x2,%rdx
mov    $0x0,%al
call   1070 <rite@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
movl   $0xffffffff,0x8(%rsp)
ff
call   1040 <setpar@plt>
lea    0xe1b(%rip),%rdi
lea    0xe1b(%rip),%rbx
lea    0x90(%rsp),%rbp
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1060 <mstpar@plt>
lea    0xe03(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1060 <mstpar@plt>
lea    0xdf7(%rip),%rdi
lea    0xdf3(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10c0 <getpar@plt>
xor    %eax,%eax
call   10d0 <endpar@plt>
mov    %rbp,%rdi
call   1080 <opfile_ro@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%eax
test   %eax,%eax
js     1282 <main+0xc2>
mov    %eax,%ecx
shl    $0x3,%ecx
lea    0x6(,%rax,8),%ebp
lea    0x18(,%rcx,4),%ebx
mov    %ebx,%edi
call   10b0 <check_malloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   10b0 <check_malloc@plt>
mov    %rax,%r13
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1030 <reed@plt>
jmp    12bf <main+0xff>
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1030 <reed@plt>
mov    0x8(%rsp),%eax
lea    0x6(,%rax,8),%ebp
shl    $0x3,%eax
lea    0x18(,%rax,4),%ebx
mov    %ebx,%edi
call   10b0 <check_malloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   10b0 <check_malloc@plt>
mov    %rax,%r13
movslq %ebp,%rbx
lea    0x0(,%rbx,4),%r15
mov    %r14d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <reed@plt>
mov    %r14d,%edi
call   1090 <close@plt>
lea    0x8(%rsp),%rdi
call   10a0 <long_swap@plt>
mov    %eax,0xc(%rsp)
test   %ebx,%ebx
jle    1319 <main+0x159>
mov    %ebp,%ebx
shl    $0x2,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    (%r12,%rbp,1),%rdi
call   10e0 <float_swap@plt>
movss  %xmm0,0x0(%r13,%rbp,1)
add    $0x4,%rbp
cmp    %rbp,%rbx
jne    1300 <main+0x140>
lea    0x10(%rsp),%rdi
call   1050 <croptrfile@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %eax,%edi
xor    %eax,%eax
call   1070 <rite@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <rite@plt>
mov    %ebp,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"infile\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [8 x i8] c"outfile\00"
@.str.3 = [3 x i8] c"nt\00"
@.str.4 = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca i8*
%13 = alloca [128 x i8]
%14 = alloca [128 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %15
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @setpar(i32 %16, i8** %17)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%20 = call i32 @mstpar(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%22 = call i32 @mstpar(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 @getpar(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %15)
%24 = call i32 (...) @endpar()
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%26 = call i32 @opfile_ro(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %15
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %47
29: ; preds = %2
%30 = load i32, i32* %6
%31 = call i32 (i32, ...) @reed(i32 %30, i32* %15, i64 4)
%32 = load i32, i32* %15
%33 = mul nsw i32 8, %32
%34 = add nsw i32 %33, 6
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 4
%38 = trunc i64 %37 to i32
%39 = call i64 @check_malloc(i32 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %12
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = mul i64 %42, 4
%44 = trunc i64 %43 to i32
%45 = call i64 @check_malloc(i32 %44)
%46 = inttoptr i64 %45 to float*
store float* %46, float** %11
br label %65
47: ; preds = %2
%48 = load i32, i32* %15
%49 = mul nsw i32 8, %48
%50 = add nsw i32 %49, 6
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = mul i64 %52, 4
%54 = trunc i64 %53 to i32
%55 = call i64 @check_malloc(i32 %54)
%56 = inttoptr i64 %55 to i8*
store i8* %56, i8** %12
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 4
%60 = trunc i64 %59 to i32
%61 = call i64 @check_malloc(i32 %60)
%62 = inttoptr i64 %61 to float*
store float* %62, float** %11
%63 = load i32, i32* %6
%64 = call i32 (i32, ...) @reed(i32 %63, i32* %15, i64 4)
br label %65
65: ; preds = %47, %29
%66 = load i32, i32* %6
%67 = load i8*, i8** %12
%68 = load i32, i32* %10
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 4
%71 = call i32 (i32, ...) @reed(i32 %66, i8* %67, i64 %70)
%72 = load i32, i32* %6
%73 = call i32 @close(i32 %72)
%74 = bitcast i32* %15 to i8*
%75 = call i32 @long_swap(i8* %74)
store i32 %75, i32* %8
store i32 0, i32* %9
br label %76
76: ; preds = %91, %65
%77 = load i32, i32* %9
%78 = load i32, i32* %10
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %94
80: ; preds = %76
%81 = load i8*, i8** %12
%82 = load i32, i32* %9
%83 = mul nsw i32 %82, 4
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = call float @float_swap(i8* %85)
%87 = load float*, float** %11
%88 = load i32, i32* %9
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds float, float* %87, i64 %89
store float %86, float* %90
br label %91
91: ; preds = %80
%92 = load i32, i32* %9
%93 = add nsw i32 %92, 1
store i32 %93, i32* %9
br label %76
94: ; preds = %76
%95 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%96 = call i32 @croptrfile(i8* %95)
store i32 %96, i32* %7
%97 = load i32, i32* %7
%98 = call i32 (i32, ...) @rite(i32 %97, i32* %8, i64 4)
%99 = load i32, i32* %7
%100 = load float*, float** %11
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = mul i64 %102, 4
%104 = call i32 (i32, ...) @rite(i32 %99, float* %100, i64 %103)
%105 = load i32, i32* %7
%106 = call i32 @close(i32 %105)
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@.str = [7 x i8] c"infile\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [8 x i8] c"outfile\00"
@.str.3 = [3 x i8] c"nt\00"
@.str.4 = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
store i32 -1, i32* %6
%11 = tail call i32 @setpar(i32 %0, i8** %1)
%12 = call i32 @mstpar(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = call i32 @mstpar(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%14 = call i32 @getpar(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%15 = call i32 (...) @endpar()
%16 = call i32 @opfile_ro(i8* %8)
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %2
%20 = call i32 (i32, ...) @reed(i32 %16, i32* %6, i64 4)
%21 = load i32, i32* %6
%22 = shl nsw i32 %21, 3
%23 = or i32 %22, 6
%24 = shl i32 %23, 2
%25 = call i64 @check_malloc(i32 %24)
%26 = call i64 @check_malloc(i32 %24)
br label %34
27: ; preds = %2
%28 = shl nsw i32 %17, 3
%29 = or i32 %28, 6
%30 = shl i32 %29, 2
%31 = call i64 @check_malloc(i32 %30)
%32 = call i64 @check_malloc(i32 %30)
%33 = call i32 (i32, ...) @reed(i32 %16, i32* %6, i64 4)
br label %34
34: ; preds = %27, %19
%35 = phi i32 [ %23, %19 ], [ %29, %27 ]
%36 = phi i64 [ %26, %19 ], [ %32, %27 ]
%37 = phi i64 [ %25, %19 ], [ %31, %27 ]
%38 = inttoptr i64 %37 to i8*
%39 = inttoptr i64 %36 to float*
%40 = sext i32 %35 to i64
%41 = shl nsw i64 %40, 2
%42 = call i32 (i32, ...) @reed(i32 %16, i8* %38, i64 %41)
%43 = call i32 @close(i32 %16)
%44 = call i32 @long_swap(i8* %10)
store i32 %44, i32* %3
%45 = icmp sgt i32 %35, 0
br i1 %45, label %46, label %56
46: ; preds = %34
%47 = zext i32 %35 to i64
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ 0, %46 ], [ %54, %48 ]
%50 = shl nsw i64 %49, 2
%51 = getelementptr inbounds i8, i8* %38, i64 %50
%52 = call float @float_swap(i8* %51)
%53 = getelementptr inbounds float, float* %39, i64 %49
store float %52, float* %53
%54 = add nuw nsw i64 %49, 1
%55 = icmp eq i64 %54, %47
br i1 %55, label %56, label %48
56: ; preds = %48, %34
%57 = call i32 @croptrfile(i8* %9)
%58 = call i32 (i32, ...) @rite(i32 %57, i32* %3, i64 4)
%59 = call i32 (i32, ...) @rite(i32 %57, float* %39, i64 %41)
%60 = call i32 @close(i32 %57)
ret i32 0
}