#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 AACGMConvert(double, double, double, double *, double *, double *, int);
int AACGMLoadCoef(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *fname = NULL;
  double ilat, ilon, hgt;
  double olat, olon, r;
  int flg;
  int s;
  ilat = 85.0;
  ilon = 45.0;
  hgt = 150.0;
  flg = 0;
  if (argc < 2) {
    fprintf(stderr, "Require coefficient filename.\n");
    exit(-1);
  }
  fname = argv[1];
  s = AACGMLoadCoef(fname);
  if (s != 0) {
    fprintf(stderr, "Error loading coefficients.\n");
    exit(-1);
  }
  s = AACGMConvert(ilat, ilon, hgt, &olat, &olon, &r, flg);
  if (s != 0) {
    fprintf(stderr, "Error in AACGM conversion.\n");
    exit(-1);
  }
  fprintf(stdout, "AACGMLoadCoef\n");
  fprintf(stdout, "Coefficient file:%s\n", fname);
  fprintf(stdout, "Input: lat=%g, lon=%g, height=%g\n", ilat, ilon, hgt);
  fprintf(stdout, "Output: lat=%g, lon=%g\n", olat, olon);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b7 <main+0x77>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <AACGMLoadCoef@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     11fa <main+0xba>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mov    -0x4c(%rbp),%ecx
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1050 <AACGMConvert@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     124b <main+0x10b>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
lea    0xdf8(%rip),%rsi
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xdf9(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jle    120f <main+0xcf>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
call   1030 <AACGMLoadCoef@plt>
test   %eax,%eax
jne    1221 <main+0xe1>
movsd  0xe94(%rip),%xmm0
movsd  0xe94(%rip),%xmm1
movsd  0xe94(%rip),%xmm2
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   1050 <AACGMConvert@plt>
test   %eax,%eax
jne    1233 <main+0xf3>
mov    0x2e39(%rip),%rbx
mov    (%rbx),%edi
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xec7(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xec9(%rip),%rsi
movsd  0xe2d(%rip),%xmm0
movsd  0xe2d(%rip),%xmm1
movsd  0xe2d(%rip),%xmm2
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
lea    0xeb8(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
jmp    1243 <main+0x103>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
jmp    1243 <main+0x103>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Require coefficient filename.\0A\00"
@.str.1 = [29 x i8] c"Error loading coefficients.\0A\00"
@.str.2 = [28 x i8] c"Error in AACGM conversion.\0A\00"
@stdout = global i32 0
@.str.3 = [15 x i8] c"AACGMLoadCoef\0A\00"
@.str.4 = [21 x i8] c"Coefficient file:%s\0A\00"
@.str.5 = [34 x i8] c"Input: lat=%g, lon=%g, height=%g\0A\00"
@.str.6 = [24 x i8] c"Output: lat=%g, lon=%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store double 8.500000e+01, double* %7
store double 4.500000e+01, double* %8
store double 1.500000e+02, double* %9
store i32 0, i32* %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i32 @AACGMLoadCoef(i8* %25)
store i32 %26, i32* %14
%27 = load i32, i32* %14
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %21
%34 = load double, double* %7
%35 = load double, double* %8
%36 = load double, double* %9
%37 = load i32, i32* %13
%38 = call i32 @AACGMConvert(double %34, double %35, double %36, double* %10, double* %11, double* %12, i32 %37)
store i32 %38, i32* %14
%39 = load i32, i32* %14
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %33
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %33
%46 = load i32, i32* @stdout
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* @stdout
%49 = load i8*, i8** %6
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @stdout
%52 = load double, double* %7
%53 = load double, double* %8
%54 = load double, double* %9
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %52, double %53, double %54)
%56 = load i32, i32* @stdout
%57 = load double, double* %10
%58 = load double, double* %11
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %57, double %58)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Require coefficient filename.\0A\00"
@.str.1 = [29 x i8] c"Error loading coefficients.\0A\00"
@.str.2 = [28 x i8] c"Error in AACGM conversion.\0A\00"
@stdout = global i32 0
@.str.3 = [15 x i8] c"AACGMLoadCoef\0A\00"
@.str.4 = [21 x i8] c"Coefficient file:%s\0A\00"
@.str.5 = [34 x i8] c"Input: lat=%g, lon=%g, height=%g\0A\00"
@.str.6 = [24 x i8] c"Output: lat=%g, lon=%g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %3 to i8*
%7 = bitcast double* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @AACGMLoadCoef(i8* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %14
%24 = call i32 @AACGMConvert(double 8.500000e+01, double 4.500000e+01, double 1.500000e+02, double* %3, double* %4, double* %5, i32 0)
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %23
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%35 = load i32, i32* @stdout
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double 8.500000e+01, double 4.500000e+01, double 1.500000e+02)
%37 = load i32, i32* @stdout
%38 = load double, double* %3
%39 = load double, double* %4
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %38, double %39)
ret i32 0
}