#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 */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int filesize(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int get_FITS_header_size(char *);
int get_bitpix(char *);
int get_npix(char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
scalar_t__ mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, char *, int);
int dump_pix(char *name_in, char *name_out) {
  int fd_in, fd_out;
  char *buf_in;
  char *buf_out;
  int fsize_in, fsize_out, header_size;
  int npix;
  fsize_in = filesize(name_in);
  header_size = get_FITS_header_size(name_in);
  if ((fd_in = open(name_in, O_RDONLY)) == -1) {
    fprintf(stderr, "cannot open file %s: aborting\n", name_in);
    return -1;
  }
  buf_in = (char *)mmap(0, fsize_in, PROT_READ, MAP_SHARED, fd_in, 0);
  if (buf_in == (char *)-1) {
    perror("mmap");
    fprintf(stderr, "cannot mmap file: %s\n", name_in);
    close(fd_in);
    return -1;
  }
  if (get_bitpix(buf_in) != -32) {
    fprintf(stderr, "only 32-bit IEEE floating point format supported\n");
    close(fd_in);
    munmap(buf_in, fsize_in);
    return -1;
  }
  npix = get_npix(buf_in);
  if (npix < 1) {
    fprintf(stderr, "cannot compute number of pixels\n");
    close(fd_in);
    munmap(buf_in, fsize_in);
    return -1;
  }
  fsize_out = npix * 4;
  if ((fd_out = creat(name_out,
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)) == -1) {
    perror("creat");
    fprintf(stderr, "cannot create file %s: aborting\n", name_out);
    close(fd_in);
    munmap(buf_in, fsize_in);
    return -1;
  }
  buf_out = malloc(fsize_out);
  if (buf_out == NULL) {
    fprintf(stderr, "not enough memory\n");
    fprintf(stderr, "failed to allocate %d bytes\n", fsize_out);
    close(fd_in);
    munmap(buf_in, fsize_in);
    return -1;
  }
  write(fd_out, buf_out, fsize_out);
  close(fd_out);
  free(buf_out);
  fd_out = open(name_out, O_RDWR);
  if (fd_out == -1) {
    fprintf(stderr, "error opening file %s\n", name_out);
    close(fd_in);
    munmap(buf_in, fsize_in);
    return -1;
  }
  buf_out =
      (char *)mmap(0, fsize_out, PROT_READ | PROT_WRITE, MAP_SHARED, fd_out, 0);
  if (buf_out == (char *)-1) {
    perror("mmap");
    fprintf(stderr, "cannot mmap file: %s\n", name_out);
    munmap(buf_in, fsize_in);
    close(fd_in);
    close(fd_out);
    return -1;
  }
  memcpy(buf_out, buf_in + header_size, fsize_out);
  close(fd_in);
  close(fd_out);
  munmap(buf_in, fsize_in);
  munmap(buf_out, fsize_out);
  return 0;
}


