#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 wcsprm {
  int dummy;
};

/* Variables and functions */
int cdfix(struct wcsprm *);
int celfix(struct wcsprm *);
int cylfix(int const *, struct wcsprm *);
int datfix(struct wcsprm *);
int spcfix(struct wcsprm *);
int unitfix(int, struct wcsprm *);
int wcsfix(int ctrl, const int naxis[], struct wcsprm *wcs, int stat[]) {
  int status = 0;
  if ((stat[1] = cdfix(wcs)) > 0) {
    status = 1;
  }
  if ((stat[0] = datfix(wcs)) > 0) {
    status = 1;
  }
  if ((stat[2] = unitfix(ctrl, wcs)) > 0) {
    status = 1;
  }
  if ((stat[3] = celfix(wcs)) > 0) {
    status = 1;
  }
  if ((stat[4] = spcfix(wcs)) > 0) {
    status = 1;
  }
  if (naxis) {
    if ((stat[5] = cylfix(naxis, wcs)) > 0) {
      status = 1;
    }
  } else {
    stat[5] = -2;
  }
  return status;
}


x86 assembly (clang, -O0):
<wcsfix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <cdfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,0x4(%rcx)
cmp    $0x0,%eax
jle    119e <wcsfix+0x3e>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <datfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
jle    11bd <wcsfix+0x5d>
movl   $0x1,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <unitfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,0x8(%rcx)
cmp    $0x0,%eax
jle    11e0 <wcsfix+0x80>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <celfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,0xc(%rcx)
cmp    $0x0,%eax
jle    1200 <wcsfix+0xa0>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <spcfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,0x10(%rcx)
cmp    $0x0,%eax
jle    1220 <wcsfix+0xc0>
movl   $0x1,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1254 <wcsfix+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <cylfix@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,0x14(%rcx)
cmp    $0x0,%eax
jle    124f <wcsfix+0xef>
movl   $0x1,-0x24(%rbp)
jmp    125f <wcsfix+0xff>
mov    -0x20(%rbp),%rax
movl   $0xfffffffe,0x14(%rax)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsfix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %edi,%ebp
mov    %rdx,%rdi
call   1040 <cdfix@plt>
mov    %eax,0x4(%r14)
test   %eax,%eax
setg   0x7(%rsp)
mov    %r12,%rdi
call   1030 <datfix@plt>
mov    %eax,(%r14)
test   %eax,%eax
setg   %r13b
mov    %ebp,%edi
mov    %r12,%rsi
call   1060 <unitfix@plt>
mov    %eax,0x8(%r14)
test   %eax,%eax
setg   %bl
mov    %r12,%rdi
call   1070 <celfix@plt>
mov    %eax,0xc(%r14)
test   %eax,%eax
setg   %bpl
mov    %r12,%rdi
call   1050 <spcfix@plt>
mov    %eax,0x10(%r14)
test   %eax,%eax
setg   %al
or     %bpl,%al
or     %r13b,%bl
or     %al,%bl
or     0x7(%rsp),%bl
movzbl %bl,%ebp
test   %r15,%r15
je     11fb <wcsfix+0x9b>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <cylfix@plt>
test   %eax,%eax
mov    $0x1,%ecx
cmovg  %ecx,%ebp
jmp    1200 <wcsfix+0xa0>
mov    $0xfffffffe,%eax
mov    %eax,0x14(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.wcsprm = type { i32 }
define i32 @wcsfix(i32 %0, i32* %1, %struct.wcsprm* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca %struct.wcsprm*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store %struct.wcsprm* %2, %struct.wcsprm** %7
store i32* %3, i32** %8
store i32 0, i32* %9
%10 = load %struct.wcsprm*, %struct.wcsprm** %7
%11 = call i32 @cdfix(%struct.wcsprm* %10)
%12 = load i32*, i32** %8
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %11, i32* %13
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 1, i32* %9
br label %16
16: ; preds = %15, %4
%17 = load %struct.wcsprm*, %struct.wcsprm** %7
%18 = call i32 @datfix(%struct.wcsprm* %17)
%19 = load i32*, i32** %8
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %18, i32* %20
%21 = icmp sgt i32 %18, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 1, i32* %9
br label %23
23: ; preds = %22, %16
%24 = load i32, i32* %5
%25 = load %struct.wcsprm*, %struct.wcsprm** %7
%26 = call i32 @unitfix(i32 %24, %struct.wcsprm* %25)
%27 = load i32*, i32** %8
%28 = getelementptr inbounds i32, i32* %27, i64 2
store i32 %26, i32* %28
%29 = icmp sgt i32 %26, 0
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 1, i32* %9
br label %31
31: ; preds = %30, %23
%32 = load %struct.wcsprm*, %struct.wcsprm** %7
%33 = call i32 @celfix(%struct.wcsprm* %32)
%34 = load i32*, i32** %8
%35 = getelementptr inbounds i32, i32* %34, i64 3
store i32 %33, i32* %35
%36 = icmp sgt i32 %33, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %9
br label %38
38: ; preds = %37, %31
%39 = load %struct.wcsprm*, %struct.wcsprm** %7
%40 = call i32 @spcfix(%struct.wcsprm* %39)
%41 = load i32*, i32** %8
%42 = getelementptr inbounds i32, i32* %41, i64 4
store i32 %40, i32* %42
%43 = icmp sgt i32 %40, 0
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 1, i32* %9
br label %45
45: ; preds = %44, %38
%46 = load i32*, i32** %6
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %57
48: ; preds = %45
%49 = load i32*, i32** %6
%50 = load %struct.wcsprm*, %struct.wcsprm** %7
%51 = call i32 @cylfix(i32* %49, %struct.wcsprm* %50)
%52 = load i32*, i32** %8
%53 = getelementptr inbounds i32, i32* %52, i64 5
store i32 %51, i32* %53
%54 = icmp sgt i32 %51, 0
br i1 %54, label %55, label %56
55: ; preds = %48
store i32 1, i32* %9
br label %56
56: ; preds = %55, %48
br label %60
57: ; preds = %45
%58 = load i32*, i32** %8
%59 = getelementptr inbounds i32, i32* %58, i64 5
store i32 -2, i32* %59
br label %60
60: ; preds = %57, %56
%61 = load i32, i32* %9
ret i32 %61
}

LLVM IR (-O2):
%struct.wcsprm = type { i32 }
define i32 @wcsfix(i32 %0, i32* %1, %struct.wcsprm* %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @cdfix(%struct.wcsprm* %2)
%6 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %5, i32* %6
%7 = icmp sgt i32 %5, 0
%8 = tail call i32 @datfix(%struct.wcsprm* %2)
store i32 %8, i32* %3
%9 = icmp sgt i32 %8, 0
%10 = tail call i32 @unitfix(i32 %0, %struct.wcsprm* %2)
%11 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %10, i32* %11
%12 = icmp sgt i32 %10, 0
%13 = tail call i32 @celfix(%struct.wcsprm* %2)
%14 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %13, i32* %14
%15 = icmp sgt i32 %13, 0
%16 = tail call i32 @spcfix(%struct.wcsprm* %2)
%17 = getelementptr inbounds i32, i32* %3, i64 4
store i32 %16, i32* %17
%18 = icmp sgt i32 %16, 0
%19 = select i1 %18, i1 true, i1 %15
%20 = select i1 %19, i1 true, i1 %12
%21 = select i1 %20, i1 true, i1 %9
%22 = select i1 %21, i1 true, i1 %7
%23 = zext i1 %22 to i32
%24 = icmp eq i32* %1, null
br i1 %24, label %29, label %25
25: ; preds = %4
%26 = tail call i32 @cylfix(i32* %1, %struct.wcsprm* %2)
%27 = icmp slt i32 %26, 1
%28 = select i1 %27, i32 %23, i32 1
br label %29
29: ; preds = %4, %25
%30 = phi i32 [ %26, %25 ], [ -2, %4 ]
%31 = phi i32 [ %28, %25 ], [ %23, %4 ]
%32 = getelementptr inbounds i32, i32* %3, i64 5
store i32 %30, i32* %32
ret i32 %31
}