#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 *cp, 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;
  }
  ctypeS2[8] = '\0';
  for (cp = ctypeS2; *cp; cp++)
    ;
  while (cp < ctypeS2 + 8)
    *(cp++) = ' ';
  if (strncmp(ctypeS2 + 5, "???", 3) == 0) {
    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, &ptype2, &xtype2,
                       &restreq, crvalS2, &dS2dX))) {
    return status;
  }
  if (xtype2 != xtype1) {
    return 2;
  }
  if (ctypeS2[7] == '?') {
    if (ptype2 == xtype2) {
      strcpy(ctypeS2 + 4, "    ");
    } else {
      ctypeS2[7] = ptype2;
    }
  }
  *cdeltS2 = dS2dX * dXdS1 * cdeltS1;
  return 0;
}


x86 assembly (clang, -O0):
<spctrn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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    -0x51(%rbp),%rsi
lea    -0x53(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x68(%rbp),%r8
lea    -0x78(%rbp),%r9
call   1060 <spcspx@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0x0,%eax
je     11b2 <spctrn+0x72>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1367 <spctrn+0x227>
mov    -0x38(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e5 <spctrn+0xa5>
jmp    11d4 <spctrn+0x94>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11c2 <spctrn+0x82>
jmp    11ea <spctrn+0xaa>
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    1216 <spctrn+0xd6>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x20,(%rax)
jmp    11ea <spctrn+0xaa>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xddb(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12a1 <spctrn+0x161>
movsbl -0x53(%rbp),%eax
cmp    $0x77,%eax
jne    125f <spctrn+0x11f>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xdaf(%rip),%rsi
call   1040 <strcpy@plt>
jmp    129c <spctrn+0x15c>
movsbl -0x53(%rbp),%eax
cmp    $0x61,%eax
jne    1285 <spctrn+0x145>
mov    -0x38(%rbp),%rdi
add    $0x5,%rdi
lea    0xd8d(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1297 <spctrn+0x157>
mov    -0x53(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x38(%rbp),%rax
movb   $0x32,0x6(%rax)
jmp    129c <spctrn+0x15c>
jmp    12a1 <spctrn+0x161>
mov    -0x38(%rbp),%rdi
movsd  -0x68(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mov    -0x40(%rbp),%r8
lea    -0x52(%rbp),%rsi
lea    -0x54(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x70(%rbp),%r9
call   1050 <spcxps@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0x0,%eax
je     12e4 <spctrn+0x1a4>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1367 <spctrn+0x227>
movsbl -0x54(%rbp),%eax
movsbl -0x53(%rbp),%ecx
cmp    %ecx,%eax
je     1300 <spctrn+0x1c0>
movl   $0x2,-0x4(%rbp)
jmp    1367 <spctrn+0x227>
mov    -0x38(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x3f,%eax
jne    1349 <spctrn+0x209>
movsbl -0x52(%rbp),%eax
movsbl -0x54(%rbp),%ecx
cmp    %ecx,%eax
jne    133a <spctrn+0x1fa>
mov    -0x38(%rbp),%rdi
add    $0x4,%rdi
lea    0xcdc(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1344 <spctrn+0x204>
mov    -0x52(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x7(%rax)
jmp    1349 <spctrn+0x209>
movsd  -0x70(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%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   1070 <spcspx@plt>
test   %eax,%eax
jne    12b2 <spctrn+0x162>
movb   $0x0,0x8(%rbx)
mov    $0xfffffffffffffff7,%rdx
nopl   (%rax)
cmpb   $0x0,0x9(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    11b0 <spctrn+0x60>
mov    %rdx,%rax
add    $0x8,%rax
jae    11d9 <spctrn+0x89>
lea    (%rbx,%rdx,1),%rdi
add    $0x8,%rdi
neg    %rdx
mov    $0x20,%esi
call   1060 <memset@plt>
lea    0x5(%rbx),%r12
lea    0xe1c(%rip),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
jne    123b <spctrn+0xeb>
mov    0xc(%rsp),%al
cmp    $0x61,%al
je     1217 <spctrn+0xc7>
cmp    $0x77,%al
jne    1234 <spctrn+0xe4>
lea    0xdef(%rip),%rsi
jmp    121e <spctrn+0xce>
lea    0xdea(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcpy@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
jmp    123b <spctrn+0xeb>
mov    %al,0x5(%rbx)
movb   $0x32,0x6(%rbx)
movsd  0x40(%rsp),%xmm0
lea    0xe(%rsp),%rsi
lea    0xd(%rsp),%rdx
lea    0x24(%rsp),%rcx
lea    0x38(%rsp),%r9
mov    %rbx,%rdi
mov    %r15,%r8
call   1050 <spcxps@plt>
test   %eax,%eax
jne    12b2 <spctrn+0x162>
mov    0xd(%rsp),%cl
mov    $0x2,%eax
cmp    0xc(%rsp),%cl
jne    12b2 <spctrn+0x162>
cmpb   $0x3f,0x7(%rbx)
jne    1299 <spctrn+0x149>
mov    0xe(%rsp),%al
cmp    %cl,%al
jne    1296 <spctrn+0x146>
add    $0x4,%rbx
lea    0xd80(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
jmp    1299 <spctrn+0x149>
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 i8
%23 = alloca i32
%24 = alloca i32
%25 = alloca double
%26 = alloca double
%27 = 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
%28 = load i8*, i8** %10
%29 = load double, double* %11
%30 = load double, double* %13
%31 = load double, double* %14
%32 = call i32 @spcspx(i8* %28, double %29, double %30, double %31, i8* %19, i8* %21, i32* %23, double* %25, double* %27)
store i32 %32, i32* %24
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %8
%35 = load i32, i32* %24
store i32 %35, i32* %9
br label %131
36: ; preds = %8
%37 = load i8*, i8** %15
%38 = getelementptr inbounds i8, i8* %37, i64 8
store i8 0, i8* %38
%39 = load i8*, i8** %15
store i8* %39, i8** %18
br label %40
40: ; preds = %45, %36
%41 = load i8*, i8** %18
%42 = load i8, i8* %41
%43 = icmp ne i8 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
br label %45
45: ; preds = %44
%46 = load i8*, i8** %18
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %18
br label %40
48: ; preds = %40
br label %49
49: ; preds = %54, %48
%50 = load i8*, i8** %18
%51 = load i8*, i8** %15
%52 = getelementptr inbounds i8, i8* %51, i64 8
%53 = icmp ult i8* %50, %52
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i8*, i8** %18
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %18
store i8 32, i8* %55
br label %49
57: ; preds = %49
%58 = load i8*, i8** %15
%59 = getelementptr inbounds i8, i8* %58, i64 5
%60 = call i64 @strncmp(i8* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %86
62: ; preds = %57
%63 = load i8, i8* %21
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 119
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i8*, i8** %15
%68 = getelementptr inbounds i8, i8* %67, i64 5
%69 = call i32 @strcpy(i8* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %85
70: ; preds = %62
%71 = load i8, i8* %21
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 97
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i8*, i8** %15
%76 = getelementptr inbounds i8, i8* %75, i64 5
%77 = call i32 @strcpy(i8* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %84
78: ; preds = %70
%79 = load i8, i8* %21
%80 = load i8*, i8** %15
%81 = getelementptr inbounds i8, i8* %80, i64 5
store i8 %79, i8* %81
%82 = load i8*, i8** %15
%83 = getelementptr inbounds i8, i8* %82, i64 6
store i8 50, i8* %83
br label %84
84: ; preds = %78, %74
br label %85
85: ; preds = %84, %66
br label %86
86: ; preds = %85, %57
%87 = load i8*, i8** %15
%88 = load double, double* %25
%89 = load double, double* %13
%90 = load double, double* %14
%91 = load double*, double** %16
%92 = call i32 @spcxps(i8* %87, double %88, double %89, double %90, i8* %20, i8* %22, i32* %23, double* %91, double* %26)
store i32 %92, i32* %24
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %86
%95 = load i32, i32* %24
store i32 %95, i32* %9
br label %131
96: ; preds = %86
%97 = load i8, i8* %22
%98 = sext i8 %97 to i32
%99 = load i8, i8* %21
%100 = sext i8 %99 to i32
%101 = icmp ne i32 %98, %100
br i1 %101, label %102, label %103
102: ; preds = %96
store i32 2, i32* %9
br label %131
103: ; preds = %96
%104 = load i8*, i8** %15
%105 = getelementptr inbounds i8, i8* %104, i64 7
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = icmp eq i32 %107, 63
br i1 %108, label %109, label %124
109: ; preds = %103
%110 = load i8, i8* %20
%111 = sext i8 %110 to i32
%112 = load i8, i8* %22
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %111, %113
br i1 %114, label %115, label %119
115: ; preds = %109
%116 = load i8*, i8** %15
%117 = getelementptr inbounds i8, i8* %116, i64 4
%118 = call i32 @strcpy(i8* %117, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %123
119: ; preds = %109
%120 = load i8, i8* %20
%121 = load i8*, i8** %15
%122 = getelementptr inbounds i8, i8* %121, i64 7
store i8 %120, i8* %122
br label %123
123: ; preds = %119, %115
br label %124
124: ; preds = %123, %103
%125 = load double, double* %26
%126 = load double, double* %27
%127 = fmul double %125, %126
%128 = load double, double* %12
%129 = fmul double %127, %128
%130 = load double*, double** %17
store double %129, double* %130
store i32 0, i32* %9
br label %131
131: ; preds = %124, %102, %94, %34
%132 = load i32, i32* %9
ret i32 %132
}

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 %72
23: ; preds = %8
%24 = getelementptr inbounds i8, i8* %5, i64 8
store i8 0, i8* %24
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %30, %25 ]
%27 = getelementptr i8, i8* %5, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
%30 = add nuw nsw i64 %26, 1
br i1 %29, label %31, label %25
31: ; preds = %25
%32 = icmp ult i64 %26, 8
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = getelementptr i8, i8* %5, i64 %26
%35 = sub nuw nsw i64 8, %26
br label %36
36: ; preds = %33, %31
%37 = getelementptr inbounds i8, i8* %5, 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 eq i64 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = load i8, i8* %11
switch i8 %41, label %46 [
i8 119, label %42
i8 97, label %44
]
42: ; preds = %40
%43 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %48
44: ; preds = %40
%45 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %48
46: ; preds = %40
store i8 %41, i8* %37
%47 = getelementptr inbounds i8, i8* %5, i64 6
store i8 50, i8* %47
br label %48
48: ; preds = %42, %46, %44, %36
%49 = load double, double* %14
%50 = call i32 @spcxps(i8* %5, double %49, double %3, double %4, i8* %10, i8* %12, i32* %13, double* %6, double* %15)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %72
52: ; preds = %48
%53 = load i8, i8* %12
%54 = load i8, i8* %11
%55 = icmp eq i8 %53, %54
br i1 %55, label %56, label %72
56: ; preds = %52
%57 = getelementptr inbounds i8, i8* %5, i64 7
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 63
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load i8, i8* %10
%62 = icmp eq i8 %61, %53
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = getelementptr inbounds i8, i8* %5, i64 4
%65 = call i32 @strcpy(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %67
66: ; preds = %60
store i8 %61, i8* %57
br label %67
67: ; preds = %63, %66, %56
%68 = load double, double* %15
%69 = load double, double* %16
%70 = fmul double %68, %69
%71 = fmul double %70, %2
store double %71, double* %7
br label %72
72: ; preds = %52, %48, %8, %67
%73 = phi i32 [ 0, %67 ], [ %21, %8 ], [ %50, %48 ], [ 2, %52 ]
ret i32 %73
}