x86 assembly (clang, -O0):
<dump_pix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <filesize@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_FITS_header_size@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    125d <dump_pix+0x6d>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x34(%rbp),%esi
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    0x2d78(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1070 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x28(%rbp)
jne    12d1 <dump_pix+0xe1>
lea    0xd82(%rip),%rdi
call   1100 <perror@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x28(%rbp),%rdi
call   1090 <get_bitpix@plt>
cmp    $0xffffffe0,%eax
je     131a <dump_pix+0x12a>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x28(%rbp),%rdi
call   1040 <get_npix@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x1,-0x40(%rbp)
jge    1367 <dump_pix+0x177>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x40(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c15(%rip),%rax
mov    (%rax),%esi
mov    0x2c3c(%rip),%rax
or     (%rax),%esi
mov    0x2c1b(%rip),%rax
or     (%rax),%esi
mov    0x2c32(%rip),%rax
or     (%rax),%esi
mov    0x2c01(%rip),%rax
or     (%rax),%esi
call   1110 <creat@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    13f9 <dump_pix+0x209>
lea    0xcd4(%rip),%rdi
call   1100 <perror@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xcc1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x38(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1461 <dump_pix+0x271>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%edx
lea    0xc8d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x20(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1060 <write@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
mov    0x2b4c(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    14db <dump_pix+0x2eb>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xc30(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x38(%rbp),%esi
mov    0x2b13(%rip),%rax
mov    (%rax),%edx
mov    0x2aaa(%rip),%rax
or     (%rax),%edx
mov    0x2af1(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1070 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x30(%rbp)
jne    156c <dump_pix+0x37c>
lea    0xafb(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xae7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <dump_pix+0x3c2>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x3c(%rbp),%rax
add    %rax,%rsi
mov    -0x38(%rbp),%edx
call   10b0 <memcpy@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10d0 <munmap@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10d0 <munmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_pix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r13
mov    %rdi,%rbx
call   10f0 <filesize@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <get_FITS_header_size@plt>
mov    %eax,%ebp
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     13ad <dump_pix+0x1bd>
mov    %eax,%r14d
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
mov    0x2da5(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r15d,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     1476 <dump_pix+0x286>
mov    %rax,%r12
mov    %rax,%rdi
call   1090 <get_bitpix@plt>
cmp    $0xffffffe0,%eax
jne    13cc <dump_pix+0x1dc>
mov    %ebp,0x14(%rsp)
mov    %r13,0x8(%rsp)
mov    %r12,%rdi
call   1040 <get_npix@plt>
test   %eax,%eax
jle    13de <dump_pix+0x1ee>
mov    %eax,%r13d
mov    0x2cfa(%rip),%rax
mov    0x2d23(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d00(%rip),%rax
or     (%rax),%esi
mov    0x2d17(%rip),%rax
or     (%rax),%esi
mov    0x2ce6(%rip),%rax
or     (%rax),%esi
mov    0x8(%rsp),%rdi
call   1110 <creat@plt>
cmp    $0xffffffff,%eax
je     14a6 <dump_pix+0x2b6>
mov    %eax,%ebx
mov    %r15d,(%rsp)
shl    $0x2,%r13d
mov    %r13d,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1405 <dump_pix+0x215>
mov    %rax,%rbp
mov    %ebx,%edi
mov    %rax,%rsi
mov    %r13d,%edx
call   1060 <write@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     1431 <dump_pix+0x241>
mov    %eax,%ebp
mov    0x2c67(%rip),%rax
mov    (%rax),%edx
mov    0x2cbe(%rip),%rax
or     (%rax),%edx
mov    0x2ca5(%rip),%rax
mov    (%rax),%ecx
xor    %r15d,%r15d
xor    %edi,%edi
mov    %r13d,%esi
mov    %ebp,0x4(%rsp)
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
mov    (%rsp),%ebp
je     14d3 <dump_pix+0x2e3>
mov    %rax,%rbx
movslq 0x14(%rsp),%rax
mov    %r12,%rsi
add    %rax,%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
call   10b0 <memcpy@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   10d0 <munmap@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   10d0 <munmap@plt>
jmp    1464 <dump_pix+0x274>
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
lea    0xc43(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    145e <dump_pix+0x26e>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
lea    0xc5e(%rip),%rsi
jmp    13ee <dump_pix+0x1fe>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r12,%rdi
mov    %r15d,%esi
jmp    1459 <dump_pix+0x269>
mov    0x2ba4(%rip),%rbx
mov    (%rbx),%edi
lea    0xc9f(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xca2(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    144b <dump_pix+0x25b>
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r12,%rdi
mov    (%rsp),%esi
call   10d0 <munmap@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xba2(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
lea    0xb92(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14d,%edi
call   1080 <close@plt>
jmp    145e <dump_pix+0x26e>
lea    0xbe0(%rip),%rdi
call   1100 <perror@plt>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
lea    0xbd1(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13f5 <dump_pix+0x205>
lea    0xb45(%rip),%rdi
call   1100 <perror@plt>
mov    0x2aca(%rip),%rax
mov    (%rax),%edi
lea    0xb35(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   10d0 <munmap@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    0x4(%rsp),%edi
jmp    149f <dump_pix+0x2af>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"cannot open file %s: aborting\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.1 = [5 x i8] c"mmap\00"
@.str.2 = [22 x i8] c"cannot mmap file: %s\0A\00"
@.str.3 = [50 x i8] c"only 32-bit IEEE floating point format supported\0A\00"
@.str.4 = [33 x i8] c"cannot compute number of pixels\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@.str.5 = [6 x i8] c"creat\00"
@.str.6 = [33 x i8] c"cannot create file %s: aborting\0A\00"
@.str.7 = [19 x i8] c"not enough memory\0A\00"
@.str.8 = [29 x i8] c"failed to allocate %d bytes\0A\00"
@O_RDWR = global i32 0
@.str.9 = [23 x i8] c"error opening file %s\0A\00"
@PROT_WRITE = global i32 0
define i32 @dump_pix(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%14 = load i8*, i8** %4
%15 = call i32 @filesize(i8* %14)
store i32 %15, i32* %10
%16 = load i8*, i8** %4
%17 = call i32 @get_FITS_header_size(i8* %16)
store i32 %17, i32* %12
%18 = load i8*, i8** %4
%19 = load i32, i32* @O_RDONLY
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 -1, i32* %3
br label %172
26: ; preds = %2
%27 = load i32, i32* %10
%28 = load i32, i32* @PROT_READ
%29 = load i32, i32* @MAP_SHARED
%30 = load i32, i32* %6
%31 = call i64 @mmap(i32 0, i32 %27, i32 %28, i32 %29, i32 %30, i32 0)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = icmp eq i8* %33, inttoptr (i64 -1 to i8*)
br i1 %34, label %35, label %42
35: ; preds = %26
%36 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %4
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %6
%41 = call i32 @close(i32 %40)
store i32 -1, i32* %3
br label %172
42: ; preds = %26
%43 = load i8*, i8** %8
%44 = call i32 @get_bitpix(i8* %43)
%45 = icmp ne i32 %44, -32
br i1 %45, label %46, label %54
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%49 = load i32, i32* %6
%50 = call i32 @close(i32 %49)
%51 = load i8*, i8** %8
%52 = load i32, i32* %10
%53 = call i32 @munmap(i8* %51, i32 %52)
store i32 -1, i32* %3
br label %172
54: ; preds = %42
%55 = load i8*, i8** %8
%56 = call i32 @get_npix(i8* %55)
store i32 %56, i32* %13
%57 = load i32, i32* %13
%58 = icmp slt i32 %57, 1
br i1 %58, label %59, label %67
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%62 = load i32, i32* %6
%63 = call i32 @close(i32 %62)
%64 = load i8*, i8** %8
%65 = load i32, i32* %10
%66 = call i32 @munmap(i8* %64, i32 %65)
store i32 -1, i32* %3
br label %172
67: ; preds = %54
%68 = load i32, i32* %13
%69 = mul nsw i32 %68, 4
store i32 %69, i32* %11
%70 = load i8*, i8** %5
%71 = load i32, i32* @S_IRUSR
%72 = load i32, i32* @S_IWUSR
%73 = or i32 %71, %72
%74 = load i32, i32* @S_IRGRP
%75 = or i32 %73, %74
%76 = load i32, i32* @S_IWGRP
%77 = or i32 %75, %76
%78 = load i32, i32* @S_IROTH
%79 = or i32 %77, %78
%80 = call i32 @creat(i8* %70, i32 %79)
store i32 %80, i32* %7
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %92
82: ; preds = %67
%83 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%84 = load i32, i32* @stderr
%85 = load i8*, i8** %5
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %85)
%87 = load i32, i32* %6
%88 = call i32 @close(i32 %87)
%89 = load i8*, i8** %8
%90 = load i32, i32* %10
%91 = call i32 @munmap(i8* %89, i32 %90)
store i32 -1, i32* %3
br label %172
92: ; preds = %67
%93 = load i32, i32* %11
%94 = call i8* @malloc(i32 %93)
store i8* %94, i8** %9
%95 = load i8*, i8** %9
%96 = icmp eq i8* %95, null
br i1 %96, label %97, label %108
97: ; preds = %92
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%100 = load i32, i32* @stderr
%101 = load i32, i32* %11
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %6
%104 = call i32 @close(i32 %103)
%105 = load i8*, i8** %8
%106 = load i32, i32* %10
%107 = call i32 @munmap(i8* %105, i32 %106)
store i32 -1, i32* %3
br label %172
108: ; preds = %92
%109 = load i32, i32* %7
%110 = load i8*, i8** %9
%111 = load i32, i32* %11
%112 = call i32 @write(i32 %109, i8* %110, i32 %111)
%113 = load i32, i32* %7
%114 = call i32 @close(i32 %113)
%115 = load i8*, i8** %9
%116 = call i32 @free(i8* %115)
%117 = load i8*, i8** %5
%118 = load i32, i32* @O_RDWR
%119 = call i32 @open(i8* %117, i32 %118)
store i32 %119, i32* %7
%120 = load i32, i32* %7
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %131
122: ; preds = %108
%123 = load i32, i32* @stderr
%124 = load i8*, i8** %5
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %124)
%126 = load i32, i32* %6
%127 = call i32 @close(i32 %126)
%128 = load i8*, i8** %8
%129 = load i32, i32* %10
%130 = call i32 @munmap(i8* %128, i32 %129)
store i32 -1, i32* %3
br label %172
131: ; preds = %108
%132 = load i32, i32* %11
%133 = load i32, i32* @PROT_READ
%134 = load i32, i32* @PROT_WRITE
%135 = or i32 %133, %134
%136 = load i32, i32* @MAP_SHARED
%137 = load i32, i32* %7
%138 = call i64 @mmap(i32 0, i32 %132, i32 %135, i32 %136, i32 %137, i32 0)
%139 = inttoptr i64 %138 to i8*
store i8* %139, i8** %9
%140 = load i8*, i8** %9
%141 = icmp eq i8* %140, inttoptr (i64 -1 to i8*)
br i1 %141, label %142, label %154
142: ; preds = %131
%143 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%144 = load i32, i32* @stderr
%145 = load i8*, i8** %5
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %145)
%147 = load i8*, i8** %8
%148 = load i32, i32* %10
%149 = call i32 @munmap(i8* %147, i32 %148)
%150 = load i32, i32* %6
%151 = call i32 @close(i32 %150)
%152 = load i32, i32* %7
%153 = call i32 @close(i32 %152)
store i32 -1, i32* %3
br label %172
154: ; preds = %131
%155 = load i8*, i8** %9
%156 = load i8*, i8** %8
%157 = load i32, i32* %12
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %156, i64 %158
%160 = load i32, i32* %11
%161 = call i32 @memcpy(i8* %155, i8* %159, i32 %160)
%162 = load i32, i32* %6
%163 = call i32 @close(i32 %162)
%164 = load i32, i32* %7
%165 = call i32 @close(i32 %164)
%166 = load i8*, i8** %8
%167 = load i32, i32* %10
%168 = call i32 @munmap(i8* %166, i32 %167)
%169 = load i8*, i8** %9
%170 = load i32, i32* %11
%171 = call i32 @munmap(i8* %169, i32 %170)
store i32 0, i32* %3
br label %172
172: ; preds = %154, %142, %122, %97, %82, %59, %46, %35, %22
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"cannot open file %s: aborting\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.1 = [5 x i8] c"mmap\00"
@.str.2 = [22 x i8] c"cannot mmap file: %s\0A\00"
@.str.3 = [50 x i8] c"only 32-bit IEEE floating point format supported\0A\00"
@.str.4 = [33 x i8] c"cannot compute number of pixels\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@.str.5 = [6 x i8] c"creat\00"
@.str.6 = [33 x i8] c"cannot create file %s: aborting\0A\00"
@.str.7 = [19 x i8] c"not enough memory\0A\00"
@.str.8 = [29 x i8] c"failed to allocate %d bytes\0A\00"
@O_RDWR = global i32 0
@.str.9 = [23 x i8] c"error opening file %s\0A\00"
@PROT_WRITE = global i32 0
define i32 @dump_pix(i8* %0, i8* %1) {
%3 = tail call i32 @filesize(i8* %0)
%4 = tail call i32 @get_FITS_header_size(i8* %0)
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* %0, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %102
11: ; preds = %2
%12 = load i32, i32* @PROT_READ
%13 = load i32, i32* @MAP_SHARED
%14 = tail call i64 @mmap(i32 0, i32 %3, i32 %12, i32 %13, i32 %6, i32 0)
%15 = inttoptr i64 %14 to i8*
%16 = icmp eq i8* %15, inttoptr (i64 -1 to i8*)
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%21 = tail call i32 @close(i32 %6)
br label %102
22: ; preds = %11
%23 = tail call i32 @get_bitpix(i8* %15)
%24 = icmp eq i32 %23, -32
br i1 %24, label %30, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @close(i32 %6)
%29 = tail call i32 @munmap(i8* %15, i32 %3)
br label %102
30: ; preds = %22
%31 = tail call i32 @get_npix(i8* %15)
%32 = icmp slt i32 %31, 1
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%36 = tail call i32 @close(i32 %6)
%37 = tail call i32 @munmap(i8* %15, i32 %3)
br label %102
38: ; preds = %30
%39 = shl nsw i32 %31, 2
%40 = load i32, i32* @S_IRUSR
%41 = load i32, i32* @S_IWUSR
%42 = or i32 %41, %40
%43 = load i32, i32* @S_IRGRP
%44 = or i32 %42, %43
%45 = load i32, i32* @S_IWGRP
%46 = or i32 %44, %45
%47 = load i32, i32* @S_IROTH
%48 = or i32 %46, %47
%49 = tail call i32 @creat(i8* %1, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %57
51: ; preds = %38
%52 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%55 = tail call i32 @close(i32 %6)
%56 = tail call i32 @munmap(i8* %15, i32 %3)
br label %102
57: ; preds = %38
%58 = tail call i8* @malloc(i32 %39)
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %67
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %39)
%65 = tail call i32 @close(i32 %6)
%66 = tail call i32 @munmap(i8* %15, i32 %3)
br label %102
67: ; preds = %57
%68 = tail call i32 @write(i32 %49, i8* %58, i32 %39)
%69 = tail call i32 @close(i32 %49)
%70 = tail call i32 @free(i8* %58)
%71 = load i32, i32* @O_RDWR
%72 = tail call i32 @open(i8* %1, i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %79
74: ; preds = %67
%75 = load i32, i32* @stderr
%76 = tail call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %1)
%77 = tail call i32 @close(i32 %6)
%78 = tail call i32 @munmap(i8* %15, i32 %3)
br label %102
79: ; preds = %67
%80 = load i32, i32* @PROT_READ
%81 = load i32, i32* @PROT_WRITE
%82 = or i32 %81, %80
%83 = load i32, i32* @MAP_SHARED
%84 = tail call i64 @mmap(i32 0, i32 %39, i32 %82, i32 %83, i32 %72, i32 0)
%85 = inttoptr i64 %84 to i8*
%86 = icmp eq i8* %85, inttoptr (i64 -1 to i8*)
br i1 %86, label %87, label %94
87: ; preds = %79
%88 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%89 = load i32, i32* @stderr
%90 = tail call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%91 = tail call i32 @munmap(i8* %15, i32 %3)
%92 = tail call i32 @close(i32 %6)
%93 = tail call i32 @close(i32 %72)
br label %102
94: ; preds = %79
%95 = sext i32 %4 to i64
%96 = getelementptr inbounds i8, i8* %15, i64 %95
%97 = tail call i32 @memcpy(i8* %85, i8* %96, i32 %39)
%98 = tail call i32 @close(i32 %6)
%99 = tail call i32 @close(i32 %72)
%100 = tail call i32 @munmap(i8* %15, i32 %3)
%101 = tail call i32 @munmap(i8* %85, i32 %39)
br label %102
102: ; preds = %94, %87, %74, %60, %51, %33, %25, %17, %8
%103 = phi i32 [ -1, %8 ], [ -1, %17 ], [ -1, %25 ], [ -1, %33 ], [ -1, %51 ], [ -1, %60 ], [ -1, %74 ], [ -1, %87 ], [ 0, %94 ]
ret i32 %103
}