#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 qfits_query(char const *, int);
int qfits_get_datinfo(const char *filename, int xtnum, int *seg_start,
                      int *seg_size) {
  if (filename == NULL || xtnum < 0 ||
      (seg_start == NULL && seg_size == NULL)) {
    return -1;
  }
  if (seg_start != NULL) {
    *seg_start = qfits_query(filename, (1 << 28) | xtnum);
    if (*seg_start < 0)
      return -1;
  }
  if (seg_size != NULL) {
    *seg_size = qfits_query(filename, (1 << 26) | xtnum);
    if (*seg_size < 0)
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<qfits_get_datinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1152 <qfits_get_datinfo+0x42>
cmpl   $0x0,-0x14(%rbp)
jl     1152 <qfits_get_datinfo+0x42>
cmpq   $0x0,-0x20(%rbp)
jne    115e <qfits_get_datinfo+0x4e>
cmpq   $0x0,-0x28(%rbp)
jne    115e <qfits_get_datinfo+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11eb <qfits_get_datinfo+0xdb>
cmpq   $0x0,-0x20(%rbp)
je     11a1 <qfits_get_datinfo+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x10000000,%esi
call   1030 <qfits_query@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jge    119c <qfits_get_datinfo+0x8c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11eb <qfits_get_datinfo+0xdb>
jmp    11a1 <qfits_get_datinfo+0x91>
cmpq   $0x0,-0x28(%rbp)
je     11e4 <qfits_get_datinfo+0xd4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x4000000,%esi
call   1030 <qfits_query@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jge    11df <qfits_get_datinfo+0xcf>
movl   $0xffffffff,-0x4(%rbp)
jmp    11eb <qfits_get_datinfo+0xdb>
jmp    11e4 <qfits_get_datinfo+0xd4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qfits_get_datinfo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     1179 <qfits_get_datinfo+0x69>
mov    %esi,%r12d
test   %esi,%esi
js     1179 <qfits_get_datinfo+0x69>
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rdx,%rax
or     %rcx,%rax
je     1179 <qfits_get_datinfo+0x69>
mov    %rdi,%rbx
test   %rbp,%rbp
je     1158 <qfits_get_datinfo+0x48>
mov    %r12d,%esi
or     $0x10000000,%esi
mov    %rbx,%rdi
call   1030 <qfits_query@plt>
mov    %eax,0x0(%rbp)
test   %eax,%eax
js     1179 <qfits_get_datinfo+0x69>
test   %r15,%r15
je     1176 <qfits_get_datinfo+0x66>
or     $0x4000000,%r12d
mov    %rbx,%rdi
mov    %r12d,%esi
call   1030 <qfits_query@plt>
mov    %eax,(%r15)
test   %eax,%eax
js     1179 <qfits_get_datinfo+0x69>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @qfits_get_datinfo(i8* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32*, i32** %8
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32*, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18, %12, %4
store i32 -1, i32* %5
br label %51
22: ; preds = %18, %15
%23 = load i32*, i32** %8
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = or i32 268435456, %27
%29 = call i32 @qfits_query(i8* %26, i32 %28)
%30 = load i32*, i32** %8
store i32 %29, i32* %30
%31 = load i32*, i32** %8
%32 = load i32, i32* %31
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %25
store i32 -1, i32* %5
br label %51
35: ; preds = %25
br label %36
36: ; preds = %35, %22
%37 = load i32*, i32** %9
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i8*, i8** %6
%41 = load i32, i32* %7
%42 = or i32 67108864, %41
%43 = call i32 @qfits_query(i8* %40, i32 %42)
%44 = load i32*, i32** %9
store i32 %43, i32* %44
%45 = load i32*, i32** %9
%46 = load i32, i32* %45
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %39
store i32 -1, i32* %5
br label %51
49: ; preds = %39
br label %50
50: ; preds = %49, %36
store i32 0, i32* %5
br label %51
51: ; preds = %50, %48, %34, %21
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
define i32 @qfits_get_datinfo(i8* %0, i32 %1, i32* writeonly %2, i32* writeonly %3) {
%5 = icmp eq i8* %0, null
%6 = icmp slt i32 %1, 0
%7 = or i1 %5, %6
br i1 %7, label %23, label %8
8: ; preds = %4
%9 = icmp eq i32* %2, null
%10 = icmp eq i32* %3, null
%11 = and i1 %9, %10
br i1 %11, label %23, label %12
12: ; preds = %8
br i1 %9, label %17, label %13
13: ; preds = %12
%14 = or i32 %1, 268435456
%15 = tail call i32 @qfits_query(i8* %0, i32 %14)
store i32 %15, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %13, %12
br i1 %10, label %22, label %18
18: ; preds = %17
%19 = or i32 %1, 67108864
%20 = tail call i32 @qfits_query(i8* %0, i32 %19)
store i32 %20, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18, %17
br label %23
23: ; preds = %18, %13, %4, %8, %22
%24 = phi i32 [ 0, %22 ], [ -1, %8 ], [ -1, %4 ], [ -1, %13 ], [ -1, %18 ]
ret i32 %24
}