#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;
float M_PI;
float atanf(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 *, float *,
                          float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *, float *, float *,
                          float *, float *, float *, float *, float *, float *,
                          float *, float *, float *);
int main() {
  FILE *input;
  FILE *plane;
  FILE *output;
  int i;
  char C[60];
  char *brac;
  char buff[BUFSIZ];
  float time, angle;
  float pf[3], vf[3], pm[3], vm[3];
  float forceSum[3], normal[3], momentSum[3];
  forceSum[1] = 0.0;
  forceSum[2] = 0.0;
  forceSum[3] = 0.0;
  input = fopen("./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 == 0) {
        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++;
    }
    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 = atanf(normal[3] / normal[1]);
        if (angle < 0)
          angle = (angle + M_PI) * 180 / M_PI - 90;
        else
          angle = angle * 180 / M_PI - 90;
        printf("Flap angle is read in as: %f degree \n", angle);
      }
    }
    output = fopen("forceBalance.dat", "a");
    printf("Writing forceBalance.dat...\n");
    fprintf(output, "%f %f\n", angle, momentSum[2]);
    fclose(output);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
movl   $0x0,-0x2c(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x118(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x110(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xa8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe8(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe4(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe0(%rbp)
ff
lea    0xe09(%rip),%rdi
lea    0xe19(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    123e <main+0xbe>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x108(%rbp)
jmp    1759 <main+0x5d9>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x3c,%esi
call   1070 <fgets@plt>
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rax
mov    %eax,%esi
mov    -0x38(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1491 <main+0x311>
mov    -0x110(%rbp),%rdi
lea    -0xbc(%rbp),%rcx
add    $0x4,%rcx
lea    -0xbc(%rbp),%r8
add    $0x8,%r8
lea    -0xbc(%rbp),%r9
add    $0xc,%r9
lea    -0xc8(%rbp),%rax
add    $0x4,%rax
lea    -0xc8(%rbp),%r13
add    $0x8,%r13
lea    -0xc8(%rbp),%r12
add    $0xc,%r12
lea    -0xd4(%rbp),%r15
add    $0x4,%r15
lea    -0xd4(%rbp),%r14
add    $0x8,%r14
lea    -0xd4(%rbp),%rbx
add    $0xc,%rbx
lea    -0xe0(%rbp),%r11
add    $0x4,%r11
lea    -0xe0(%rbp),%r10
add    $0x8,%r10
lea    -0xe0(%rbp),%rdx
add    $0xc,%rdx
mov    %rdx,-0x120(%rbp)
lea    0xd70(%rip),%rsi
lea    -0xac(%rbp),%rdx
sub    $0x50,%rsp
mov    %rax,(%rsp)
mov    -0x120(%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   1090 <sscanf@plt>
add    $0x50,%rsp
cmpl   $0x0,-0x4c(%rbp)
jne    13c3 <main+0x243>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe8(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe4(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xe0(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x100(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xfc(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xf8(%rbp)
ff
jmp    1483 <main+0x303>
movss  -0xb8(%rbp),%xmm0
ff
addss  -0xc4(%rbp),%xmm0
ff
addss  -0xe8(%rbp),%xmm0
ff
movss  %xmm0,-0xe8(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
addss  -0xc0(%rbp),%xmm0
ff
addss  -0xe4(%rbp),%xmm0
ff
movss  %xmm0,-0xe4(%rbp)
ff
movss  -0xb0(%rbp),%xmm0
ff
addss  -0xbc(%rbp),%xmm0
ff
addss  -0xe0(%rbp),%xmm0
ff
movss  %xmm0,-0xe0(%rbp)
ff
movss  -0xd0(%rbp),%xmm0
ff
addss  -0xdc(%rbp),%xmm0
ff
addss  -0x100(%rbp),%xmm0
ff
movss  %xmm0,-0x100(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
addss  -0xd8(%rbp),%xmm0
ff
addss  -0xfc(%rbp),%xmm0
ff
movss  %xmm0,-0xfc(%rbp)
ff
movss  -0xc8(%rbp),%xmm0
ff
addss  -0xd4(%rbp),%xmm0
ff
addss  -0xf8(%rbp),%xmm0
ff
movss  %xmm0,-0xf8(%rbp)
ff
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    126f <main+0xef>
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0xe8(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xe8(%rbp)
ff
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0xe4(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xe4(%rbp)
ff
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0xe0(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xe0(%rbp)
ff
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0x100(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x100(%rbp)
ff
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0xfc(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xfc(%rbp)
ff
cvtsi2ssl -0x4c(%rbp),%xmm1
movss  -0xf8(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xf8(%rbp)
ff
movss  -0x100(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0xfc(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0xf8(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    0xb7e(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xb96(%rip),%rdi
lea    0xaaf(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    15a8 <main+0x428>
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x108(%rbp)
jmp    1759 <main+0x5d9>
mov    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rax
mov    %eax,%esi
mov    -0x40(%rbp),%rdx
call   1070 <fgets@plt>
mov    -0x40(%rbp),%rdi
lea    -0xf8(%rbp),%rdx
add    $0x4,%rdx
lea    -0xf8(%rbp),%rcx
add    $0x8,%rcx
lea    -0xf8(%rbp),%r8
add    $0xc,%r8
lea    0xb74(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
movss  -0xf0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    161f <main+0x49f>
jp     161f <main+0x49f>
jmp    1643 <main+0x4c3>
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x108(%rbp)
jmp    1759 <main+0x5d9>
movss  -0xec(%rbp),%xmm0
ff
divss  -0xf4(%rbp),%xmm0
ff
call   1040 <atanf@plt>
movss  %xmm0,-0xb0(%rbp)
ff
xorps  %xmm0,%xmm0
ucomiss -0xb0(%rbp),%xmm0
jbe    16b3 <main+0x533>
movss  -0xb0(%rbp),%xmm0
ff
mov    0x2969(%rip),%rax
addss  (%rax),%xmm0
movss  0x979(%rip),%xmm1
mulss  %xmm1,%xmm0
mov    0x2952(%rip),%rax
divss  (%rax),%xmm0
movss  0x95e(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xb0(%rbp)
ff
jmp    16e2 <main+0x562>
movss  0x949(%rip),%xmm0
mulss  -0xb0(%rbp),%xmm0
ff
mov    0x291e(%rip),%rax
divss  (%rax),%xmm0
movss  0x92a(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xb0(%rbp)
ff
movss  -0xb0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xa9d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1701 <main+0x581>
lea    0xab0(%rip),%rdi
lea    0xaba(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
lea    0xaac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rdi
movss  -0xb0(%rbp),%xmm0
ff
movss  -0xfc(%rbp),%xmm1
ff
lea    0xaa7(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x108(%rbp)
mov    -0xa0(%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    $0x98,%rsp
mov    %rsp,%r14
mov    0x2e2a(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%rbx
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe46(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1335 <main+0x1a5>
mov    %rax,%r15
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    -0xc0(%rbp),%rdi
mov    $0x3c,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1341 <main+0x1b1>
mov    %r14,-0x30(%rbp)
lea    -0x68(%rbp),%rcx
lea    -0x64(%rbp),%r8
lea    -0x60(%rbp),%r9
lea    -0x40(%rbp),%r14
lea    -0x3c(%rbp),%r10
lea    -0x38(%rbp),%r11
lea    -0x34(%rbp),%rax
lea    -0x30(%rbp),%r13
sub    $0x8,%rsp
lea    0xde1(%rip),%rsi
lea    -0x70(%rbp),%rdx
mov    %rbx,%rdi
push   %r13
push   %rax
push   %r11
push   %r10
push   %r14
lea    -0x44(%rbp),%rax
push   %rax
lea    -0x54(%rbp),%rax
push   %rax
lea    -0x58(%rbp),%rax
push   %rax
lea    -0x5c(%rbp),%rax
push   %rax
call   10a0 <sscanf@plt>
add    $0x50,%rsp
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1346 <main+0x1b6>
xorps  %xmm0,%xmm0
movaps %xmm0,-0x80(%rbp)
mov    $0x1,%r14d
mov    %r15,%r13
lea    -0x30(%rbp),%r15
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0xd7b(%rip),%rsi
lea    -0x70(%rbp),%rdx
lea    -0x68(%rbp),%rcx
lea    -0x64(%rbp),%r8
lea    -0x60(%rbp),%r9
push   %r15
lea    -0x34(%rbp),%rax
push   %rax
lea    -0x38(%rbp),%rax
push   %rax
lea    -0x3c(%rbp),%rax
push   %rax
lea    -0x40(%rbp),%rax
push   %rax
lea    -0x44(%rbp),%rax
push   %rax
lea    -0x54(%rbp),%rax
push   %rax
lea    -0x58(%rbp),%rax
push   %rax
lea    -0x5c(%rbp),%rax
push   %rax
call   10a0 <sscanf@plt>
add    $0x50,%rsp
movsd  -0x44(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
addps  %xmm0,%xmm1
movaps -0x80(%rbp),%xmm0
addps  %xmm1,%xmm0
movaps %xmm0,-0x80(%rbp)
add    $0x1,%r14d
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    12a0 <main+0x110>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
mov    -0x30(%rbp),%r14
movaps -0x80(%rbp),%xmm2
mov    %r13,%r15
jmp    1355 <main+0x1c5>
lea    0xe69(%rip),%rdi
jmp    13fe <main+0x26e>
xorps  %xmm0,%xmm0
jmp    1355 <main+0x1c5>
xorps  %xmm2,%xmm2
movss  0xcaf(%rip),%xmm0
mov    -0x30(%rbp),%r14
movaps %xmm2,%xmm1
divss  %xmm0,%xmm1
shufps $0x55,%xmm2,%xmm2
divss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movaps %xmm2,-0x80(%rbp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xce1(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xcfa(%rip),%rdi
lea    0xc8d(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f7 <main+0x267>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
lea    -0x50(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
lea    -0x48(%rbp),%r8
lea    0xce4(%rip),%rsi
mov    %r15,%rdi
call   1070 <fscanf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
movss  -0x4c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    13e7 <main+0x257>
jnp    141a <main+0x28a>
lea    0xccf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1403 <main+0x273>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
mov    %r14,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movss  -0x48(%rbp),%xmm0
divss  -0x50(%rbp),%xmm0
call   1050 <atanf@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    144e <main+0x2be>
mov    0x2bb0(%rip),%rax
movss  (%rax),%xmm1
addss  %xmm1,%xmm0
mulss  0xbbc(%rip),%xmm0
divss  %xmm1,%xmm0
jmp    1461 <main+0x2d1>
mulss  0xbae(%rip),%xmm0
mov    0x2b8b(%rip),%rax
divss  (%rax),%xmm0
addss  0xb9f(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
cvtss2sd %xmm0,%xmm0
lea    0xc64(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xc7c(%rip),%rdi
lea    0xc86(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0xcaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xc6d(%rip),%rsi
mov    %rbx,%rdi
movss  -0x30(%rbp),%xmm0
movaps -0x80(%rbp),%xmm1
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1408 <main+0x278>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [23 x i8] c"./balance/0/forces.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [79 x i8] c"Error, unable to find forces.dat, please check your folder name/structure... \0A\00"
@.str.3 = [43 x i8] c"Reading force balance across the flap... \0A\00"
@.str.4 = [53 x i8] c"%f (((%f %f %f) (%f %f %f)) ((%f %f %f) (%f %f %f)))\00"
@.str.5 = [47 x i8] c"Moments about point (0 0 3) are:%f y:%f z:%f \0A\00"
@.str.6 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.7 = [67 x i8] c"Error! Unable to find flap angle, please check the file location!\0A\00"
@.str.8 = [17 x i8] c"%*s %*s %f %f %f\00"
@.str.9 = [32 x i8] c"Error! Invalid Normal Direction\00"
@M_PI = global float 0.000000e+00
@.str.10 = [38 x i8] c"Flap angle is read in as: %f degree \0A\00"
@.str.11 = [17 x i8] c"forceBalance.dat\00"
@.str.12 = [2 x i8] c"a\00"
@.str.13 = [29 x i8] c"Writing forceBalance.dat...\0A\00"
@.str.14 = [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 [60 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca float
%11 = alloca float
%12 = alloca [3 x float]
%13 = alloca [3 x 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 i32
store i32 0, i32* %1
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %8
%23 = alloca i8, i64 %21
store i64 %21, i64* %9
%24 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
store float 0.000000e+00, float* %24
%25 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
store float 0.000000e+00, float* %25
%26 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
store float 0.000000e+00, float* %26
%27 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %2
%28 = load i32*, i32** %2
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %19
br label %221
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%34 = getelementptr inbounds [60 x i8], [60 x i8]* %6, i64 0, i64 0
%35 = load i32*, i32** %2
%36 = call i8* @fgets(i8* %34, i32 60, i32* %35)
store i8* %36, i8** %7
store i32 0, i32* %5
br label %37
37: ; preds = %114, %32
%38 = trunc i64 %21 to i32
%39 = load i32*, i32** %2
%40 = call i8* @fgets(i8* %23, i32 %38, i32* %39)
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %117
42: ; preds = %37
%43 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%44 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%45 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%46 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%47 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%48 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%49 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%50 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%51 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%52 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%53 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%54 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%55 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), float* %10, float* %43, float* %44, float* %45, float* %46, float* %47, float* %48, float* %49, float* %50, float* %51, float* %52, float* %53, float* %54)
%56 = load i32, i32* %5
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %42
%59 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
store float 0.000000e+00, float* %59
%60 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
store float 0.000000e+00, float* %60
%61 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
store float 0.000000e+00, float* %61
%62 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
store float 0.000000e+00, float* %62
%63 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
store float 0.000000e+00, float* %63
%64 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
store float 0.000000e+00, float* %64
br label %114
65: ; preds = %42
%66 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%67 = load float, float* %66
%68 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%69 = load float, float* %68
%70 = fadd float %67, %69
%71 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%72 = load float, float* %71
%73 = fadd float %72, %70
store float %73, float* %71
%74 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%75 = load float, float* %74
%76 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%77 = load float, float* %76
%78 = fadd float %75, %77
%79 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%80 = load float, float* %79
%81 = fadd float %80, %78
store float %81, float* %79
%82 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%83 = load float, float* %82
%84 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%85 = load float, float* %84
%86 = fadd float %83, %85
%87 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
%88 = load float, float* %87
%89 = fadd float %88, %86
store float %89, float* %87
%90 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%91 = load float, float* %90
%92 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%93 = load float, float* %92
%94 = fadd float %91, %93
%95 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
%96 = load float, float* %95
%97 = fadd float %96, %94
store float %97, float* %95
%98 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%99 = load float, float* %98
%100 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%101 = load float, float* %100
%102 = fadd float %99, %101
%103 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%104 = load float, float* %103
%105 = fadd float %104, %102
store float %105, float* %103
%106 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%107 = load float, float* %106
%108 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%109 = load float, float* %108
%110 = fadd float %107, %109
%111 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
%112 = load float, float* %111
%113 = fadd float %112, %110
store float %113, float* %111
br label %114
114: ; preds = %65, %58
%115 = load i32, i32* %5
%116 = add nsw i32 %115, 1
store i32 %116, i32* %5
br label %37
117: ; preds = %37
%118 = load i32, i32* %5
%119 = sitofp i32 %118 to float
%120 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%121 = load float, float* %120
%122 = fdiv float %121, %119
store float %122, float* %120
%123 = load i32, i32* %5
%124 = sitofp i32 %123 to float
%125 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%126 = load float, float* %125
%127 = fdiv float %126, %124
store float %127, float* %125
%128 = load i32, i32* %5
%129 = sitofp i32 %128 to float
%130 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
%131 = load float, float* %130
%132 = fdiv float %131, %129
store float %132, float* %130
%133 = load i32, i32* %5
%134 = sitofp i32 %133 to float
%135 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
%136 = load float, float* %135
%137 = fdiv float %136, %134
store float %137, float* %135
%138 = load i32, i32* %5
%139 = sitofp i32 %138 to float
%140 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%141 = load float, float* %140
%142 = fdiv float %141, %139
store float %142, float* %140
%143 = load i32, i32* %5
%144 = sitofp i32 %143 to float
%145 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
%146 = load float, float* %145
%147 = fdiv float %146, %144
store float %147, float* %145
%148 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 1
%149 = load float, float* %148
%150 = fpext float %149 to double
%151 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%152 = load float, float* %151
%153 = fpext float %152 to double
%154 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 3
%155 = load float, float* %154
%156 = fpext float %155 to double
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), double %150, double %153, double %156)
%158 = load i32*, i32** %2
%159 = call i32 @fclose(i32* %158)
%160 = call i32* @fopen(i8* getelementptr inbounds ([31 x i8], [31 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* %160, i32** %3
%161 = load i32*, i32** %3
%162 = icmp eq i32* %161, null
br i1 %162, label %163, label %165
163: ; preds = %117
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %19
br label %221
165: ; preds = %117
%166 = trunc i64 %21 to i32
%167 = load i32*, i32** %3
%168 = call i8* @fgets(i8* %23, i32 %166, i32* %167)
%169 = load i32*, i32** %3
%170 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 1
%171 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 2
%172 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 3
%173 = call i32 @fscanf(i32* %169, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), float* %170, float* %171, float* %172)
%174 = load i32*, i32** %3
%175 = call i32 @fclose(i32* %174)
%176 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 2
%177 = load float, float* %176
%178 = fpext float %177 to double
%179 = fcmp une double %178, 0.000000e+00
br i1 %179, label %180, label %182
180: ; preds = %165
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %19
br label %221
182: ; preds = %165
%183 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 3
%184 = load float, float* %183
%185 = getelementptr inbounds [3 x float], [3 x float]* %17, i64 0, i64 1
%186 = load float, float* %185
%187 = fdiv float %184, %186
%188 = call float @atanf(float %187)
store float %188, float* %11
%189 = load float, float* %11
%190 = fcmp olt float %189, 0.000000e+00
br i1 %190, label %191, label %199
191: ; preds = %182
%192 = load float, float* %11
%193 = load float, float* @M_PI
%194 = fadd float %192, %193
%195 = fmul float %194, 1.800000e+02
%196 = load float, float* @M_PI
%197 = fdiv float %195, %196
%198 = fsub float %197, 9.000000e+01
store float %198, float* %11
br label %205
199: ; preds = %182
%200 = load float, float* %11
%201 = fmul float %200, 1.800000e+02
%202 = load float, float* @M_PI
%203 = fdiv float %201, %202
%204 = fsub float %203, 9.000000e+01
store float %204, float* %11
br label %205
205: ; preds = %199, %191
%206 = load float, float* %11
%207 = fpext float %206 to double
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), double %207)
br label %209
209: ; preds = %205
br label %210
210: ; preds = %209
%211 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32* %211, i32** %4
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%213 = load i32*, i32** %4
%214 = load float, float* %11
%215 = getelementptr inbounds [3 x float], [3 x float]* %18, i64 0, i64 2
%216 = load float, float* %215
%217 = call i32 @fprintf(i32* %213, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), float %214, float %216)
%218 = load i32*, i32** %4
%219 = call i32 @fclose(i32* %218)
br label %220
220: ; preds = %210
store i32 0, i32* %19
br label %221
221: ; preds = %220, %180, %163, %30
%222 = load i8*, i8** %8
%223 = load i32, i32* %19
switch i32 %223, label %226 [
i32 0, label %224
i32 1, label %224
]
224: ; preds = %221, %221
%225 = load i32, i32* %1
ret i32 %225
226: ; preds = %221
unreachable
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [23 x i8] c"./balance/0/forces.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [53 x i8] c"%f (((%f %f %f) (%f %f %f)) ((%f %f %f) (%f %f %f)))\00"
@.str.5 = [47 x i8] c"Moments about point (0 0 3) are:%f y:%f z:%f \0A\00"
@.str.6 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.8 = [17 x i8] c"%*s %*s %f %f %f\00"
@.str.9 = [32 x i8] c"Error! Invalid Normal Direction\00"
@M_PI = global float 0.000000e+00
@.str.10 = [38 x i8] c"Flap angle is read in as: %f degree \0A\00"
@.str.11 = [17 x i8] c"forceBalance.dat\00"
@.str.12 = [2 x i8] c"a\00"
@.str.14 = [7 x i8] c"%f %f\0A\00"
@str = [42 x i8] c"Reading force balance across the flap... \00"
@str.15 = [28 x i8] c"Writing forceBalance.dat...\00"
@str.16 = [66 x i8] c"Error! Unable to find flap angle, please check the file location!\00"
@str.17 = [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 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%9 = load i32, i32* @BUFSIZ
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = bitcast float* %2 to i8*
%14 = bitcast [3 x float]* %3 to i8*
%15 = bitcast [3 x float]* %4 to i8*
%16 = bitcast [3 x float]* %5 to i8*
%17 = bitcast [3 x float]* %6 to i8*
%18 = bitcast [3 x float]* %7 to i8*
%19 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.17, i64 0, i64 0))
br label %110
23: ; preds = %0
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%25 = call i8* @fgets(i8* %8, i32 60, i32* %19)
%26 = call i8* @fgets(i8* %12, i32 %9, i32* %19)
%27 = icmp eq i8* %26, null
br i1 %27, label %60, label %28
28: ; preds = %23
%29 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%30 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
%31 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 3
%32 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%33 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%34 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 3
%35 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%36 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%37 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 3
%38 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%39 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%40 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 3
%41 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), float* %2, float* %29, float* %30, float* %31, float* %32, float* %33, float* %34, float* %35, float* %36, float* %37, float* %38, float* %39, float* %40)
%42 = call i8* @fgets(i8* %12, i32 %9, i32* %19)
%43 = icmp eq i8* %42, null
br i1 %43, label %60, label %44
44: ; preds = %28
%45 = bitcast float* %35 to <2 x float>*
%46 = bitcast float* %38 to <2 x float>*
br label %47
47: ; preds = %44, %47
%48 = phi i32 [ %55, %47 ], [ 1, %44 ]
%49 = phi <2 x float> [ %54, %47 ], [ zeroinitializer, %44 ]
%50 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), float* %2, float* %29, float* %30, float* %31, float* %32, float* %33, float* %34, float* %35, float* %36, float* %37, float* %38, float* %39, float* %40)
%51 = load <2 x float>, <2 x float>* %45
%52 = load <2 x float>, <2 x float>* %46
%53 = fadd <2 x float> %51, %52
%54 = fadd <2 x float> %49, %53
%55 = add nuw nsw i32 %48, 1
%56 = call i8* @fgets(i8* %12, i32 %9, i32* %19)
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %47
58: ; preds = %47
%59 = sitofp i32 %55 to float
br label %60
60: ; preds = %58, %28, %23
%61 = phi float [ 0.000000e+00, %23 ], [ 1.000000e+00, %28 ], [ %59, %58 ]
%62 = phi <2 x float> [ undef, %23 ], [ zeroinitializer, %28 ], [ %54, %58 ]
%63 = extractelement <2 x float> %62, i64 0
%64 = fdiv float %63, %61
%65 = extractelement <2 x float> %62, i64 1
%66 = fdiv float %65, %61
%67 = fpext float %64 to double
%68 = fpext float %66 to double
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), double %67, double %68, double poison)
%70 = call i32 @fclose(i32* %19)
%71 = call i32* @fopen(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %75
73: ; preds = %60
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.16, i64 0, i64 0))
br label %110
75: ; preds = %60
%76 = call i8* @fgets(i8* %12, i32 %9, i32* %71)
%77 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%78 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%79 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 3
%80 = call i32 @fscanf(i32* %71, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), float* %77, float* %78, float* %79)
%81 = call i32 @fclose(i32* %71)
%82 = load float, float* %78
%83 = fcmp une float %82, 0.000000e+00
br i1 %83, label %84, label %86
84: ; preds = %75
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %110
86: ; preds = %75
%87 = load float, float* %79
%88 = load float, float* %77
%89 = fdiv float %87, %88
%90 = call float @atanf(float %89)
%91 = fcmp olt float %90, 0.000000e+00
br i1 %91, label %92, label %97
92: ; preds = %86
%93 = load float, float* @M_PI
%94 = fadd float %90, %93
%95 = fmul float %94, 1.800000e+02
%96 = fdiv float %95, %93
br label %101
97: ; preds = %86
%98 = fmul float %90, 1.800000e+02
%99 = load float, float* @M_PI
%100 = fdiv float %98, %99
br label %101
101: ; preds = %97, %92
%102 = phi float [ %96, %92 ], [ %100, %97 ]
%103 = fadd float %102, -9.000000e+01
%104 = fpext float %103 to double
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), double %104)
%106 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.15, i64 0, i64 0))
%108 = call i32 @fprintf(i32* %106, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), float %103, float %66)
%109 = call i32 @fclose(i32* %106)
br label %110
110: ; preds = %101, %84, %73, %21
%111 = phi i32 [ 1, %21 ], [ 1, %73 ], [ 1, %84 ], [ 0, %101 ]
ret i32 %111
}