#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 */
struct seq_file {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(unsigned char *);
unsigned char *mk_bms(float *, unsigned int *);
int /*<<< orphan*/ mk_sec5and7(float *, unsigned int, unsigned char **,
                               unsigned char **, int, int, int, int, int);
int wrt_sec(unsigned char *, unsigned char *, unsigned char *, unsigned char *,
            unsigned char *, unsigned char *, unsigned char *, unsigned char *,
            struct seq_file *);
int simple_grib_out(unsigned char **sec, float *data, unsigned int ndata,
                    int use_scale, int dec_scale, int bin_scale,
                    int wanted_bits, int max_bits, struct seq_file *out) {
  unsigned int n_defined;
  int i;
  unsigned char *sec0, *sec1, *sec2, *sec3, *sec4, *sec5, *sec6, *sec7;
  sec0 = sec[0];
  sec1 = sec[1];
  sec2 = sec[2];
  sec3 = sec[3];
  sec4 = sec[4];
  n_defined = ndata;
  sec6 = mk_bms(data, &n_defined);
  mk_sec5and7(data, n_defined, &sec5, &sec7, use_scale, dec_scale, bin_scale,
              wanted_bits, max_bits);
  i = wrt_sec(sec0, sec1, sec2, sec3, sec4, sec5, sec6, sec7, out);
  free(sec5);
  free(sec6);
  free(sec7);
  return i;
}


x86 assembly (clang, -O0):
<simple_grib_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <mk_bms@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
lea    -0x58(%rbp),%rdx
lea    -0x68(%rbp),%rcx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1060 <mk_sec5and7@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r11
mov    -0x68(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1050 <wrt_sec@plt>
mov    %eax,-0x28(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_grib_out>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %rsi,%r15
mov    (%rdi),%rax
mov    %rax,0x28(%rsp)
mov    0x8(%rdi),%r12
mov    0x10(%rdi),%r13
mov    0x18(%rdi),%rax
mov    %rax,0x20(%rsp)
mov    0x20(%rdi),%rax
mov    %rax,0x18(%rsp)
mov    %edx,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %r15,%rdi
call   1040 <mk_bms@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
sub    $0x8,%rsp
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r15,%rdi
mov    %r14d,%r8d
mov    %ebp,%r9d
mov    0x80(%rsp),%eax
push   %rax
mov    0x80(%rsp),%eax
push   %rax
push   0x48(%rsp)
call   1060 <mk_sec5and7@plt>
add    $0x20,%rsp
mov    0x10(%rsp),%r9
sub    $0x8,%rsp
mov    0x30(%rsp),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    0x28(%rsp),%rcx
mov    0x20(%rsp),%r8
push   0x88(%rsp)
push   0x18(%rsp)
push   %rbx
call   1050 <wrt_sec@plt>
add    $0x20,%rsp
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.seq_file = type { i32 }
define i32 @simple_grib_out(i8** %0, float* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, %struct.seq_file* %8) {
%10 = alloca i8**
%11 = alloca float*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.seq_file*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca i8*
store i8** %0, i8*** %10
store float* %1, float** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store %struct.seq_file* %8, %struct.seq_file** %18
%29 = load i8**, i8*** %10
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
store i8* %31, i8** %21
%32 = load i8**, i8*** %10
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
store i8* %34, i8** %22
%35 = load i8**, i8*** %10
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
store i8* %37, i8** %23
%38 = load i8**, i8*** %10
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
store i8* %40, i8** %24
%41 = load i8**, i8*** %10
%42 = getelementptr inbounds i8*, i8** %41, i64 4
%43 = load i8*, i8** %42
store i8* %43, i8** %25
%44 = load i32, i32* %12
store i32 %44, i32* %19
%45 = load float*, float** %11
%46 = call i8* @mk_bms(float* %45, i32* %19)
store i8* %46, i8** %27
%47 = load float*, float** %11
%48 = load i32, i32* %19
%49 = load i32, i32* %13
%50 = load i32, i32* %14
%51 = load i32, i32* %15
%52 = load i32, i32* %16
%53 = load i32, i32* %17
%54 = call i32 @mk_sec5and7(float* %47, i32 %48, i8** %26, i8** %28, i32 %49, i32 %50, i32 %51, i32 %52, i32 %53)
%55 = load i8*, i8** %21
%56 = load i8*, i8** %22
%57 = load i8*, i8** %23
%58 = load i8*, i8** %24
%59 = load i8*, i8** %25
%60 = load i8*, i8** %26
%61 = load i8*, i8** %27
%62 = load i8*, i8** %28
%63 = load %struct.seq_file*, %struct.seq_file** %18
%64 = call i32 @wrt_sec(i8* %55, i8* %56, i8* %57, i8* %58, i8* %59, i8* %60, i8* %61, i8* %62, %struct.seq_file* %63)
store i32 %64, i32* %20
%65 = load i8*, i8** %26
%66 = call i32 @free(i8* %65)
%67 = load i8*, i8** %27
%68 = call i32 @free(i8* %67)
%69 = load i8*, i8** %28
%70 = call i32 @free(i8* %69)
%71 = load i32, i32* %20
ret i32 %71
}

LLVM IR (-O2):
%struct.seq_file = type { i32 }
define i32 @simple_grib_out(i8** nocapture %0, float* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, %struct.seq_file* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = bitcast i32* %10 to i8*
%14 = bitcast i8** %11 to i8*
%15 = bitcast i8** %12 to i8*
%16 = load i8*, i8** %0
%17 = getelementptr inbounds i8*, i8** %0, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %0, i64 2
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8*, i8** %0, i64 3
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %0, i64 4
%24 = load i8*, i8** %23
store i32 %2, i32* %10
%25 = call i8* @mk_bms(float* %1, i32* %10)
%26 = load i32, i32* %10
%27 = call i32 @mk_sec5and7(float* %1, i32 %26, i8** %11, i8** %12, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7)
%28 = load i8*, i8** %11
%29 = load i8*, i8** %12
%30 = call i32 @wrt_sec(i8* %16, i8* %18, i8* %20, i8* %22, i8* %24, i8* %28, i8* %25, i8* %29, %struct.seq_file* %8)
%31 = load i8*, i8** %11
%32 = call i32 @free(i8* %31)
%33 = call i32 @free(i8* %25)
%34 = load i8*, i8** %12
%35 = call i32 @free(i8* %34)
ret i32 %30
}