#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*/ clrhd(char *);
int /*<<< orphan*/ dskbcr_(int *, int *);
int /*<<< orphan*/ dskbor_(int *, char *, int *, int *);
int /*<<< orphan*/ dskbr_(int *, char *, int *, int *);
int /*<<< orphan*/ dskbwr_(int *, int *);
int filec_getdebug();
int /*<<< orphan*/ free(char *);
int getbo();
void *malloc(int);
int /*<<< orphan*/ memcpy(unsigned short *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puthd(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ swpbyt(int /*<<< orphan*/, int, char *);
int rdlum(char *filename, char **head, int *lhead, char **array, int *naxis,
          int *axis, int *type) {
  int readl;
  int i, j;
  int istat, cbo;
  int lun = 1;
  int lflag;
  int is1 = 0, is2 = 0;
  char lumhead[2048];
  unsigned short lumsiz[2];
  unsigned int *data;
  char s[132];
  int filec_debug = filec_getdebug();
  *array = 0;
  *head = 0;
  j = strlen(filename);
  if (filec_debug)
    printf("Opening file: %s\n", filename);
  dskbor_(&lun, filename, &j, &istat);
  if (istat != 0)
    return -1;
  lflag = (1 == 1);
  if (filec_debug)
    printf("Reading header\n");
  dskbwr_(&lun, &lflag);
  readl = 2048;
  dskbr_(&lun, (char *)lumhead, &readl, &istat);
  if (filec_debug)
    printf("Read Completion status : %d\n", istat);
  if (istat != 0)
    goto close;
  if (strncmp(&lumhead[4], "lumi", 4))
    return -2;
  cbo = getbo();
  if (filec_debug) {
    if (cbo == 0)
      printf("This computer is little endian\n");
    else
      printf("This computer is big endian\n");
  }
  memcpy(lumsiz, (char *)&lumhead[806], 4);
  if (cbo == 1)
    swpbyt(0, 4, (char *)lumsiz);
  if (filec_debug) {
    is1 = *lumsiz;
    is2 = *(lumsiz + 1);
    printf("Image size %d x %d\n", is1, is2);
  }
  *lhead = 4096;
  *head = malloc(4096);
  memset(*head, 0, 4096);
  clrhd(*head);
  *naxis = 2;
  axis[0] = is1;
  axis[1] = is2;
  puthd("DIM", "2", *head);
  sprintf(s, "%d", is1);
  puthd("SIZE1", s, *head);
  sprintf(s, "%d", is2);
  puthd("SIZE2", s, *head);
  *type = 4;
  puthd("TYPE", "unsigned_short", *head);
  if (filec_debug)
    printf("Updated Header        : \n%s<END\n", *head);
  readl = is1 * is2 * sizeof(unsigned short);
  data = malloc(readl);
  *array = (char *)data;
  if (filec_debug)
    printf("Reading %d bytes\n", readl);
  dskbr_(&lun, (char *)data, &readl, &istat);
  if (cbo == 1) {
    if (filec_debug)
      printf("Swapping %d bytes\n", readl);
    swpbyt(0, readl, (char *)data);
  }
close:
  if (filec_debug)
    printf("Done reading Lumiscan image (size %d x %d) (istat %d)\n", is1, is2,
           istat);
  if (istat != 0)
    dskbcr_(&lun, &i);
  else
    dskbcr_(&lun, &istat);
  if (istat != 0) {
    if (*array != 0)
      free(*array);
    if (*head != 0)
      free(*head);
    return istat;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<rdlum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x910,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x1,-0x50(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x0,%al
call   1050 <filec_getdebug@plt>
mov    %eax,-0x904(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x904(%rbp)
je     129a <rdlum+0x8a>
mov    -0x10(%rbp),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdi
lea    -0x44(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1070 <dskbor_@plt>
cmpl   $0x0,-0x48(%rbp)
je     12c5 <rdlum+0xb5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1682 <rdlum+0x472>
movl   $0x1,-0x54(%rbp)
cmpl   $0x0,-0x904(%rbp)
je     12e7 <rdlum+0xd7>
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   10e0 <dskbwr_@plt>
movl   $0x800,-0x3c(%rbp)
lea    -0x860(%rbp),%rsi
lea    -0x50(%rbp),%rdi
lea    -0x3c(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1100 <dskbr_@plt>
cmpl   $0x0,-0x904(%rbp)
je     1331 <rdlum+0x121>
mov    -0x48(%rbp),%esi
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
cmpl   $0x0,-0x48(%rbp)
je     1340 <rdlum+0x130>
jmp    15e5 <rdlum+0x3d5>
lea    -0x860(%rbp),%rdi
add    $0x4,%rdi
lea    0xced(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1372 <rdlum+0x162>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1682 <rdlum+0x472>
mov    $0x0,%al
call   1110 <getbo@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x904(%rbp)
je     13b9 <rdlum+0x1a9>
cmpl   $0x0,-0x4c(%rbp)
jne    13a6 <rdlum+0x196>
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    13b4 <rdlum+0x1a4>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    13b9 <rdlum+0x1a9>
lea    -0x864(%rbp),%rdi
lea    -0x860(%rbp),%rsi
add    $0x326,%rsi
mov    $0x4,%edx
call   10d0 <memcpy@plt>
cmpl   $0x1,-0x4c(%rbp)
jne    13f5 <rdlum+0x1e5>
lea    -0x864(%rbp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   10b0 <swpbyt@plt>
cmpl   $0x0,-0x904(%rbp)
je     142a <rdlum+0x21a>
movzwl -0x864(%rbp),%eax
mov    %eax,-0x58(%rbp)
movzwl -0x862(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x1000,(%rax)
mov    $0x1000,%edi
call   10f0 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1130 <clrhd@plt>
mov    -0x30(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x58(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x5c(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xc03(%rip),%rdi
lea    0xc0d(%rip),%rsi
call   10a0 <puthd@plt>
lea    -0x900(%rbp),%rdi
mov    -0x58(%rbp),%edx
lea    0xbea(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x900(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xbd3(%rip),%rdi
call   10a0 <puthd@plt>
lea    -0x900(%rbp),%rdi
mov    -0x5c(%rbp),%edx
lea    0xbba(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x900(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xba9(%rip),%rdi
call   10a0 <puthd@plt>
mov    0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xb92(%rip),%rdi
lea    0xb90(%rip),%rsi
call   10a0 <puthd@plt>
cmpl   $0x0,-0x904(%rbp)
je     1544 <rdlum+0x334>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xb7f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x58(%rbp),%eax
imul   -0x5c(%rbp),%eax
cltq
shl    $0x1,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
call   10f0 <malloc@plt>
mov    %rax,-0x870(%rbp)
mov    -0x870(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x0,-0x904(%rbp)
je     158f <rdlum+0x37f>
mov    -0x3c(%rbp),%esi
lea    0xb55(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x870(%rbp),%rsi
lea    -0x50(%rbp),%rdi
lea    -0x3c(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1100 <dskbr_@plt>
cmpl   $0x1,-0x4c(%rbp)
jne    15e0 <rdlum+0x3d0>
cmpl   $0x0,-0x904(%rbp)
je     15cf <rdlum+0x3bf>
mov    -0x3c(%rbp),%esi
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    -0x870(%rbp),%rdx
xor    %edi,%edi
call   10b0 <swpbyt@plt>
jmp    15e5 <rdlum+0x3d5>
cmpl   $0x0,-0x904(%rbp)
je     1609 <rdlum+0x3f9>
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x48(%rbp),%ecx
lea    0xb00(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
cmpl   $0x0,-0x48(%rbp)
je     1625 <rdlum+0x415>
lea    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <dskbcr_@plt>
jmp    1632 <rdlum+0x422>
lea    -0x50(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1080 <dskbcr_@plt>
cmpl   $0x0,-0x48(%rbp)
je     167b <rdlum+0x46b>
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1656 <rdlum+0x446>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1670 <rdlum+0x460>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1682 <rdlum+0x472>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x910,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdlum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8c8,%rsp
mov    %r9,%rbx
mov    %r8,0x18(%rsp)
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
movl   $0x1,0x8(%rsp)
xor    %eax,%eax
call   1050 <filec_getdebug@plt>
mov    %eax,%ebp
movq   $0x0,(%r14)
movq   $0x0,(%r12)
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %eax,0x28(%rsp)
test   %ebp,%ebp
je     1286 <rdlum+0x66>
lea    0xd84(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0x8(%rsp),%rdi
lea    0x28(%rsp),%rdx
mov    %rsp,%rcx
mov    %r13,%rsi
call   1080 <dskbor_@plt>
mov    $0xffffffff,%eax
cmpl   $0x0,(%rsp)
jne    1435 <rdlum+0x215>
mov    %rbx,%r13
movl   $0x1,0x24(%rsp)
test   %ebp,%ebp
je     130a <rdlum+0xea>
lea    0xe67(%rip),%rdi
call   1060 <puts@plt>
lea    0x8(%rsp),%rbx
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   10f0 <dskbwr_@plt>
movl   $0x800,0x4(%rsp)
lea    0xc0(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
call   1110 <dskbr_@plt>
mov    (%rsp),%esi
lea    0xd11(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    133c <rdlum+0x11c>
lea    0x8(%rsp),%rbx
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   10f0 <dskbwr_@plt>
movl   $0x800,0x4(%rsp)
lea    0xc0(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
call   1110 <dskbr_@plt>
xor    %edx,%edx
cmpl   $0x0,(%rsp)
mov    $0x0,%esi
mov    %rsp,%rbx
je     13a5 <rdlum+0x185>
test   %ebp,%ebp
je     1361 <rdlum+0x141>
mov    (%rsp),%ecx
lea    0xd5b(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
cmpl   $0x0,(%rsp)
lea    0x2c(%rsp),%rsi
cmove  %rbx,%rsi
lea    0x8(%rsp),%rdi
call   1090 <dskbcr_@plt>
cmpl   $0x0,(%rsp)
je     1433 <rdlum+0x213>
mov    (%r14),%rdi
test   %rdi,%rdi
je     138f <rdlum+0x16f>
call   1030 <free@plt>
mov    (%r12),%rdi
test   %rdi,%rdi
je     139d <rdlum+0x17d>
call   1030 <free@plt>
mov    (%rsp),%eax
jmp    1435 <rdlum+0x215>
lea    0xc4(%rsp),%rdi
lea    0xc7b(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
mov    %rax,%rcx
mov    $0xfffffffe,%eax
test   %rcx,%rcx
jne    1435 <rdlum+0x215>
mov    %r13,%rbx
xor    %eax,%eax
call   1120 <getbo@plt>
mov    %eax,%r13d
test   %ebp,%ebp
je     13ed <rdlum+0x1cd>
test   %r13d,%r13d
je     1447 <rdlum+0x227>
lea    0xd04(%rip),%rdi
call   1060 <puts@plt>
lea    0x3e6(%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x4,%edx
call   10e0 <memcpy@plt>
cmp    $0x1,%r13d
sete   %al
mov    %eax,0x14(%rsp)
jne    1422 <rdlum+0x202>
lea    0x10(%rsp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   10c0 <swpbyt@plt>
test   %ebp,%ebp
jne    1472 <rdlum+0x252>
movl   $0x0,0xc(%rsp)
xor    %r13d,%r13d
jmp    1492 <rdlum+0x272>
xor    %eax,%eax
add    $0x8c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcba(%rip),%rdi
call   1060 <puts@plt>
lea    0x3e6(%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x4,%edx
call   10e0 <memcpy@plt>
movl   $0x0,0x14(%rsp)
movzwl 0x10(%rsp),%r13d
movzwl 0x12(%rsp),%edx
lea    0xbb0(%rip),%rdi
mov    %r13d,%esi
mov    %edx,0xc(%rsp)
xor    %eax,%eax
call   10a0 <printf@plt>
movl   $0x1000,(%r15)
mov    $0x1000,%edi
call   1100 <malloc@plt>
mov    %rax,(%r12)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10d0 <memset@plt>
mov    (%r12),%rdi
call   1140 <clrhd@plt>
mov    0x18(%rsp),%rax
movl   $0x2,(%rax)
mov    %r13d,(%rbx)
mov    0xc(%rsp),%r15d
mov    %r15d,0x4(%rbx)
mov    (%r12),%rdx
lea    0xb67(%rip),%rdi
lea    0xb71(%rip),%rsi
call   10b0 <puthd@plt>
lea    0xb58(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13d,0x18(%rsp)
mov    %r13d,%edx
call   1130 <sprintf@plt>
mov    (%r12),%rdx
lea    0xb3b(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <puthd@plt>
mov    %rbx,%rdi
lea    0xb26(%rip),%rsi
mov    %r15d,%edx
call   1130 <sprintf@plt>
mov    (%r12),%rdx
lea    0xb1c(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <puthd@plt>
mov    0x900(%rsp),%rax
movl   $0x4,(%rax)
mov    (%r12),%rdx
lea    0xb01(%rip),%rdi
lea    0xaff(%rip),%rsi
call   10b0 <puthd@plt>
test   %ebp,%ebp
je     157c <rdlum+0x35c>
mov    (%r12),%rsi
lea    0xafa(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0xc(%rsp),%ebx
imul   0x18(%rsp),%ebx
add    %ebx,%ebx
mov    %ebx,0x4(%rsp)
mov    %ebx,%edi
call   1100 <malloc@plt>
mov    %rax,%r15
mov    %rax,(%r14)
test   %ebp,%ebp
je     15df <rdlum+0x3bf>
lea    0xaed(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r15,%rsi
call   1110 <dskbr_@plt>
cmpb   $0x0,0x14(%rsp)
je     1625 <rdlum+0x405>
mov    0x4(%rsp),%esi
lea    0xacf(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %rsp,%rbx
jmp    1602 <rdlum+0x3e2>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r15,%rsi
call   1110 <dskbr_@plt>
cmpb   $0x0,0x14(%rsp)
mov    %rsp,%rbx
je     1361 <rdlum+0x141>
mov    0x4(%rsp),%esi
xor    %edi,%edi
mov    %r15,%rdx
call   10c0 <swpbyt@plt>
mov    0x18(%rsp),%esi
mov    0xc(%rsp),%edx
test   %ebp,%ebp
jne    1350 <rdlum+0x130>
jmp    1361 <rdlum+0x141>
mov    %rsp,%rbx
mov    0xc(%rsp),%edx
mov    0x18(%rsp),%esi
jmp    1350 <rdlum+0x130>

LLVM IR (-O0):
@.str = [18 x i8] c"Opening file: %s\0A\00"
@.str.1 = [16 x i8] c"Reading header\0A\00"
@.str.2 = [29 x i8] c"Read Completion status : %d\0A\00"
@.str.3 = [5 x i8] c"lumi\00"
@.str.4 = [32 x i8] c"This computer is little endian\0A\00"
@.str.5 = [29 x i8] c"This computer is big endian\0A\00"
@.str.6 = [20 x i8] c"Image size %d x %d\0A\00"
@.str.7 = [4 x i8] c"DIM\00"
@.str.8 = [2 x i8] c"2\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [6 x i8] c"SIZE1\00"
@.str.11 = [6 x i8] c"SIZE2\00"
@.str.12 = [5 x i8] c"TYPE\00"
@.str.13 = [15 x i8] c"unsigned_short\00"
@.str.14 = [33 x i8] c"Updated Header : \0A%s<END\0A\00"
@.str.15 = [18 x i8] c"Reading %d bytes\0A\00"
@.str.16 = [19 x i8] c"Swapping %d bytes\0A\00"
@.str.17 = [55 x i8] c"Done reading Lumiscan image (size %d x %d) (istat %d)\0A\00"
define i32 @rdlum(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca [2048 x i8]
%26 = alloca [2 x i16]
%27 = alloca i32*
%28 = alloca [132 x i8]
%29 = alloca i32
store i8* %0, i8** %9
store i8** %1, i8*** %10
store i32* %2, i32** %11
store i8** %3, i8*** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
store i32 1, i32* %21
store i32 0, i32* %23
store i32 0, i32* %24
%30 = call i32 (...) @filec_getdebug()
store i32 %30, i32* %29
%31 = load i8**, i8*** %12
store i8* null, i8** %31
%32 = load i8**, i8*** %10
store i8* null, i8** %32
%33 = load i8*, i8** %9
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %18
%35 = load i32, i32* %29
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %7
%38 = load i8*, i8** %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37, %7
%41 = load i8*, i8** %9
%42 = call i32 @dskbor_(i32* %21, i8* %41, i32* %18, i32* %19)
%43 = load i32, i32* %19
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
store i32 -1, i32* %8
br label %222
46: ; preds = %40
store i32 1, i32* %22
%47 = load i32, i32* %29
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
%52 = call i32 @dskbwr_(i32* %21, i32* %22)
store i32 2048, i32* %16
%53 = getelementptr inbounds [2048 x i8], [2048 x i8]* %25, i64 0, i64 0
%54 = call i32 @dskbr_(i32* %21, i8* %53, i32* %16, i32* %19)
%55 = load i32, i32* %29
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i32, i32* %19
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %57, %51
%61 = load i32, i32* %19
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %60
br label %185
64: ; preds = %60
%65 = getelementptr inbounds [2048 x i8], [2048 x i8]* %25, i64 0, i64 4
%66 = call i64 @strncmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64
store i32 -2, i32* %8
br label %222
69: ; preds = %64
%70 = call i32 (...) @getbo()
store i32 %70, i32* %20
%71 = load i32, i32* %29
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %81
73: ; preds = %69
%74 = load i32, i32* %20
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %80
78: ; preds = %73
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %78, %76
br label %81
81: ; preds = %80, %69
%82 = getelementptr inbounds [2 x i16], [2 x i16]* %26, i64 0, i64 0
%83 = getelementptr inbounds [2048 x i8], [2048 x i8]* %25, i64 0, i64 806
%84 = call i32 @memcpy(i16* %82, i8* %83, i32 4)
%85 = load i32, i32* %20
%86 = icmp eq i32 %85, 1
br i1 %86, label %87, label %91
87: ; preds = %81
%88 = getelementptr inbounds [2 x i16], [2 x i16]* %26, i64 0, i64 0
%89 = bitcast i16* %88 to i8*
%90 = call i32 @swpbyt(i32 0, i32 4, i8* %89)
br label %91
91: ; preds = %87, %81
%92 = load i32, i32* %29
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %105
94: ; preds = %91
%95 = getelementptr inbounds [2 x i16], [2 x i16]* %26, i64 0, i64 0
%96 = load i16, i16* %95
%97 = zext i16 %96 to i32
store i32 %97, i32* %23
%98 = getelementptr inbounds [2 x i16], [2 x i16]* %26, i64 0, i64 0
%99 = getelementptr inbounds i16, i16* %98, i64 1
%100 = load i16, i16* %99
%101 = zext i16 %100 to i32
store i32 %101, i32* %24
%102 = load i32, i32* %23
%103 = load i32, i32* %24
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %102, i32 %103)
br label %105
105: ; preds = %94, %91
%106 = load i32*, i32** %11
store i32 4096, i32* %106
%107 = call i8* @malloc(i32 4096)
%108 = load i8**, i8*** %10
store i8* %107, i8** %108
%109 = load i8**, i8*** %10
%110 = load i8*, i8** %109
%111 = call i32 @memset(i8* %110, i32 0, i32 4096)
%112 = load i8**, i8*** %10
%113 = load i8*, i8** %112
%114 = call i32 @clrhd(i8* %113)
%115 = load i32*, i32** %13
store i32 2, i32* %115
%116 = load i32, i32* %23
%117 = load i32*, i32** %14
%118 = getelementptr inbounds i32, i32* %117, i64 0
store i32 %116, i32* %118
%119 = load i32, i32* %24
%120 = load i32*, i32** %14
%121 = getelementptr inbounds i32, i32* %120, i64 1
store i32 %119, i32* %121
%122 = load i8**, i8*** %10
%123 = load i8*, i8** %122
%124 = call i32 @puthd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %123)
%125 = getelementptr inbounds [132 x i8], [132 x i8]* %28, i64 0, i64 0
%126 = load i32, i32* %23
%127 = call i32 @sprintf(i8* %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %126)
%128 = getelementptr inbounds [132 x i8], [132 x i8]* %28, i64 0, i64 0
%129 = load i8**, i8*** %10
%130 = load i8*, i8** %129
%131 = call i32 @puthd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %128, i8* %130)
%132 = getelementptr inbounds [132 x i8], [132 x i8]* %28, i64 0, i64 0
%133 = load i32, i32* %24
%134 = call i32 @sprintf(i8* %132, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %133)
%135 = getelementptr inbounds [132 x i8], [132 x i8]* %28, i64 0, i64 0
%136 = load i8**, i8*** %10
%137 = load i8*, i8** %136
%138 = call i32 @puthd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %135, i8* %137)
%139 = load i32*, i32** %15
store i32 4, i32* %139
%140 = load i8**, i8*** %10
%141 = load i8*, i8** %140
%142 = call i32 @puthd(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %141)
%143 = load i32, i32* %29
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %149
145: ; preds = %105
%146 = load i8**, i8*** %10
%147 = load i8*, i8** %146
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i8* %147)
br label %149
149: ; preds = %145, %105
%150 = load i32, i32* %23
%151 = load i32, i32* %24
%152 = mul nsw i32 %150, %151
%153 = sext i32 %152 to i64
%154 = mul i64 %153, 2
%155 = trunc i64 %154 to i32
store i32 %155, i32* %16
%156 = load i32, i32* %16
%157 = call i8* @malloc(i32 %156)
%158 = bitcast i8* %157 to i32*
store i32* %158, i32** %27
%159 = load i32*, i32** %27
%160 = bitcast i32* %159 to i8*
%161 = load i8**, i8*** %12
store i8* %160, i8** %161
%162 = load i32, i32* %29
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %149
%165 = load i32, i32* %16
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i32 %165)
br label %167
167: ; preds = %164, %149
%168 = load i32*, i32** %27
%169 = bitcast i32* %168 to i8*
%170 = call i32 @dskbr_(i32* %21, i8* %169, i32* %16, i32* %19)
%171 = load i32, i32* %20
%172 = icmp eq i32 %171, 1
br i1 %172, label %173, label %184
173: ; preds = %167
%174 = load i32, i32* %29
%175 = icmp ne i32 %174, 0
br i1 %175, label %176, label %179
176: ; preds = %173
%177 = load i32, i32* %16
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i32 %177)
br label %179
179: ; preds = %176, %173
%180 = load i32, i32* %16
%181 = load i32*, i32** %27
%182 = bitcast i32* %181 to i8*
%183 = call i32 @swpbyt(i32 0, i32 %180, i8* %182)
br label %184
184: ; preds = %179, %167
br label %185
185: ; preds = %184, %63
%186 = load i32, i32* %29
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %193
188: ; preds = %185
%189 = load i32, i32* %23
%190 = load i32, i32* %24
%191 = load i32, i32* %19
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.17, i64 0, i64 0), i32 %189, i32 %190, i32 %191)
br label %193
193: ; preds = %188, %185
%194 = load i32, i32* %19
%195 = icmp ne i32 %194, 0
br i1 %195, label %196, label %198
196: ; preds = %193
%197 = call i32 @dskbcr_(i32* %21, i32* %17)
br label %200
198: ; preds = %193
%199 = call i32 @dskbcr_(i32* %21, i32* %19)
br label %200
200: ; preds = %198, %196
%201 = load i32, i32* %19
%202 = icmp ne i32 %201, 0
br i1 %202, label %203, label %221
203: ; preds = %200
%204 = load i8**, i8*** %12
%205 = load i8*, i8** %204
%206 = icmp ne i8* %205, null
br i1 %206, label %207, label %211
207: ; preds = %203
%208 = load i8**, i8*** %12
%209 = load i8*, i8** %208
%210 = call i32 @free(i8* %209)
br label %211
211: ; preds = %207, %203
%212 = load i8**, i8*** %10
%213 = load i8*, i8** %212
%214 = icmp ne i8* %213, null
br i1 %214, label %215, label %219
215: ; preds = %211
%216 = load i8**, i8*** %10
%217 = load i8*, i8** %216
%218 = call i32 @free(i8* %217)
br label %219
219: ; preds = %215, %211
%220 = load i32, i32* %19
store i32 %220, i32* %8
br label %222
221: ; preds = %200
store i32 0, i32* %8
br label %222
222: ; preds = %221, %219, %68, %45
%223 = load i32, i32* %8
ret i32 %223
}

LLVM IR (-O2):
@.str = [18 x i8] c"Opening file: %s\0A\00"
@.str.2 = [29 x i8] c"Read Completion status : %d\0A\00"
@.str.3 = [5 x i8] c"lumi\00"
@.str.6 = [20 x i8] c"Image size %d x %d\0A\00"
@.str.7 = [4 x i8] c"DIM\00"
@.str.8 = [2 x i8] c"2\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [6 x i8] c"SIZE1\00"
@.str.11 = [6 x i8] c"SIZE2\00"
@.str.12 = [5 x i8] c"TYPE\00"
@.str.13 = [15 x i8] c"unsigned_short\00"
@.str.14 = [33 x i8] c"Updated Header : \0A%s<END\0A\00"
@.str.15 = [18 x i8] c"Reading %d bytes\0A\00"
@.str.16 = [19 x i8] c"Swapping %d bytes\0A\00"
@.str.17 = [55 x i8] c"Done reading Lumiscan image (size %d x %d) (istat %d)\0A\00"
@str = [28 x i8] c"This computer is big endian\00"
@str.18 = [31 x i8] c"This computer is little endian\00"
@str.19 = [15 x i8] c"Reading header\00"
define i32 @rdlum(i8* %0, i8** nocapture %1, i32* nocapture writeonly %2, i8** nocapture %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2048 x i8]
%15 = alloca [2 x i16]
%16 = alloca [132 x i8]
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
%20 = bitcast i32* %11 to i8*
%21 = bitcast i32* %12 to i8*
store i32 1, i32* %12
%22 = bitcast i32* %13 to i8*
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%24 = bitcast [2 x i16]* %15 to i8*
%25 = getelementptr inbounds [132 x i8], [132 x i8]* %16, i64 0, i64 0
%26 = tail call i32 (...) @filec_getdebug()
store i8* null, i8** %3
store i8* null, i8** %1
%27 = tail call i32 @strlen(i8* %0)
store i32 %27, i32* %10
%28 = icmp eq i32 %26, 0
br i1 %28, label %31, label %29
29: ; preds = %7
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %31
31: ; preds = %29, %7
%32 = call i32 @dskbor_(i32* %12, i8* %0, i32* %10, i32* %11)
%33 = load i32, i32* %11
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %144
35: ; preds = %31
store i32 1, i32* %13
br i1 %28, label %42, label %36
36: ; preds = %35
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0))
%38 = call i32 @dskbwr_(i32* %12, i32* %13)
store i32 2048, i32* %8
%39 = call i32 @dskbr_(i32* %12, i8* %23, i32* %8, i32* %11)
%40 = load i32, i32* %11
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %40)
br label %45
42: ; preds = %35
%43 = call i32 @dskbwr_(i32* %12, i32* %13)
store i32 2048, i32* %8
%44 = call i32 @dskbr_(i32* %12, i8* %23, i32* %8, i32* %11)
br label %45
45: ; preds = %42, %36
%46 = load i32, i32* %11
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %117
48: ; preds = %45
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 4
%50 = call i64 @strncmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %144
52: ; preds = %48
%53 = call i32 (...) @getbo()
br i1 %28, label %63, label %54
54: ; preds = %52
%55 = icmp eq i32 %53, 0
br i1 %55, label %56, label %61
56: ; preds = %54
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%58 = getelementptr inbounds [2 x i16], [2 x i16]* %15, i64 0, i64 0
%59 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 806
%60 = call i32 @memcpy(i16* %58, i8* %59, i32 4)
br label %71
61: ; preds = %54
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %63
63: ; preds = %61, %52
%64 = getelementptr inbounds [2 x i16], [2 x i16]* %15, i64 0, i64 0
%65 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 806
%66 = call i32 @memcpy(i16* %64, i8* %65, i32 4)
%67 = icmp eq i32 %53, 1
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 @swpbyt(i32 0, i32 4, i8* %24)
br label %70
70: ; preds = %68, %63
br i1 %28, label %80, label %71
71: ; preds = %56, %70
%72 = phi i1 [ false, %56 ], [ %67, %70 ]
%73 = getelementptr inbounds [2 x i16], [2 x i16]* %15, i64 0, i64 0
%74 = load i16, i16* %73
%75 = zext i16 %74 to i32
%76 = getelementptr inbounds [2 x i16], [2 x i16]* %15, i64 0, i64 1
%77 = load i16, i16* %76
%78 = zext i16 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %75, i32 %78)
br label %80
80: ; preds = %71, %70
%81 = phi i1 [ %72, %71 ], [ %67, %70 ]
%82 = phi i32 [ %78, %71 ], [ 0, %70 ]
%83 = phi i32 [ %75, %71 ], [ 0, %70 ]
store i32 4096, i32* %2
%84 = call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
store i8* %84, i8** %1
%85 = call i32 @memset(i8* %84, i32 0, i32 4096)
%86 = load i8*, i8** %1
%87 = call i32 @clrhd(i8* %86)
store i32 2, i32* %4
store i32 %83, i32* %5
%88 = getelementptr inbounds i32, i32* %5, i64 1
store i32 %82, i32* %88
%89 = load i8*, i8** %1
%90 = call i32 @puthd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %89)
%91 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %83)
%92 = load i8*, i8** %1
%93 = call i32 @puthd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %25, i8* %92)
%94 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %82)
%95 = load i8*, i8** %1
%96 = call i32 @puthd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %25, i8* %95)
store i32 4, i32* %6
%97 = load i8*, i8** %1
%98 = call i32 @puthd(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %97)
br i1 %28, label %102, label %99
99: ; preds = %80
%100 = load i8*, i8** %1
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %99, %80
%103 = shl nuw nsw i32 %82, 1
%104 = mul i32 %103, %83
store i32 %104, i32* %8
%105 = call i8* @malloc(i32 %104)
store i8* %105, i8** %3
br i1 %28, label %106, label %108
106: ; preds = %102
%107 = call i32 @dskbr_(i32* %12, i8* %105, i32* %8, i32* %11)
br i1 %81, label %114, label %125
108: ; preds = %102
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i32 %104)
%110 = call i32 @dskbr_(i32* %12, i8* %105, i32* %8, i32* %11)
br i1 %81, label %111, label %120
111: ; preds = %108
%112 = load i32, i32* %8
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %106, %111
%115 = load i32, i32* %8
%116 = call i32 @swpbyt(i32 0, i32 %115, i8* %105)
br label %117
117: ; preds = %114, %45
%118 = phi i32 [ 0, %45 ], [ %82, %114 ]
%119 = phi i32 [ 0, %45 ], [ %83, %114 ]
br i1 %28, label %125, label %120
120: ; preds = %108, %117
%121 = phi i32 [ %119, %117 ], [ %83, %108 ]
%122 = phi i32 [ %118, %117 ], [ %82, %108 ]
%123 = load i32, i32* %11
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.17, i64 0, i64 0), i32 %121, i32 %122, i32 %123)
br label %125
125: ; preds = %106, %120, %117
%126 = load i32, i32* %11
%127 = icmp eq i32 %126, 0
%128 = select i1 %127, i32* %11, i32* %9
%129 = call i32 @dskbcr_(i32* %12, i32* %128)
%130 = load i32, i32* %11
%131 = icmp eq i32 %130, 0
br i1 %131, label %144, label %132
132: ; preds = %125
%133 = load i8*, i8** %3
%134 = icmp eq i8* %133, null
br i1 %134, label %137, label %135
135: ; preds = %132
%136 = call i32 @free(i8* %133)
br label %137
137: ; preds = %135, %132
%138 = load i8*, i8** %1
%139 = icmp eq i8* %138, null
br i1 %139, label %142, label %140
140: ; preds = %137
%141 = call i32 @free(i8* %138)
br label %142
142: ; preds = %140, %137
%143 = load i32, i32* %11
br label %144
144: ; preds = %125, %48, %31, %142
%145 = phi i32 [ %143, %142 ], [ -1, %31 ], [ -2, %48 ], [ 0, %125 ]
ret i32 %145
}