#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
int M_PI;
float atan2(float, float);
float cos(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, float);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *, ...);
int /*<<< orphan*/ printf(char *, ...);
float sin(float);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *, float *, float *,
                          float *, float *, float *, float *, float *, float *,
                          float *, float *, float *);
int main() {
  FILE *input;
  FILE *hindge;
  FILE *plane;
  FILE *output;
  FILE *implement;
  int i;
  char C[60];
  char *brac;
  char buff[BUFSIZ];
  float time, angle;
  float pf[3], vf[3], pm[3], vm[3], p1[3], p2[3], p3[3];
  float forceSum[3], normal[3], momentSum[3], hardMoment, calculatedMoment,
      surf_ang, length;
  hindge = fopen("./constant/triSurface/hindge.dat", "r");
  if (hindge == NULL) {
    printf("Error! locations of the hindge point is not specified");
    return 1;
  } else {
    fscanf(hindge, "%f %f %f \n", &p1[1], &p1[2], &p1[3]);
    fscanf(hindge, "%f %f %f \n %f %f", &p2[1], &p2[2], &p2[3], &surf_ang,
           &length);
    printf("The hindge points are (%f %f %f) and (%f %f %f)\n", p1[1], p1[2],
           p1[3], p2[1], p2[2], p2[3]);
    fclose(hindge);
  }
  forceSum[1] = 0.0;
  forceSum[2] = 0.0;
  forceSum[3] = 0.0;
  input = fopen("./postProcessing/balance/0/forces.dat", "r");
  if (input == NULL) {
    printf("Error, unable to find forces.dat, please check your folder "
           "name/structure... \n");
    return 1;
  } else {
    printf("Reading force balance across the flap... \n");
    brac = fgets(C, 60, input);
    i = 0;
    while (fgets(buff, sizeof buff, input) != NULL) {
      sscanf(buff, "%f (((%f %f %f) (%f %f %f)) ((%f %f %f) (%f %f %f)))",
             &time, &pf[1], &pf[2], &pf[3], &vf[1], &vf[2], &vf[3], &pm[1],
             &pm[2], &pm[3], &vm[1], &vm[2], &vm[3]);
      if (i <= 8) {
        forceSum[1] = 0.0;
        forceSum[2] = 0.0;
        forceSum[3] = 0.0;
        momentSum[1] = 0.0;
        momentSum[2] = 0.0;
        momentSum[3] = 0.0;
      } else {
        forceSum[1] += pf[1] + vf[1];
        forceSum[2] += pf[2] + vf[2];
        forceSum[3] += pf[3] + vf[3];
        momentSum[1] += pm[1] + vm[1];
        momentSum[2] += pm[2] + vm[2];
        momentSum[3] += pm[3] + vm[3];
      }
      i++;
    }
    i = i - 9;
    forceSum[1] /= (float)i;
    forceSum[2] /= (float)i;
    forceSum[3] /= (float)i;
    momentSum[1] /= (float)i;
    momentSum[2] /= (float)i;
    momentSum[3] /= (float)i;
    printf("Moments about point (0 0 3) are:%f y:%f z:%f \n", momentSum[1],
           momentSum[2], momentSum[3]);
    fclose(input);
    plane = fopen("./constant/triSurface/flap.stl", "r");
    if (plane == NULL) {
      printf("Error! Unable to find flap angle, please check the file "
             "location!\n");
      return 1;
    } else {
      fgets(buff, sizeof buff, plane);
      fscanf(plane, "%*s %*s %f %f %f", &normal[1], &normal[2], &normal[3]);
      fclose(plane);
      if (normal[2] != 0.0) {
        printf("Error! Invalid Normal Direction");
        return 1;
      } else {
        angle = atan2(normal[3], normal[1]);
        if (angle < 0)
          angle = (angle + 2 * M_PI) * 180 / M_PI - 90;
        else
          angle = angle * 180 / M_PI - 90;
        printf("Flap angle is read in as: %f degree \n", angle);
      }
    }
    calculatedMoment = (length / 2) * (-forceSum[1] * sin(angle * M_PI / 180) +
                                       forceSum[3] * cos(angle * M_PI / 180));
    hardMoment = 0;
    implement = fopen("./constant/forcedMoment.dat", "r");
    if (implement == NULL) {
      printf("Error, cannot find forcedMoment.dat!! \n");
      printf("Setting additional moment to zero!! \n");
      hardMoment = 0;
    } else {
      fscanf(implement, "%f", &hardMoment);
      fclose(implement);
    }
    output = fopen("forceBalance.dat", "a");
    printf("Writing forceBalance.dat...\n");
    fprintf(output, "%f %f\n", angle, (calculatedMoment + hardMoment));
    fclose(output);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
movl   $0x0,-0x2c(%rbp)
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x160(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x158(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xb8(%rbp)
lea    0xe0e(%rip),%rdi
lea    0xe28(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    123d <main+0x9d>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x14c(%rbp)
jmp    1a19 <main+0x879>
mov    -0x40(%rbp),%rdi
lea    -0xfc(%rbp),%rdx
add    $0x4,%rdx
lea    -0xfc(%rbp),%rcx
add    $0x8,%rcx
lea    -0xfc(%rbp),%r8
add    $0xc,%r8
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x108(%rbp),%rdx
add    $0x4,%rdx
lea    -0x108(%rbp),%rcx
add    $0x8,%rcx
lea    -0x108(%rbp),%r8
add    $0xc,%r8
lea    0xdd4(%rip),%rsi
lea    -0x144(%rbp),%r9
lea    -0x148(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
mov    $0x0,%al
call   1060 <fscanf@plt>
add    $0x10,%rsp
movss  -0xf8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0xf4(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0xf0(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
movss  -0x104(%rbp),%xmm3
ff
cvtss2sd %xmm3,%xmm3
movss  -0x100(%rbp),%xmm4
ff
cvtss2sd %xmm4,%xmm4
movss  -0xfc(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xd75(%rip),%rdi
mov    $0x6,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x118(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x114(%rbp)
ff
lea    0xd6e(%rip),%rdi
lea    0xce2(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1383 <main+0x1e3>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x14c(%rbp)
jmp    1a19 <main+0x879>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x3c,%esi
call   1070 <fgets@plt>
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x158(%rbp),%rdi
mov    -0x160(%rbp),%rax
mov    %eax,%esi
mov    -0x38(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     15d6 <main+0x436>
mov    -0x158(%rbp),%rdi
lea    -0xcc(%rbp),%rcx
add    $0x4,%rcx
lea    -0xcc(%rbp),%r8
add    $0x8,%r8
lea    -0xcc(%rbp),%r9
add    $0xc,%r9
lea    -0xd8(%rbp),%rax
add    $0x4,%rax
lea    -0xd8(%rbp),%r13
add    $0x8,%r13
lea    -0xd8(%rbp),%r12
add    $0xc,%r12
lea    -0xe4(%rbp),%r15
add    $0x4,%r15
lea    -0xe4(%rbp),%r14
add    $0x8,%r14
lea    -0xe4(%rbp),%rbx
add    $0xc,%rbx
lea    -0xf0(%rbp),%r11
add    $0x4,%r11
lea    -0xf0(%rbp),%r10
add    $0x8,%r10
lea    -0xf0(%rbp),%rdx
add    $0xc,%rdx
mov    %rdx,-0x168(%rbp)
lea    0xce2(%rip),%rsi
lea    -0xbc(%rbp),%rdx
sub    $0x50,%rsp
mov    %rax,(%rsp)
mov    -0x168(%rbp),%rax
mov    %r13,0x8(%rsp)
mov    %r12,0x10(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14,0x20(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r11,0x30(%rsp)
mov    %r10,0x38(%rsp)
mov    %rax,0x40(%rsp)
call   10a0 <sscanf@plt>
add    $0x50,%rsp
cmpl   $0x8,-0x5c(%rbp)
jg     1508 <main+0x368>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x118(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x114(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x134(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x130(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x12c(%rbp)
ff
jmp    15c8 <main+0x428>
movss  -0xc8(%rbp),%xmm0
ff
addss  -0xd4(%rbp),%xmm0
ff
addss  -0x11c(%rbp),%xmm0
ff
movss  %xmm0,-0x11c(%rbp)
ff
movss  -0xc4(%rbp),%xmm0
ff
addss  -0xd0(%rbp),%xmm0
ff
addss  -0x118(%rbp),%xmm0
ff
movss  %xmm0,-0x118(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
addss  -0xcc(%rbp),%xmm0
ff
addss  -0x114(%rbp),%xmm0
ff
movss  %xmm0,-0x114(%rbp)
ff
movss  -0xe0(%rbp),%xmm0
ff
addss  -0xec(%rbp),%xmm0
ff
addss  -0x134(%rbp),%xmm0
ff
movss  %xmm0,-0x134(%rbp)
ff
movss  -0xdc(%rbp),%xmm0
ff
addss  -0xe8(%rbp),%xmm0
ff
addss  -0x130(%rbp),%xmm0
ff
movss  %xmm0,-0x130(%rbp)
ff
movss  -0xd8(%rbp),%xmm0
ff
addss  -0xe4(%rbp),%xmm0
ff
addss  -0x12c(%rbp),%xmm0
ff
movss  %xmm0,-0x12c(%rbp)
ff
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    13b4 <main+0x214>
mov    -0x5c(%rbp),%eax
sub    $0x9,%eax
mov    %eax,-0x5c(%rbp)
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x11c(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x118(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x118(%rbp)
ff
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x114(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x114(%rbp)
ff
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x134(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x134(%rbp)
ff
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x130(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x130(%rbp)
ff
cvtsi2ssl -0x5c(%rbp),%xmm1
movss  -0x12c(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x12c(%rbp)
ff
movss  -0x134(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0x130(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0x12c(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    0xae7(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xaff(%rip),%rdi
lea    0x96f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    16f6 <main+0x556>
lea    0xafc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x14c(%rbp)
jmp    1a19 <main+0x879>
mov    -0x158(%rbp),%rdi
mov    -0x160(%rbp),%rax
mov    %eax,%esi
mov    -0x48(%rbp),%rdx
call   1070 <fgets@plt>
mov    -0x48(%rbp),%rdi
lea    -0x12c(%rbp),%rdx
add    $0x4,%rdx
lea    -0x12c(%rbp),%rcx
add    $0x8,%rcx
lea    -0x12c(%rbp),%r8
add    $0xc,%r8
lea    0xadd(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
movss  -0x124(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    176f <main+0x5cf>
jp     176f <main+0x5cf>
jmp    1793 <main+0x5f3>
lea    0xab3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x14c(%rbp)
jmp    1a19 <main+0x879>
movss  -0x120(%rbp),%xmm0
ff
movss  -0x128(%rbp),%xmm1
ff
call   1030 <atan2@plt>
movss  %xmm0,-0xc0(%rbp)
ff
xorps  %xmm0,%xmm0
ucomiss -0xc0(%rbp),%xmm0
jbe    1810 <main+0x670>
movss  -0xc0(%rbp),%xmm0
ff
mov    0x2819(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  0x820(%rip),%xmm1
mulss  %xmm1,%xmm0
mov    0x27f9(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
movss  0x801(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc0(%rbp)
ff
jmp    1843 <main+0x6a3>
movss  0x7ec(%rip),%xmm0
mulss  -0xc0(%rbp),%xmm0
ff
mov    0x27c1(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
movss  0x7c9(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc0(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0x9f3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1862 <main+0x6c2>
movss  -0x148(%rbp),%xmm0
ff
movss  0x796(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x16c(%rbp)
ff
movss  -0x11c(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x174(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
mov    0x273e(%rip),%rax
cvtsi2ssl (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  0x74a(%rip),%xmm1
divss  %xmm1,%xmm0
call   1090 <sin@plt>
movss  %xmm0,-0x170(%rbp)
ff
movss  -0x114(%rbp),%xmm0
ff
movss  %xmm0,-0x178(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
mov    0x26fe(%rip),%rax
cvtsi2ssl (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  0x70a(%rip),%xmm1
divss  %xmm1,%xmm0
call   10b0 <cos@plt>
movss  -0x178(%rbp),%xmm2
ff
movss  -0x174(%rbp),%xmm1
ff
movss  -0x170(%rbp),%xmm3
ff
movaps %xmm0,%xmm4
movss  -0x16c(%rbp),%xmm0
ff
mulss  %xmm4,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x140(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x13c(%rbp)
ff
lea    0x91f(%rip),%rdi
lea    0x6d6(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1997 <main+0x7f7>
lea    0x919(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x933(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x13c(%rbp)
ff
jmp    19b9 <main+0x819>
mov    -0x58(%rbp),%rdi
lea    0x6dc(%rip),%rsi
lea    -0x13c(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
lea    0x919(%rip),%rdi
lea    0x923(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x50(%rbp)
lea    0x915(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
movss  -0xc0(%rbp),%xmm0
ff
movss  -0x140(%rbp),%xmm1
ff
addss  -0x13c(%rbp),%xmm1
ff
lea    0x908(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x14c(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,%rsp
mov    -0x2c(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsp,%r12
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
mov    %rax,-0x38(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe30(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13dd <main+0x22d>
mov    %rax,%r14
lea    -0x58(%rbp),%rdx
lea    -0x54(%rbp),%rcx
lea    -0x50(%rbp),%r8
lea    0xe5e(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    -0x4c(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x44(%rbp),%r8
sub    $0x8,%rsp
lea    -0x94(%rbp),%r10
lea    0xe41(%rip),%rsi
lea    -0x98(%rbp),%r9
mov    %r14,%rdi
xor    %eax,%eax
push   %r10
call   1070 <fscanf@plt>
add    $0x10,%rsp
movss  -0x58(%rbp),%xmm0
movss  -0x54(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x50(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x4c(%rbp),%xmm3
movss  -0x48(%rbp),%xmm4
cvtss2sd %xmm3,%xmm3
cvtss2sd %xmm4,%xmm4
movss  -0x44(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xdfe(%rip),%rdi
mov    $0x6,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xe19(%rip),%rdi
lea    0xd8d(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13fa <main+0x24a>
mov    %rax,%r15
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
lea    -0x110(%rbp),%rdi
mov    $0x3c,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
mov    -0x38(%rbp),%rsi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1406 <main+0x256>
mov    %r12,-0x90(%rbp)
mov    $0xfffffff7,%r14d
lea    0xddb(%rip),%r12
lea    -0xb4(%rbp),%r13
jmp    134b <main+0x19b>
cs nopw 0x0(%rax,%rax,1)
movaps %xmm0,-0x70(%rbp)
mov    %rbx,%rdi
mov    -0x38(%rbp),%rsi
mov    %r15,%rdx
call   1080 <fgets@plt>
movaps -0x70(%rbp),%xmm2
add    $0x1,%r14d
movaps %xmm2,-0xd0(%rbp)
test   %rax,%rax
je     13e9 <main+0x239>
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
lea    -0xac(%rbp),%rcx
lea    -0xa8(%rbp),%r8
lea    -0xa4(%rbp),%r9
lea    -0x70(%rbp),%rax
push   %rax
lea    -0x74(%rbp),%rax
push   %rax
lea    -0x78(%rbp),%rax
push   %rax
lea    -0x7c(%rbp),%rax
push   %rax
lea    -0x80(%rbp),%rax
push   %rax
lea    -0x84(%rbp),%rax
push   %rax
lea    -0x98(%rbp),%rax
push   %rax
lea    -0x9c(%rbp),%rax
push   %rax
lea    -0xa0(%rbp),%rax
push   %rax
call   10b0 <sscanf@plt>
add    $0x50,%rsp
mov    %r14d,%eax
xorps  %xmm0,%xmm0
add    $0x9,%eax
jb     1320 <main+0x170>
movsd  -0x84(%rbp),%xmm0
ff
movsd  -0x78(%rbp),%xmm1
addps  %xmm0,%xmm1
movaps -0xd0(%rbp),%xmm0
addps  %xmm1,%xmm0
jmp    1320 <main+0x170>
lea    0xc5b(%rip),%rdi
jmp    14a6 <main+0x2f6>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
mov    -0x90(%rbp),%r12
jmp    140e <main+0x25e>
lea    0xecb(%rip),%rdi
jmp    14b6 <main+0x306>
movss  0xbf2(%rip),%xmm0
movaps %xmm2,%xmm1
divss  %xmm0,%xmm1
shufps $0x55,%xmm2,%xmm2
divss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xceb(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xd04(%rip),%rdi
lea    0xbee(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14af <main+0x2ff>
mov    %rax,%r14
mov    %rbx,%rdi
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
call   1080 <fgets@plt>
lea    -0x40(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    0xced(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
movss  -0x3c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    149f <main+0x2ef>
jnp    14d2 <main+0x322>
lea    0xcd6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    14bb <main+0x30b>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movss  -0x40(%rbp),%xmm1
movss  -0x38(%rbp),%xmm0
call   1040 <atan2@plt>
mov    0x2b00(%rip),%rbx
mov    (%rbx),%eax
lea    (%rax,%rax,1),%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
movaps %xmm0,%xmm4
cmpltss 0xb18(%rip),%xmm4
movss  0xafc(%rip),%xmm2
movaps %xmm4,%xmm3
andnps %xmm2,%xmm3
andps  %xmm1,%xmm4
orps   %xmm3,%xmm4
addss  %xmm0,%xmm4
mulss  0xae8(%rip),%xmm4
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm4
addss  0xad9(%rip),%xmm4
movaps %xmm4,-0x70(%rbp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
lea    0xc57(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl (%rbx),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0xaa8(%rip),%xmm0
ucomiss 0xaa9(%rip),%xmm0
jae    1640 <main+0x490>
movss  0xa9f(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1640 <main+0x490>
ucomiss 0xa8b(%rip),%xmm0
jae    1666 <main+0x4b6>
movss  0xa81(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1666 <main+0x4b6>
movl   $0x0,-0x2c(%rbp)
lea    0xc18(%rip),%rdi
lea    0xa8c(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     15dd <main+0x42d>
mov    %rax,%rbx
lea    0xac9(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    15fc <main+0x44c>
lea    0xc5a(%rip),%rdi
call   1030 <puts@plt>
lea    0xc75(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x2c(%rbp)
lea    0xbdb(%rip),%rdi
lea    0xbe5(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
lea    0xc09(%rip),%rdi
call   1030 <puts@plt>
lea    0xbcc(%rip),%rsi
mov    %rbx,%rdi
movaps -0x70(%rbp),%xmm0
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    14c0 <main+0x310>
call   10a0 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl (%rbx),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0x9af(%rip),%xmm0
ucomiss 0x9b0(%rip),%xmm0
jb     158b <main+0x3db>
call   10c0 <cos@plt>
jmp    159c <main+0x3ec>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [33 x i8] c"./constant/triSurface/hindge.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [54 x i8] c"Error! locations of the hindge point is not specified\00"
@.str.3 = [11 x i8] c"%f %f %f \0A\00"
@.str.4 = [17 x i8] c"%f %f %f \0A %f %f\00"
@.str.5 = [49 x i8] c"The hindge points are (%f %f %f) and (%f %f %f)\0A\00"
@.str.6 = [38 x i8] c"./postProcessing/balance/0/forces.dat\00"
@.str.7 = [79 x i8] c"Error, unable to find forces.dat, please check your folder name/structure... \0A\00"
@.str.8 = [43 x i8] c"Reading force balance across the flap... \0A\00"
@.str.9 = [53 x i8] c"%f (((%f %f %f) (%f %f %f)) ((%f %f %f) (%f %f %f)))\00"
@.str.10 = [47 x i8] c"Moments about point (0 0 3) are:%f y:%f z:%f \0A\00"
@.str.11 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.12 = [67 x i8] c"Error! Unable to find flap angle, please check the file location!\0A\00"
@.str.13 = [17 x i8] c"%*s %*s %f %f %f\00"
@.str.14 = [32 x i8] c"Error! Invalid Normal Direction\00"
@M_PI = global i32 0
@.str.15 = [38 x i8] c"Flap angle is read in as: %f degree \0A\00"
@.str.16 = [28 x i8] c"./constant/forcedMoment.dat\00"
@.str.17 = [40 x i8] c"Error, cannot find forcedMoment.dat!! \0A\00"
@.str.18 = [38 x i8] c"Setting additional moment to zero!! \0A\00"
@.str.19 = [3 x i8] c"%f\00"
@.str.20 = [17 x i8] c"forceBalance.dat\00"
@.str.21 = [2 x i8] c"a\00"
@.str.22 = [29 x i8] c"Writing forceBalance.dat...\0A\00"
@.str.23 = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [60 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca float
%13 = alloca float
%14 = alloca [3 x float]
%15 = alloca [3 x float]
%16 = alloca [3 x float]
%17 = alloca [3 x float]
%18 = alloca [3 x float]
%19 = alloca [3 x float]
%20 = alloca [3 x float]
%21 = alloca [3 x float]
%22 = alloca [3 x float]
%23 = alloca [3 x float]
%24 = alloca float
%25 = alloca float
%26 = alloca float
%27 = alloca float
%28 = alloca i32
store i32 0, i32* %1
%29 = load i32, i32* @BUFSIZ
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %10
%32 = alloca i8, i64 %30
store i64 %30, i64* %11
%33 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %3
%34 = load i32*, i32** %3
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %28
br label %308
38: ; preds = %0
%39 = load i32*, i32** %3
%40 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
%41 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%42 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
%43 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float* %40, float* %41, float* %42)
%44 = load i32*, i32** %3
%45 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 1
%46 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 2
%47 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 3
%48 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %44, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float* %45, float* %46, float* %47, float* %26, float* %27)
%49 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
%56 = load float, float* %55
%57 = fpext float %56 to double
%58 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 1
%59 = load float, float* %58
%60 = fpext float %59 to double
%61 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 2
%62 = load float, float* %61
%63 = fpext float %62 to double
%64 = getelementptr inbounds [3 x float], [3 x float]* %19, i64 0, i64 3
%65 = load float, float* %64
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), double %51, double %54, double %57, double %60, double %63, double %66)
%68 = load i32*, i32** %3
%69 = call i32 @fclose(i32* %68)
br label %70
70: ; preds = %38
%71 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
store float 0.000000e+00, float* %71
%72 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 2
store float 0.000000e+00, float* %72
%73 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 3
store float 0.000000e+00, float* %73
%74 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %74, i32** %2
%75 = load i32*, i32** %2
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %79
77: ; preds = %70
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %28
br label %308
79: ; preds = %70
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0))
%81 = getelementptr inbounds [60 x i8], [60 x i8]* %8, i64 0, i64 0
%82 = load i32*, i32** %2
%83 = call i8* @fgets(i8* %81, i32 60, i32* %82)
store i8* %83, i8** %9
store i32 0, i32* %7
br label %84
84: ; preds = %161, %79
%85 = trunc i64 %30 to i32
%86 = load i32*, i32** %2
%87 = call i8* @fgets(i8* %32, i32 %85, i32* %86)
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %164
89: ; preds = %84
%90 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%91 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%92 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%93 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%94 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%95 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%96 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%97 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%98 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
%99 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 1
%100 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 2
%101 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 3
%102 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), float* %12, float* %90, float* %91, float* %92, float* %93, float* %94, float* %95, float* %96, float* %97, float* %98, float* %99, float* %100, float* %101)
%103 = load i32, i32* %7
%104 = icmp sle i32 %103, 8
br i1 %104, label %105, label %112
105: ; preds = %89
%106 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
store float 0.000000e+00, float* %106
%107 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 2
store float 0.000000e+00, float* %107
%108 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 3
store float 0.000000e+00, float* %108
%109 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 1
store float 0.000000e+00, float* %109
%110 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 2
store float 0.000000e+00, float* %110
%111 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 3
store float 0.000000e+00, float* %111
br label %161
112: ; preds = %89
%113 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%114 = load float, float* %113
%115 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%116 = load float, float* %115
%117 = fadd float %114, %116
%118 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
%119 = load float, float* %118
%120 = fadd float %119, %117
store float %120, float* %118
%121 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%122 = load float, float* %121
%123 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%124 = load float, float* %123
%125 = fadd float %122, %124
%126 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 2
%127 = load float, float* %126
%128 = fadd float %127, %125
store float %128, float* %126
%129 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%130 = load float, float* %129
%131 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%132 = load float, float* %131
%133 = fadd float %130, %132
%134 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 3
%135 = load float, float* %134
%136 = fadd float %135, %133
store float %136, float* %134
%137 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%138 = load float, float* %137
%139 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 1
%140 = load float, float* %139
%141 = fadd float %138, %140
%142 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 1
%143 = load float, float* %142
%144 = fadd float %143, %141
store float %144, float* %142
%145 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%146 = load float, float* %145
%147 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 2
%148 = load float, float* %147
%149 = fadd float %146, %148
%150 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 2
%151 = load float, float* %150
%152 = fadd float %151, %149
store float %152, float* %150
%153 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
%154 = load float, float* %153
%155 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 3
%156 = load float, float* %155
%157 = fadd float %154, %156
%158 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 3
%159 = load float, float* %158
%160 = fadd float %159, %157
store float %160, float* %158
br label %161
161: ; preds = %112, %105
%162 = load i32, i32* %7
%163 = add nsw i32 %162, 1
store i32 %163, i32* %7
br label %84
164: ; preds = %84
%165 = load i32, i32* %7
%166 = sub nsw i32 %165, 9
store i32 %166, i32* %7
%167 = load i32, i32* %7
%168 = sitofp i32 %167 to float
%169 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
%170 = load float, float* %169
%171 = fdiv float %170, %168
store float %171, float* %169
%172 = load i32, i32* %7
%173 = sitofp i32 %172 to float
%174 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 2
%175 = load float, float* %174
%176 = fdiv float %175, %173
store float %176, float* %174
%177 = load i32, i32* %7
%178 = sitofp i32 %177 to float
%179 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 3
%180 = load float, float* %179
%181 = fdiv float %180, %178
store float %181, float* %179
%182 = load i32, i32* %7
%183 = sitofp i32 %182 to float
%184 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 1
%185 = load float, float* %184
%186 = fdiv float %185, %183
store float %186, float* %184
%187 = load i32, i32* %7
%188 = sitofp i32 %187 to float
%189 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 2
%190 = load float, float* %189
%191 = fdiv float %190, %188
store float %191, float* %189
%192 = load i32, i32* %7
%193 = sitofp i32 %192 to float
%194 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 3
%195 = load float, float* %194
%196 = fdiv float %195, %193
store float %196, float* %194
%197 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 1
%198 = load float, float* %197
%199 = fpext float %198 to double
%200 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 2
%201 = load float, float* %200
%202 = fpext float %201 to double
%203 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 3
%204 = load float, float* %203
%205 = fpext float %204 to double
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0), double %199, double %202, double %205)
%207 = load i32*, i32** %2
%208 = call i32 @fclose(i32* %207)
%209 = call i32* @fopen(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %209, i32** %4
%210 = load i32*, i32** %4
%211 = icmp eq i32* %210, null
br i1 %211, label %212, label %214
212: ; preds = %164
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %28
br label %308
214: ; preds = %164
%215 = trunc i64 %30 to i32
%216 = load i32*, i32** %4
%217 = call i8* @fgets(i8* %32, i32 %215, i32* %216)
%218 = load i32*, i32** %4
%219 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 1
%220 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 2
%221 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 3
%222 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %218, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), float* %219, float* %220, float* %221)
%223 = load i32*, i32** %4
%224 = call i32 @fclose(i32* %223)
%225 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 2
%226 = load float, float* %225
%227 = fpext float %226 to double
%228 = fcmp une double %227, 0.000000e+00
br i1 %228, label %229, label %231
229: ; preds = %214
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %28
br label %308
231: ; preds = %214
%232 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 3
%233 = load float, float* %232
%234 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 1
%235 = load float, float* %234
%236 = call float @atan2(float %233, float %235)
store float %236, float* %13
%237 = load float, float* %13
%238 = fcmp olt float %237, 0.000000e+00
br i1 %238, label %239, label %250
239: ; preds = %231
%240 = load float, float* %13
%241 = load i32, i32* @M_PI
%242 = mul nsw i32 2, %241
%243 = sitofp i32 %242 to float
%244 = fadd float %240, %243
%245 = fmul float %244, 1.800000e+02
%246 = load i32, i32* @M_PI
%247 = sitofp i32 %246 to float
%248 = fdiv float %245, %247
%249 = fsub float %248, 9.000000e+01
store float %249, float* %13
br label %257
250: ; preds = %231
%251 = load float, float* %13
%252 = fmul float %251, 1.800000e+02
%253 = load i32, i32* @M_PI
%254 = sitofp i32 %253 to float
%255 = fdiv float %252, %254
%256 = fsub float %255, 9.000000e+01
store float %256, float* %13
br label %257
257: ; preds = %250, %239
%258 = load float, float* %13
%259 = fpext float %258 to double
%260 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0), double %259)
br label %261
261: ; preds = %257
br label %262
262: ; preds = %261
%263 = load float, float* %27
%264 = fdiv float %263, 2.000000e+00
%265 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
%266 = load float, float* %265
%267 = fneg float %266
%268 = load float, float* %13
%269 = load i32, i32* @M_PI
%270 = sitofp i32 %269 to float
%271 = fmul float %268, %270
%272 = fdiv float %271, 1.800000e+02
%273 = call float @sin(float %272)
%274 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 3
%275 = load float, float* %274
%276 = load float, float* %13
%277 = load i32, i32* @M_PI
%278 = sitofp i32 %277 to float
%279 = fmul float %276, %278
%280 = fdiv float %279, 1.800000e+02
%281 = call float @cos(float %280)
%282 = fmul float %275, %281
%283 = call float @llvm.fmuladd.f32(float %267, float %273, float %282)
%284 = fmul float %264, %283
store float %284, float* %25
store float 0.000000e+00, float* %24
%285 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %285, i32** %6
%286 = load i32*, i32** %6
%287 = icmp eq i32* %286, null
br i1 %287, label %288, label %291
288: ; preds = %262
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.17, i64 0, i64 0))
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
store float 0.000000e+00, float* %24
br label %296
291: ; preds = %262
%292 = load i32*, i32** %6
%293 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %292, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), float* %24)
%294 = load i32*, i32** %6
%295 = call i32 @fclose(i32* %294)
br label %296
296: ; preds = %291, %288
%297 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0))
store i32* %297, i32** %5
%298 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
%299 = load i32*, i32** %5
%300 = load float, float* %13
%301 = load float, float* %25
%302 = load float, float* %24
%303 = fadd float %301, %302
%304 = call i32 @fprintf(i32* %299, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0), float %300, float %303)
%305 = load i32*, i32** %5
%306 = call i32 @fclose(i32* %305)
br label %307
307: ; preds = %296
store i32 0, i32* %28
br label %308
308: ; preds = %307, %229, %212, %77, %36
%309 = load i8*, i8** %10
%310 = load i32, i32* %28
switch i32 %310, label %313 [
i32 0, label %311
i32 1, label %311
]
311: ; preds = %308, %308
%312 = load i32, i32* %1
ret i32 %312
313: ; preds = %308
unreachable
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [33 x i8] c"./constant/triSurface/hindge.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [54 x i8] c"Error! locations of the hindge point is not specified\00"
@.str.3 = [11 x i8] c"%f %f %f \0A\00"
@.str.4 = [17 x i8] c"%f %f %f \0A %f %f\00"
@.str.5 = [49 x i8] c"The hindge points are (%f %f %f) and (%f %f %f)\0A\00"
@.str.6 = [38 x i8] c"./postProcessing/balance/0/forces.dat\00"
@.str.9 = [53 x i8] c"%f (((%f %f %f) (%f %f %f)) ((%f %f %f) (%f %f %f)))\00"
@.str.10 = [47 x i8] c"Moments about point (0 0 3) are:%f y:%f z:%f \0A\00"
@.str.11 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.13 = [17 x i8] c"%*s %*s %f %f %f\00"
@.str.14 = [32 x i8] c"Error! Invalid Normal Direction\00"
@M_PI = global i32 0
@.str.15 = [38 x i8] c"Flap angle is read in as: %f degree \0A\00"
@.str.16 = [28 x i8] c"./constant/forcedMoment.dat\00"
@.str.19 = [3 x i8] c"%f\00"
@.str.20 = [17 x i8] c"forceBalance.dat\00"
@.str.21 = [2 x i8] c"a\00"
@.str.23 = [7 x i8] c"%f %f\0A\00"
@str = [42 x i8] c"Reading force balance across the flap... \00"
@str.24 = [28 x i8] c"Writing forceBalance.dat...\00"
@str.25 = [39 x i8] c"Error, cannot find forcedMoment.dat!! \00"
@str.26 = [37 x i8] c"Setting additional moment to zero!! \00"
@str.27 = [66 x i8] c"Error! Unable to find flap angle, please check the file location!\00"
@str.28 = [78 x i8] c"Error, unable to find forces.dat, please check your folder name/structure... \00"
define i32 @main() {
%1 = alloca [60 x i8]
%2 = alloca float
%3 = alloca [3 x float]
%4 = alloca [3 x float]
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%14 = load i32, i32* @BUFSIZ
%15 = zext i32 %14 to i64
%16 = tail call i8* @llvm.stacksave()
%17 = alloca i8, i64 %15
%18 = bitcast float* %2 to i8*
%19 = bitcast [3 x float]* %3 to i8*
%20 = bitcast [3 x float]* %4 to i8*
%21 = bitcast [3 x float]* %5 to i8*
%22 = bitcast [3 x float]* %6 to i8*
%23 = bitcast [3 x float]* %7 to i8*
%24 = bitcast [3 x float]* %8 to i8*
%25 = bitcast [3 x float]* %9 to i8*
%26 = bitcast float* %10 to i8*
%27 = bitcast float* %11 to i8*
%28 = bitcast float* %12 to i8*
%29 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %172
33: ; preds = %0
%34 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%35 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%36 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 3
%37 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float* %34, float* %35, float* %36)
%38 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
%39 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 2
%40 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 3
%41 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float* %38, float* %39, float* %40, float* %11, float* %12)
%42 = load float, float* %34
%43 = fpext float %42 to double
%44 = load float, float* %35
%45 = fpext float %44 to double
%46 = load float, float* %36
%47 = fpext float %46 to double
%48 = load float, float* %38
%49 = fpext float %48 to double
%50 = load float, float* %39
%51 = fpext float %50 to double
%52 = load float, float* %40
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), double %43, double %45, double %47, double %49, double %51, double %53)
%55 = call i32 @fclose(i32* %29)
%56 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %60
58: ; preds = %33
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.28, i64 0, i64 0))
br label %172
60: ; preds = %33
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%62 = call i8* @fgets(i8* %13, i32 60, i32* %56)
%63 = call i8* @fgets(i8* %17, i32 %14, i32* %56)
%64 = icmp eq i8* %63, null
br i1 %64, label %96, label %65
65: ; preds = %60
%66 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%67 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
%68 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 3
%69 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%70 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%71 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 3
%72 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%73 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%74 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 3
%75 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%76 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%77 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 3
%78 = bitcast float* %72 to <2 x float>*
%79 = bitcast float* %75 to <2 x float>*
br label %80
80: ; preds = %65, %80
%81 = phi i32 [ 0, %65 ], [ %90, %80 ]
%82 = phi <2 x float> [ undef, %65 ], [ %89, %80 ]
%83 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), float* %2, float* %66, float* %67, float* %68, float* %69, float* %70, float* %71, float* %72, float* %73, float* %74, float* %75, float* %76, float* %77)
%84 = icmp ult i32 %81, 9
%85 = load <2 x float>, <2 x float>* %78
%86 = load <2 x float>, <2 x float>* %79
%87 = fadd <2 x float> %85, %86
%88 = fadd <2 x float> %82, %87
%89 = select i1 %84, <2 x float> zeroinitializer, <2 x float> %88
%90 = add nuw nsw i32 %81, 1
%91 = call i8* @fgets(i8* %17, i32 %14, i32* %56)
%92 = icmp eq i8* %91, null
br i1 %92, label %93, label %80
93: ; preds = %80
%94 = add nsw i32 %81, -8
%95 = sitofp i32 %94 to float
br label %96
96: ; preds = %93, %60
%97 = phi float [ -9.000000e+00, %60 ], [ %95, %93 ]
%98 = phi <2 x float> [ undef, %60 ], [ %89, %93 ]
%99 = extractelement <2 x float> %98, i64 0
%100 = fdiv float %99, %97
%101 = extractelement <2 x float> %98, i64 1
%102 = fdiv float %101, %97
%103 = fpext float %100 to double
%104 = fpext float %102 to double
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0), double %103, double %104, double poison)
%106 = call i32 @fclose(i32* %56)
%107 = call i32* @fopen(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%108 = icmp eq i32* %107, null
br i1 %108, label %109, label %111
109: ; preds = %96
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.27, i64 0, i64 0))
br label %172
111: ; preds = %96
%112 = call i8* @fgets(i8* %17, i32 %14, i32* %107)
%113 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%114 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%115 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 3
%116 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %107, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), float* %113, float* %114, float* %115)
%117 = call i32 @fclose(i32* %107)
%118 = load float, float* %114
%119 = fcmp une float %118, 0.000000e+00
br i1 %119, label %120, label %122
120: ; preds = %111
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
br label %172
122: ; preds = %111
%123 = load float, float* %115
%124 = load float, float* %113
%125 = call float @atan2(float %123, float %124)
%126 = fcmp olt float %125, 0.000000e+00
%127 = load i32, i32* @M_PI
%128 = shl nsw i32 %127, 1
%129 = sitofp i32 %128 to float
%130 = select i1 %126, float %129, float -0.000000e+00
%131 = fadd float %125, %130
%132 = fmul float %131, 1.800000e+02
%133 = sitofp i32 %127 to float
%134 = fdiv float %132, %133
%135 = fadd float %134, -9.000000e+01
%136 = fpext float %135 to double
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0), double %136)
%138 = load i32, i32* @M_PI
%139 = sitofp i32 %138 to float
%140 = fmul float %135, %139
%141 = fdiv float %140, 1.800000e+02
%142 = fcmp oeq float %141, 0xFFF0000000000000
%143 = fcmp oeq float %141, 0x7FF0000000000000
%144 = or i1 %143, %142
br i1 %144, label %145, label %151
145: ; preds = %122
%146 = call float @sin(float %141)
%147 = load i32, i32* @M_PI
%148 = sitofp i32 %147 to float
%149 = fmul float %135, %148
%150 = fdiv float %149, 1.800000e+02
br label %151
151: ; preds = %122, %145
%152 = phi float [ %141, %122 ], [ %150, %145 ]
%153 = fcmp oeq float %152, 0xFFF0000000000000
%154 = fcmp oeq float %152, 0x7FF0000000000000
%155 = or i1 %154, %153
br i1 %155, label %156, label %158
156: ; preds = %151
%157 = call float @cos(float %152)
br label %158
158: ; preds = %151, %156
store float 0.000000e+00, float* %10
%159 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%160 = icmp eq i32* %159, null
br i1 %160, label %161, label %164
161: ; preds = %158
%162 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.25, i64 0, i64 0))
%163 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
store float 0.000000e+00, float* %10
br label %167
164: ; preds = %158
%165 = call i32 (i32*, i8*, float*, ...) @fscanf(i32* %159, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), float* %10)
%166 = call i32 @fclose(i32* %159)
br label %167
167: ; preds = %164, %161
%168 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0))
%169 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.24, i64 0, i64 0))
%170 = call i32 @fprintf(i32* %168, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0), float %135, float poison)
%171 = call i32 @fclose(i32* %168)
br label %172
172: ; preds = %167, %120, %109, %58, %31
%173 = phi i32 [ 1, %31 ], [ 1, %58 ], [ 1, %109 ], [ 1, %120 ], [ 0, %167 ]
ret i32 %173
}