#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*/ free(char *);
char *irafrdhead(char *, int *);
int /*<<< orphan*/ irafrdimage(char **, size_t *, size_t *, int *);
int /*<<< orphan*/ iraftofits(char *, char *, int, char **, size_t *, size_t *,
                              int *);
int iraf2mem(char *filename, char **buffptr, size_t *buffsize, size_t *filesize,
             int *status) {
  char *irafheader;
  int lenirafhead;
  *buffptr = NULL;
  *buffsize = 0;
  *filesize = 0;
  irafheader = irafrdhead(filename, &lenirafhead);
  if (!irafheader) {
    return (*status = 104);
  }
  iraftofits(filename, irafheader, lenirafhead, buffptr, buffsize, filesize,
             status);
  free(irafheader);
  if (*status > 0)
    return (*status);
  *filesize = (((*filesize - 1) / 2880) + 1) * 2880;
  irafrdimage(buffptr, buffsize, filesize, status);
  return (*status);
}


x86 assembly (clang, -O0):
<iraf2mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   1060 <irafrdhead@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11af <iraf2mem+0x6f>
mov    -0x30(%rbp),%rax
movl   $0x68,(%rax)
movl   $0x68,-0x4(%rbp)
jmp    123c <iraf2mem+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <iraftofits@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11f7 <iraf2mem+0xb7>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123c <iraf2mem+0xfc>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
sub    $0x1,%rax
mov    $0xb40,%ecx
xor    %edx,%edx
div    %rcx
add    $0x1,%rax
imul   $0xb40,%rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <irafrdimage@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iraf2mem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movq   $0x0,(%rsi)
movq   $0x0,(%rdx)
movq   $0x0,(%rcx)
lea    0x14(%rsp),%rsi
call   1060 <irafrdhead@plt>
test   %rax,%rax
je     11ef <iraf2mem+0xaf>
mov    %rax,%rbp
mov    0x14(%rsp),%edx
mov    %r14,(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12,%rcx
mov    %r15,%r8
mov    %r13,%r9
call   1050 <iraftofits@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    (%r14),%eax
test   %eax,%eax
jg     11fb <iraf2mem+0xbb>
mov    0x0(%r13),%rax
add    $0xffffffffffffffff,%rax
movabs $0x2d82d82d82d82d83,%rcx
d8 82 2d
mul    %rcx
shr    $0x9,%rdx
imul   $0xb40,%rdx,%rax
add    $0xb40,%rax
mov    %rax,0x0(%r13)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
call   1040 <irafrdimage@plt>
mov    (%r14),%eax
jmp    11fb <iraf2mem+0xbb>
movl   $0x68,(%r14)
mov    $0x68,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iraf2mem(i8* %0, i8** %1, i64* %2, i64* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i8** %1, i8*** %8
store i64* %2, i64** %9
store i64* %3, i64** %10
store i32* %4, i32** %11
%14 = load i8**, i8*** %8
store i8* null, i8** %14
%15 = load i64*, i64** %9
store i64 0, i64* %15
%16 = load i64*, i64** %10
store i64 0, i64* %16
%17 = load i8*, i8** %7
%18 = call i8* @irafrdhead(i8* %17, i32* %13)
store i8* %18, i8** %12
%19 = load i8*, i8** %12
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %5
%22 = load i32*, i32** %11
store i32 104, i32* %22
store i32 104, i32* %6
br label %55
23: ; preds = %5
%24 = load i8*, i8** %7
%25 = load i8*, i8** %12
%26 = load i32, i32* %13
%27 = load i8**, i8*** %8
%28 = load i64*, i64** %9
%29 = load i64*, i64** %10
%30 = load i32*, i32** %11
%31 = call i32 @iraftofits(i8* %24, i8* %25, i32 %26, i8** %27, i64* %28, i64* %29, i32* %30)
%32 = load i8*, i8** %12
%33 = call i32 @free(i8* %32)
%34 = load i32*, i32** %11
%35 = load i32, i32* %34
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %23
%38 = load i32*, i32** %11
%39 = load i32, i32* %38
store i32 %39, i32* %6
br label %55
40: ; preds = %23
%41 = load i64*, i64** %10
%42 = load i64, i64* %41
%43 = sub i64 %42, 1
%44 = udiv i64 %43, 2880
%45 = add i64 %44, 1
%46 = mul i64 %45, 2880
%47 = load i64*, i64** %10
store i64 %46, i64* %47
%48 = load i8**, i8*** %8
%49 = load i64*, i64** %9
%50 = load i64*, i64** %10
%51 = load i32*, i32** %11
%52 = call i32 @irafrdimage(i8** %48, i64* %49, i64* %50, i32* %51)
%53 = load i32*, i32** %11
%54 = load i32, i32* %53
store i32 %54, i32* %6
br label %55
55: ; preds = %40, %37, %21
%56 = load i32, i32* %6
ret i32 %56
}

LLVM IR (-O2):
define i32 @iraf2mem(i8* %0, i8** %1, i64* %2, i64* %3, i32* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i8* null, i8** %1
store i64 0, i64* %2
store i64 0, i64* %3
%8 = call i8* @irafrdhead(i8* %0, i32* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %5
store i32 104, i32* %4
br label %25
11: ; preds = %5
%12 = load i32, i32* %6
%13 = call i32 @iraftofits(i8* %0, i8* %8, i32 %12, i8** %1, i64* %2, i64* %3, i32* %4)
%14 = call i32 @free(i8* %8)
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %11
%18 = load i64, i64* %3
%19 = add i64 %18, -1
%20 = urem i64 %19, 2880
%21 = add i64 %18, 2879
%22 = sub i64 %21, %20
store i64 %22, i64* %3
%23 = call i32 @irafrdimage(i8** %1, i64* %2, i64* %3, i32* %4)
%24 = load i32, i32* %4
br label %25
25: ; preds = %11, %17, %10
%26 = phi i32 [ %24, %17 ], [ 104, %10 ], [ %15, %11 ]
ret i32 %26
}