#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 spcspx(char const *, double, double, double, char *, char *, int *,
           double *, double *);
int spcxps(char *, double, double, double, char *, char *, int *, double *,
           double *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int spctrn(const char ctypeS1[9], double crvalS1, double cdeltS1,
           double restfrq, double restwav, char ctypeS2[9], double *crvalS2,
           double *cdeltS2) {
  char ptype1, ptype2, xtype1, xtype2;
  int restreq, status;
  double crvalX, dS2dX, dXdS1;
  if (status = spcspx(ctypeS1, crvalS1, restfrq, restwav, &ptype1, &xtype1,
                      &restreq, &crvalX, &dXdS1)) {
    return status;
  }
  if (strncmp(ctypeS2 + 5, "???", 3)) {
    if (xtype1 == 'w') {
      strcpy(ctypeS2 + 5, "GRI");
    } else if (xtype1 == 'a') {
      strcpy(ctypeS2 + 5, "GRA");
    } else {
      ctypeS2[5] = xtype1;
      ctypeS2[6] = '2';
    }
  }
  if (status = spcxps(ctypeS2, crvalX, restfrq, restwav, &xtype2, &ptype2,
                      &restreq, crvalS2, &dS2dX)) {
    return status;
  }
  if (xtype2 != xtype1) {
    return 2;
  }
  if (ctypeS2[7] = '?') {
    if (ptype2 == xtype2) {
      strcpy(ctypeS2 + 5, "    ");
    } else {
      ctypeS2[7] = ptype2;
    }
  }
  *cdeltS2 = dS2dX * dXdS1 * cdeltS1;
  return 0;
}


x86 assembly (clang, -O0):
<spctrn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
lea    -0x49(%rbp),%rsi
lea    -0x4b(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x60(%rbp),%r8
lea    -0x70(%rbp),%r9
call   1060 <spcspx@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     11af <spctrn+0x6f>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1306 <spctrn+0x1c6>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xe42(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     123a <spctrn+0xfa>
movsbl -0x4b(%rbp),%eax
cmp    $0x77,%eax
jne    11f8 <spctrn+0xb8>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xe16(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1235 <spctrn+0xf5>
movsbl -0x4b(%rbp),%eax
cmp    $0x61,%eax
jne    121e <spctrn+0xde>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xdf4(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1230 <spctrn+0xf0>
mov    -0x4b(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x38(%rbp),%rax
movb   $0x32,0x6(%rax)
jmp    1235 <spctrn+0xf5>
jmp    123a <spctrn+0xfa>
mov    -0x38(%rbp),%rdi
movsd  -0x60(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mov    -0x40(%rbp),%r8
lea    -0x4c(%rbp),%rsi
lea    -0x4a(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x68(%rbp),%r9
call   1050 <spcxps@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     127d <spctrn+0x13d>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1306 <spctrn+0x1c6>
movsbl -0x4c(%rbp),%eax
movsbl -0x4b(%rbp),%ecx
cmp    %ecx,%eax
je     1299 <spctrn+0x159>
movl   $0x2,-0x4(%rbp)
jmp    1306 <spctrn+0x1c6>
mov    -0x38(%rbp),%rax
movb   $0x3f,0x7(%rax)
mov    $0x1,%al
test   $0x1,%al
jne    12b0 <spctrn+0x170>
jmp    12e8 <spctrn+0x1a8>
movsbl -0x4a(%rbp),%eax
movsbl -0x4c(%rbp),%ecx
cmp    %ecx,%eax
jne    12d9 <spctrn+0x199>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xd3d(%rip),%rsi
call   1040 <strcpy@plt>
jmp    12e3 <spctrn+0x1a3>
mov    -0x4a(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x7(%rax)
jmp    12e8 <spctrn+0x1a8>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spctrn>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
movsd  %xmm1,0x28(%rsp)
lea    0xf(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x24(%rsp),%rcx
lea    0x40(%rsp),%r8
lea    0x30(%rsp),%r9
movsd  %xmm2,0x10(%rsp)
movaps %xmm2,%xmm1
movsd  %xmm3,0x18(%rsp)
movaps %xmm3,%xmm2
call   1060 <spcspx@plt>
test   %eax,%eax
jne    1265 <spctrn+0x125>
lea    0x5(%rbx),%r12
lea    0xe63(%rip),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
je     11f4 <spctrn+0xb4>
mov    0xc(%rsp),%al
cmp    $0x61,%al
je     11d0 <spctrn+0x90>
cmp    $0x77,%al
jne    11ed <spctrn+0xad>
lea    0xe36(%rip),%rsi
jmp    11d7 <spctrn+0x97>
lea    0xe31(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcpy@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
jmp    11f4 <spctrn+0xb4>
mov    %al,0x5(%rbx)
movb   $0x32,0x6(%rbx)
movsd  0x40(%rsp),%xmm0
lea    0xd(%rsp),%rsi
lea    0xe(%rsp),%rdx
lea    0x24(%rsp),%rcx
lea    0x38(%rsp),%r9
mov    %rbx,%rdi
mov    %r15,%r8
call   1050 <spcxps@plt>
test   %eax,%eax
jne    1265 <spctrn+0x125>
mov    0xd(%rsp),%cl
mov    $0x2,%eax
cmp    0xc(%rsp),%cl
jne    1265 <spctrn+0x125>
movb   $0x3f,0x7(%rbx)
mov    0xe(%rsp),%al
cmp    %cl,%al
jne    1249 <spctrn+0x109>
lea    0xdcd(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcpy@plt>
jmp    124c <spctrn+0x10c>
mov    %al,0x7(%rbx)
movsd  0x38(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"???\00"
@.str.1 = [4 x i8] c"GRI\00"
@.str.2 = [4 x i8] c"GRA\00"
@.str.3 = [5 x i8] c" \00"
define i32 @spctrn(i8* %0, double %1, double %2, double %3, double %4, i8* %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i8*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i8
%19 = alloca i8
%20 = alloca i8
%21 = alloca i8
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double
store i8* %0, i8** %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store i8* %5, i8** %15
store double* %6, double** %16
store double* %7, double** %17
%27 = load i8*, i8** %10
%28 = load double, double* %11
%29 = load double, double* %13
%30 = load double, double* %14
%31 = call i32 @spcspx(i8* %27, double %28, double %29, double %30, i8* %18, i8* %20, i32* %22, double* %24, double* %26)
store i32 %31, i32* %23
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %8
%34 = load i32, i32* %23
store i32 %34, i32* %9
br label %106
35: ; preds = %8
%36 = load i8*, i8** %15
%37 = getelementptr inbounds i8, i8* %36, i64 5
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %64
40: ; preds = %35
%41 = load i8, i8* %20
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 119
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8*, i8** %15
%46 = getelementptr inbounds i8, i8* %45, i64 5
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %63
48: ; preds = %40
%49 = load i8, i8* %20
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 97
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i8*, i8** %15
%54 = getelementptr inbounds i8, i8* %53, i64 5
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %62
56: ; preds = %48
%57 = load i8, i8* %20
%58 = load i8*, i8** %15
%59 = getelementptr inbounds i8, i8* %58, i64 5
store i8 %57, i8* %59
%60 = load i8*, i8** %15
%61 = getelementptr inbounds i8, i8* %60, i64 6
store i8 50, i8* %61
br label %62
62: ; preds = %56, %52
br label %63
63: ; preds = %62, %44
br label %64
64: ; preds = %63, %35
%65 = load i8*, i8** %15
%66 = load double, double* %24
%67 = load double, double* %13
%68 = load double, double* %14
%69 = load double*, double** %16
%70 = call i32 @spcxps(i8* %65, double %66, double %67, double %68, i8* %21, i8* %19, i32* %22, double* %69, double* %25)
store i32 %70, i32* %23
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %64
%73 = load i32, i32* %23
store i32 %73, i32* %9
br label %106
74: ; preds = %64
%75 = load i8, i8* %21
%76 = sext i8 %75 to i32
%77 = load i8, i8* %20
%78 = sext i8 %77 to i32
%79 = icmp ne i32 %76, %78
br i1 %79, label %80, label %81
80: ; preds = %74
store i32 2, i32* %9
br label %106
81: ; preds = %74
%82 = load i8*, i8** %15
%83 = getelementptr inbounds i8, i8* %82, i64 7
store i8 63, i8* %83
br i1 true, label %84, label %99
84: ; preds = %81
%85 = load i8, i8* %19
%86 = sext i8 %85 to i32
%87 = load i8, i8* %21
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %86, %88
br i1 %89, label %90, label %94
90: ; preds = %84
%91 = load i8*, i8** %15
%92 = getelementptr inbounds i8, i8* %91, i64 5
%93 = call i32 @strcpy(i8* %92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %98
94: ; preds = %84
%95 = load i8, i8* %19
%96 = load i8*, i8** %15
%97 = getelementptr inbounds i8, i8* %96, i64 7
store i8 %95, i8* %97
br label %98
98: ; preds = %94, %90
br label %99
99: ; preds = %98, %81
%100 = load double, double* %25
%101 = load double, double* %26
%102 = fmul double %100, %101
%103 = load double, double* %12
%104 = fmul double %102, %103
%105 = load double*, double** %17
store double %104, double* %105
store i32 0, i32* %9
br label %106
106: ; preds = %99, %80, %72, %33
%107 = load i32, i32* %9
ret i32 %107
}

LLVM IR (-O2):
@.str = [4 x i8] c"???\00"
@.str.1 = [4 x i8] c"GRI\00"
@.str.2 = [4 x i8] c"GRA\00"
@.str.3 = [5 x i8] c" \00"
define i32 @spctrn(i8* %0, double %1, double %2, double %3, double %4, i8* %5, double* %6, double* nocapture writeonly %7) {
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = bitcast i32* %13 to i8*
%18 = bitcast double* %14 to i8*
%19 = bitcast double* %15 to i8*
%20 = bitcast double* %16 to i8*
%21 = call i32 @spcspx(i8* %0, double %1, double %3, double %4, i8* %9, i8* %11, i32* %13, double* %14, double* %16)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %55
23: ; preds = %8
%24 = getelementptr inbounds i8, i8* %5, i64 5
%25 = call i64 @strncmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %23
%28 = load i8, i8* %11
switch i8 %28, label %33 [
i8 119, label %29
i8 97, label %31
]
29: ; preds = %27
%30 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %35
31: ; preds = %27
%32 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %35
33: ; preds = %27
store i8 %28, i8* %24
%34 = getelementptr inbounds i8, i8* %5, i64 6
store i8 50, i8* %34
br label %35
35: ; preds = %29, %33, %31, %23
%36 = load double, double* %14
%37 = call i32 @spcxps(i8* %5, double %36, double %3, double %4, i8* %12, i8* %10, i32* %13, double* %6, double* %15)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load i8, i8* %12
%41 = load i8, i8* %11
%42 = icmp eq i8 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %5, i64 7
store i8 63, i8* %44
%45 = load i8, i8* %10
%46 = icmp eq i8 %45, %40
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %50
49: ; preds = %43
store i8 %45, i8* %44
br label %50
50: ; preds = %47, %49
%51 = load double, double* %15
%52 = load double, double* %16
%53 = fmul double %51, %52
%54 = fmul double %53, %2
store double %54, double* %7
br label %55
55: ; preds = %39, %35, %8, %50
%56 = phi i32 [ 0, %50 ], [ %21, %8 ], [ %37, %35 ], [ 2, %39 ]
ret i32 %56
}