#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*/ axes_earth(unsigned char **, double *, double *);
unsigned char *code_table_3_2_location(unsigned char **);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
int f_radius(int mode, unsigned char **sec, float *data, unsigned int ndata,
             char *inv_out, void **local) {
  int table_3_2;
  unsigned char *p;
  double radius, major, minor;
  if (mode >= 0) {
    if ((p = code_table_3_2_location(sec)) == NULL) {
      sprintf(inv_out, "earth radius is not available");
      return 0;
    }
    table_3_2 = (int)*p;
    sprintf(inv_out, "code3.2=%d ", table_3_2);
    inv_out += strlen(inv_out);
    axes_earth(sec, &major, &minor);
    radius = (major + minor) * 0.5;
    switch (table_3_2) {
    case 0:
    case 6:
    case 8:
      sprintf(inv_out, "sphere predefined radius=%.1lf m", major);
      break;
    case 1:
      sprintf(inv_out, "sphere user defined radius=%.1lf m", major);
      break;
    case 2:
      sprintf(
          inv_out,
          "IAU 1965 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m",
          radius, major, minor);
      break;
    case 4:
      sprintf(
          inv_out,
          "IAG-GRS80 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m",
          radius, major, minor);
      break;
    case 5:
      sprintf(inv_out,
              "WGS84 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m",
              radius, major, minor);
      break;
    case 9:
      sprintf(inv_out,
              "OSGB-1936 Airy 1830 ave radius=%.1lf m major axis=%.1lf m minor "
              "axis=%.1lf m",
              radius, major, minor);
      break;
    case 3:
    case 7:
      sprintf(inv_out,
              "oblate spheroid user defined ave radius=%.1lf m major "
              "axis=%.1lf m minor axis=%.1lf m",
              radius, major, minor);
      break;
    default:
      sprintf(inv_out, "unknown size/shape of earth");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_radius>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1337 <f_radius+0x1f7>
mov    -0x10(%rbp),%rdi
call   1030 <code_table_3_2_location@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    119d <f_radius+0x5d>
mov    -0x28(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    133e <f_radius+0x1fe>
mov    -0x40(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe99(%rip),%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1050 <axes_earth@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe04(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x9,%rax
ja     1320 <f_radius+0x1e0>
mov    -0x60(%rbp),%rax
lea    0xde7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rdi
movsd  -0x50(%rbp),%xmm0
lea    0xe20(%rip),%rsi
mov    $0x1,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x50(%rbp),%xmm0
lea    0xe25(%rip),%rsi
mov    $0x1,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe22(%rip),%rsi
mov    $0x3,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe3e(%rip),%rsi
mov    $0x3,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe5b(%rip),%rsi
mov    $0x3,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe74(%rip),%rsi
mov    $0x3,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe9b(%rip),%rsi
mov    $0x3,%al
call   1060 <sprintf@plt>
jmp    1332 <f_radius+0x1f2>
mov    -0x28(%rbp),%rdi
lea    0xeda(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1337 <f_radius+0x1f7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_radius>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
js     1259 <f_radius+0x119>
mov    %r8,%rbx
mov    %rsi,%r15
mov    %rsi,%rdi
call   1030 <code_table_3_2_location@plt>
test   %rax,%rax
je     11d9 <f_radius+0x99>
movzbl (%rax),%r12d
lea    0xedd(%rip),%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%r14
add    %rbx,%r14
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
call   1050 <axes_earth@plt>
cmp    $0x9,%r12
ja     11fb <f_radius+0xbb>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xe40(%rip),%xmm0
lea    0xe41(%rip),%rax
movslq (%rax,%r12,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe83(%rip),%rsi
jmp    121d <f_radius+0xdd>
movups 0xe5e(%rip),%xmm0
movups %xmm0,0xe(%rbx)
movupd 0xe44(%rip),%xmm0
movupd %xmm0,(%rbx)
jmp    1259 <f_radius+0x119>
lea    0xfb6(%rip),%rsi
jmp    124f <f_radius+0x10f>
movups 0x100f(%rip),%xmm0
movups %xmm0,0xc(%r14)
movupd 0xff6(%rip),%xmm0
movupd %xmm0,(%r14)
jmp    1259 <f_radius+0x119>
lea    0xe5e(%rip),%rsi
mov    %r14,%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1060 <sprintf@plt>
jmp    1259 <f_radius+0x119>
lea    0xe6a(%rip),%rsi
jmp    124f <f_radius+0x10f>
lea    0xea3(%rip),%rsi
jmp    124f <f_radius+0x10f>
lea    0xedd(%rip),%rsi
jmp    124f <f_radius+0x10f>
lea    0xf13(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%al
call   1060 <sprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"earth radius is not available\00"
@.str.1 = [12 x i8] c"code3.2=%d \00"
@.str.2 = [33 x i8] c"sphere predefined radius=%.1lf m\00"
@.str.3 = [35 x i8] c"sphere user defined radius=%.1lf m\00"
@.str.4 = [66 x i8] c"IAU 1965 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.5 = [67 x i8] c"IAG-GRS80 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.6 = [63 x i8] c"WGS84 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.7 = [77 x i8] c"OSGB-1936 Airy 1830 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.8 = [86 x i8] c"oblate spheroid user defined ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.9 = [28 x i8] c"unknown size/shape of earth\00"
define i32 @f_radius(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca float*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i8*
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i32 %0, i32* %8
store i8** %1, i8*** %9
store float* %2, float** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8** %5, i8*** %13
%19 = load i32, i32* %8
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %89
21: ; preds = %6
%22 = load i8**, i8*** %9
%23 = call i8* @code_table_3_2_location(i8** %22)
store i8* %23, i8** %15
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8*, i8** %12
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %90
28: ; preds = %21
%29 = load i8*, i8** %15
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
store i32 %31, i32* %14
%32 = load i8*, i8** %12
%33 = load i32, i32* %14
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i8*, i8** %12
%36 = call i32 @strlen(i8* %35)
%37 = load i8*, i8** %12
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %12
%40 = load i8**, i8*** %9
%41 = call i32 @axes_earth(i8** %40, double* %17, double* %18)
%42 = load double, double* %17
%43 = load double, double* %18
%44 = fadd double %42, %43
%45 = fmul double %44, 5.000000e-01
store double %45, double* %16
%46 = load i32, i32* %14
switch i32 %46, label %85 [
i32 0, label %47
i32 6, label %47
i32 8, label %47
i32 1, label %51
i32 2, label %55
i32 4, label %61
i32 5, label %67
i32 9, label %73
i32 3, label %79
i32 7, label %79
]
47: ; preds = %28, %28, %28
%48 = load i8*, i8** %12
%49 = load double, double* %17
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %49)
br label %88
51: ; preds = %28
%52 = load i8*, i8** %12
%53 = load double, double* %17
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %53)
br label %88
55: ; preds = %28
%56 = load i8*, i8** %12
%57 = load double, double* %16
%58 = load double, double* %17
%59 = load double, double* %18
%60 = call i32 (i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), double %57, double %58, double %59)
br label %88
61: ; preds = %28
%62 = load i8*, i8** %12
%63 = load double, double* %16
%64 = load double, double* %17
%65 = load double, double* %18
%66 = call i32 (i8*, i8*, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), double %63, double %64, double %65)
br label %88
67: ; preds = %28
%68 = load i8*, i8** %12
%69 = load double, double* %16
%70 = load double, double* %17
%71 = load double, double* %18
%72 = call i32 (i8*, i8*, ...) @sprintf(i8* %68, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), double %69, double %70, double %71)
br label %88
73: ; preds = %28
%74 = load i8*, i8** %12
%75 = load double, double* %16
%76 = load double, double* %17
%77 = load double, double* %18
%78 = call i32 (i8*, i8*, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.7, i64 0, i64 0), double %75, double %76, double %77)
br label %88
79: ; preds = %28, %28
%80 = load i8*, i8** %12
%81 = load double, double* %16
%82 = load double, double* %17
%83 = load double, double* %18
%84 = call i32 (i8*, i8*, ...) @sprintf(i8* %80, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.8, i64 0, i64 0), double %81, double %82, double %83)
br label %88
85: ; preds = %28
%86 = load i8*, i8** %12
%87 = call i32 (i8*, i8*, ...) @sprintf(i8* %86, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %88
88: ; preds = %85, %79, %73, %67, %61, %55, %51, %47
br label %89
89: ; preds = %88, %6
store i32 0, i32* %7
br label %90
90: ; preds = %89, %25
%91 = load i32, i32* %7
ret i32 %91
}

LLVM IR (-O2):
@.str = [30 x i8] c"earth radius is not available\00"
@.str.1 = [12 x i8] c"code3.2=%d \00"
@.str.2 = [33 x i8] c"sphere predefined radius=%.1lf m\00"
@.str.3 = [35 x i8] c"sphere user defined radius=%.1lf m\00"
@.str.4 = [66 x i8] c"IAU 1965 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.5 = [67 x i8] c"IAG-GRS80 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.6 = [63 x i8] c"WGS84 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.7 = [77 x i8] c"OSGB-1936 Airy 1830 ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.8 = [86 x i8] c"oblate spheroid user defined ave radius=%.1lf m major axis=%.1lf m minor axis=%.1lf m\00"
@.str.9 = [28 x i8] c"unknown size/shape of earth\00"
define i32 @f_radius(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* %4, i8** nocapture readnone %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = icmp sgt i32 %0, -1
br i1 %11, label %12, label %43
12: ; preds = %6
%13 = tail call i8* @code_table_3_2_location(i8** %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %12
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(30) %4, i8* align 1 dereferenceable(30) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 30, i1 false)
br label %43
16: ; preds = %12
%17 = load i8, i8* %13
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = tail call i32 @strlen(i8* %4)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %4, i64 %21
%23 = call i32 @axes_earth(i8** %1, double* %7, double* %8)
%24 = load double, double* %7
%25 = load double, double* %8
%26 = fadd double %24, %25
%27 = fmul double %26, 5.000000e-01
switch i8 %17, label %42 [
i8 0, label %28
i8 6, label %28
i8 8, label %28
i8 1, label %30
i8 2, label %32
i8 4, label %34
i8 5, label %36
i8 9, label %38
i8 3, label %40
i8 7, label %40
]
28: ; preds = %16, %16, %16
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %24)
br label %43
30: ; preds = %16
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %24)
br label %43
32: ; preds = %16
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), double %27, double %24, double %25)
br label %43
34: ; preds = %16
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), double %27, double %24, double %25)
br label %43
36: ; preds = %16
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), double %27, double %24, double %25)
br label %43
38: ; preds = %16
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.7, i64 0, i64 0), double %27, double %24, double %25)
br label %43
40: ; preds = %16, %16
%41 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.8, i64 0, i64 0), double %27, double %24, double %25)
br label %43
42: ; preds = %16
br label %43
43: ; preds = %6, %42, %40, %38, %36, %34, %32, %30, %28, %15
ret i32 0
}