#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;
double cosf(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *, float *,
                          float *, ...);
int /*<<< orphan*/ printf(char *, ...);
double sinf(int);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *);
int main() {
  FILE *input;
  FILE *output;
  FILE *hindge;
  FILE *stl;
  char buff[BUFSIZ];
  char buff2[BUFSIZ];
  char loop_type[10];
  int i;
  float normal[3], p1[3], p2[3], p3[3], p4[3], tmp1[3], tmp2[3], tmp3[3],
      moment_1, moment_2;
  float angle_read, angle_1, angle_2, angle_optimized, length, surf_ang;
  p3[2] = 0;
  p4[2] = 0;
  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);
  }
  input = fopen("./forceBalance.dat", "r");
  if (input == NULL) {
    printf("Error! Unable to locate forceBalance.dat");
    return 1;
  } else {
    i = 0;
    while (fgets(buff, sizeof buff, input) != NULL) {
      if (i < 1) {
        sscanf(buff, "%f %f \n", &angle_1, &moment_1);
        angle_optimized = angle_1 + 10;
        printf("%f\n", angle_1);
      } else {
        angle_2 = angle_1;
        moment_2 = moment_1;
        sscanf(buff, "%f %f \n", &angle_1, &moment_1);
        angle_optimized =
            angle_1 - (angle_1 - angle_2) / (moment_1 - moment_2) * moment_1;
      }
      i++;
    }
    if (angle_optimized <= surf_ang + 5)
      angle_optimized = surf_ang + 5;
    if (angle_optimized >= surf_ang + 180)
      angle_optimized = surf_ang + 175;
    printf("angle_optimized is %f degree\n", angle_optimized);
  }
  p3[1] = p1[1] + length * cosf(angle_optimized * M_PI / 180);
  p3[2] = p1[2];
  p3[3] = p1[3] + length * sinf(angle_optimized * M_PI / 180);
  p4[1] = p3[1];
  p4[2] = p2[2];
  p4[3] = p3[3];
  fclose(input);
  output = fopen("./constant/triSurface/flap.stl", "w");
  fprintf(output, "solid flap\n");
  fprintf(output, "\t facet normal %f 0.0 %f\n",
          cosf((90 + angle_optimized) * M_PI / 180),
          sinf((90 + angle_optimized) * M_PI / 180));
  fprintf(output, "\t\t outer loop\n");
  fprintf(output, "\t\t\t vertex %f %f %f\n", p1[1], p1[2], p1[3]);
  fprintf(output, "\t\t\t vertex %f %f %f\n", p2[1], p2[2], p2[3]);
  fprintf(output, "\t\t\t vertex %f %f %f\n", p3[1], p3[2], p3[3]);
  fprintf(output, "\t\t endloop\n\t endfacet\n");
  fprintf(output, "\t facet normal %f 0.0 %f\n",
          cosf((90 + angle_optimized) * M_PI / 180),
          sinf((90 + angle_optimized) * M_PI / 180));
  fprintf(output, "\t\t outer loop\n");
  fprintf(output, "\t\t\t vertex %f %f %f\n", p4[1], p4[2], p4[3]);
  fprintf(output, "\t\t\t vertex %f %f %f\n", p2[1], p2[2], p2[3]);
  fprintf(output, "\t\t\t vertex %f %f %f\n", p3[1], p3[2], p3[3]);
  fprintf(output, "\t\t endloop\n\t endfacet\n");
  fprintf(output, "endsolid flap");
  fclose(output);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xe8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xe0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x84(%rbp)
ff
lea    0xe15(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123e <main+0xae>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
jmp    18e0 <main+0x750>
mov    -0x20(%rbp),%rdi
lea    -0x68(%rbp),%rdx
add    $0x4,%rdx
lea    -0x68(%rbp),%rcx
add    $0x8,%rcx
lea    -0x68(%rbp),%r8
add    $0xc,%r8
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x74(%rbp),%rdx
add    $0x4,%rdx
lea    -0x74(%rbp),%rcx
add    $0x8,%rcx
lea    -0x74(%rbp),%r8
add    $0xc,%r8
lea    0xded(%rip),%rsi
lea    -0xd0(%rbp),%r9
lea    -0xcc(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <fscanf@plt>
add    $0x10,%rsp
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x60(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x5c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x70(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x6c(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x68(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xda0(%rip),%rdi
mov    $0x6,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdba(%rip),%rdi
lea    0xd2e(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    133f <main+0x1af>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
jmp    18e0 <main+0x750>
movl   $0x0,-0x50(%rbp)
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     146b <main+0x2db>
cmpl   $0x1,-0x50(%rbp)
jge    13cb <main+0x23b>
mov    -0xe0(%rbp),%rdi
lea    0xcef(%rip),%rsi
lea    -0xc0(%rbp),%rdx
lea    -0xb4(%rbp),%rcx
call   10a0 <sscanf@plt>
movss  0xc74(%rip),%xmm0
addss  -0xc0(%rbp),%xmm0
ff
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    145d <main+0x2cd>
mov    -0xe0(%rbp),%rdi
movss  -0xc0(%rbp),%xmm0
ff
movss  %xmm0,-0xc4(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
movss  %xmm0,-0xb8(%rbp)
ff
lea    0xc77(%rip),%rsi
lea    -0xc0(%rbp),%rdx
lea    -0xb4(%rbp),%rcx
call   10a0 <sscanf@plt>
movss  -0xc0(%rbp),%xmm1
ff
movss  -0xc0(%rbp),%xmm0
ff
subss  -0xc4(%rbp),%xmm0
ff
movss  -0xb4(%rbp),%xmm2
ff
subss  -0xb8(%rbp),%xmm2
ff
divss  %xmm2,%xmm0
movss  -0xb4(%rbp),%xmm2
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc8(%rbp)
ff
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1346 <main+0x1b6>
movss  -0xc8(%rbp),%xmm1
ff
movss  0xb85(%rip),%xmm0
addss  -0xd0(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jb     14a4 <main+0x314>
movss  0xb6c(%rip),%xmm0
addss  -0xd0(%rbp),%xmm0
ff
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xc8(%rbp),%xmm0
ff
movss  0xb50(%rip),%xmm1
addss  -0xd0(%rbp),%xmm1
ff
ucomiss %xmm1,%xmm0
jb     14dd <main+0x34d>
movss  0xb3b(%rip),%xmm0
addss  -0xd0(%rbp),%xmm0
ff
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xc8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xc06(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x128(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x120(%rbp)
ff
movss  -0xc8(%rbp),%xmm0
ff
mov    0x2abd(%rip),%rax
mulss  (%rax),%xmm0
movss  0xacd(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  -0x128(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x120(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0x60(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movss  -0xc8(%rbp),%xmm0
ff
mov    0x2a42(%rip),%rax
mulss  (%rax),%xmm0
movss  0xa52(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
movsd  -0x118(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x110(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x74(%rbp)
movss  -0x7c(%rbp),%xmm0
movss  %xmm0,-0x88(%rbp)
ff
movss  -0x6c(%rbp),%xmm0
movss  %xmm0,-0x84(%rbp)
ff
movss  -0x74(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xafd(%rip),%rdi
lea    0xb15(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xb03(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x108(%rbp)
movss  0x9c0(%rip),%xmm0
addss  -0xc8(%rbp),%xmm0
ff
mov    0x298d(%rip),%rax
mulss  (%rax),%xmm0
movss  0x99d(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0x100(%rbp)
ff
movss  0x988(%rip),%xmm0
addss  -0xc8(%rbp),%xmm0
ff
mov    0x2955(%rip),%rax
mulss  (%rax),%xmm0
movss  0x965(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
mov    -0x108(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x100(%rbp),%xmm0
ff
lea    0xa7c(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xa84(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x60(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x5c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xa66(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x70(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x6c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x68(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xa39(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x7c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x78(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x74(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xa0c(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xa0f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xf8(%rbp)
movss  0x882(%rip),%xmm0
addss  -0xc8(%rbp),%xmm0
ff
mov    0x284f(%rip),%rax
mulss  (%rax),%xmm0
movss  0x85f(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movss  0x84a(%rip),%xmm0
addss  -0xc8(%rbp),%xmm0
ff
mov    0x2817(%rip),%rax
mulss  (%rax),%xmm0
movss  0x827(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
mov    -0xf8(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0xf0(%rbp),%xmm0
ff
lea    0x93e(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x946(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0x84(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0x80(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x922(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x70(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x6c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x68(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x8f5(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x7c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x78(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x74(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x8c8(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x8cb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x8d0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0xd4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2e20(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe41(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1386 <main+0x1e6>
mov    %rax,%r14
lea    -0x50(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
lea    -0x48(%rbp),%r8
lea    0xe6f(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    -0x40(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x38(%rbp),%r8
sub    $0x8,%rsp
lea    -0x88(%rbp),%r10
lea    0xe52(%rip),%rsi
lea    -0x84(%rbp),%r9
mov    %r14,%rdi
xor    %eax,%eax
push   %r10
call   1070 <fscanf@plt>
add    $0x10,%rsp
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x48(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x40(%rbp),%xmm3
movss  -0x3c(%rbp),%xmm4
cvtss2sd %xmm3,%xmm3
cvtss2sd %xmm4,%xmm4
movss  -0x38(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xe0f(%rip),%rdi
mov    $0x6,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xe2a(%rip),%rdi
lea    0xd9e(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     138f <main+0x1ef>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13a7 <main+0x207>
lea    0xdaa(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x48(%rbp),%rcx
mov    %rbx,%rdi
call   10a0 <sscanf@plt>
movss  -0x2c(%rbp),%xmm0
movaps %xmm0,-0x70(%rbp)
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13a9 <main+0x209>
lea    -0x2c(%rbp),%r13
lea    -0x48(%rbp),%r12
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    %rbx,%rdi
lea    0xd42(%rip),%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   10a0 <sscanf@plt>
movss  -0x2c(%rbp),%xmm0
movaps %xmm0,-0x70(%rbp)
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1310 <main+0x170>
movaps -0x70(%rbp),%xmm3
movaps %xmm3,%xmm0
subss  -0x80(%rbp),%xmm0
movss  -0x78(%rbp),%xmm2
movaps %xmm2,%xmm1
subss  -0x38(%rbp),%xmm1
divss  %xmm1,%xmm0
mulss  %xmm2,%xmm0
subss  %xmm0,%xmm3
jmp    13b5 <main+0x215>
lea    0xcaa(%rip),%rdi
jmp    1396 <main+0x1f6>
lea    0xd37(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    16f8 <main+0x558>
jmp    13b5 <main+0x215>
movaps -0x70(%rbp),%xmm3
addss  0xc4b(%rip),%xmm3
movss  -0x84(%rbp),%xmm0
ff
movss  0xc3f(%rip),%xmm1
addss  %xmm0,%xmm1
movaps %xmm3,%xmm2
cmpless %xmm1,%xmm2
andps  %xmm2,%xmm1
andnps %xmm3,%xmm2
orps   %xmm1,%xmm2
movaps %xmm0,%xmm3
addss  0xc23(%rip),%xmm3
addss  0xc1f(%rip),%xmm0
cmpnless %xmm2,%xmm3
movaps %xmm3,%xmm1
andps  %xmm2,%xmm1
andnps %xmm0,%xmm3
orps   %xmm1,%xmm3
movaps %xmm3,-0x70(%rbp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xce6(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  -0x50(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    0x2bab(%rip),%r15
movss  (%r15),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0xbb9(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
mulsd  -0x80(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movss  (%r15),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0xb81(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xc6b(%rip),%rdi
lea    0xc83(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0xc76(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
movaps -0x70(%rbp),%xmm1
addss  0xb33(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
movss  (%r15),%xmm0
mulss  %xmm1,%xmm0
divss  0xb16(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movss  (%r15),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0xaf3(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
lea    0xc19(%rip),%rsi
mov    %rbx,%rdi
movsd  -0x90(%rbp),%xmm0
ff
mov    $0x2,%al
call   1090 <fprintf@plt>
lea    0xc1a(%rip),%r12
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x48(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xbf2(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x40(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x38(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x38(%rbp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,-0x38(%rbp)
movss  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,-0x78(%rbp)
mov    %rbx,%rdi
mov    %r14,%rsi
movaps %xmm2,%xmm0
mov    $0x3,%al
call   1090 <fprintf@plt>
lea    0xb99(%rip),%r13
mov    $0x16,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  (%r15),%xmm0
mulss  -0x70(%rbp),%xmm0
divss  0x9fb(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movaps -0x70(%rbp),%xmm1
mulss  (%r15),%xmm1
movsd  %xmm0,-0x70(%rbp)
divss  0x9dc(%rip),%xmm1
cvttss2si %xmm1,%edi
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
lea    0xaff(%rip),%rsi
movsd  -0x70(%rbp),%xmm0
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  -0x80(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  -0x38(%rbp),%xmm0
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x40(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x38(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  -0x38(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    $0x16,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
lea    0xaba(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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 = [19 x i8] c"./forceBalance.dat\00"
@.str.7 = [41 x i8] c"Error! Unable to locate forceBalance.dat\00"
@.str.8 = [8 x i8] c"%f %f \0A\00"
@.str.9 = [4 x i8] c"%f\0A\00"
@.str.10 = [30 x i8] c"angle_optimized is %f degree\0A\00"
@M_PI = global float 0.000000e+00
@.str.11 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.12 = [2 x i8] c"w\00"
@.str.13 = [12 x i8] c"solid flap\0A\00"
@.str.14 = [26 x i8] c"\09 facet normal %f 0.0 %f\0A\00"
@.str.15 = [15 x i8] c"\09\09 outer loop\0A\00"
@.str.16 = [21 x i8] c"\09\09\09 vertex %f %f %f\0A\00"
@.str.17 = [23 x i8] c"\09\09 endloop\0A\09 endfacet\0A\00"
@.str.18 = [14 x i8] c"endsolid flap\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca [10 x i8]
%10 = alloca i32
%11 = alloca [3 x 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 float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca float
%27 = alloca i32
store i32 0, i32* %1
%28 = load i32, i32* @BUFSIZ
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %6
%31 = alloca i8, i64 %29
store i64 %29, i64* %7
%32 = load i32, i32* @BUFSIZ
%33 = zext i32 %32 to i64
%34 = alloca i8, i64 %33
store i64 %33, i64* %8
%35 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
store float 0.000000e+00, float* %35
%36 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
store float 0.000000e+00, float* %36
%37 = 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* %37, i32** %4
%38 = load i32*, i32** %4
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %0
%41 = 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* %27
br label %290
42: ; preds = %0
%43 = load i32*, i32** %4
%44 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%45 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%46 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%47 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float* %44, float* %45, float* %46)
%48 = load i32*, i32** %4
%49 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%50 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%51 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%52 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %48, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float* %49, float* %50, float* %51, float* %26, float* %25)
%53 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%54 = load float, float* %53
%55 = fpext float %54 to double
%56 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%57 = load float, float* %56
%58 = fpext float %57 to double
%59 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%60 = load float, float* %59
%61 = fpext float %60 to double
%62 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%66 = load float, float* %65
%67 = fpext float %66 to double
%68 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%69 = load float, float* %68
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), double %55, double %58, double %61, double %64, double %67, double %70)
%72 = load i32*, i32** %4
%73 = call i32 @fclose(i32* %72)
br label %74
74: ; preds = %42
%75 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 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* %75, i32** %2
%76 = load i32*, i32** %2
%77 = icmp eq i32* %76, null
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %27
br label %290
80: ; preds = %74
store i32 0, i32* %10
br label %81
81: ; preds = %111, %80
%82 = trunc i64 %29 to i32
%83 = load i32*, i32** %2
%84 = call i32* @fgets(i8* %31, i32 %82, i32* %83)
%85 = icmp ne i32* %84, null
br i1 %85, label %86, label %114
86: ; preds = %81
%87 = load i32, i32* %10
%88 = icmp slt i32 %87, 1
br i1 %88, label %89, label %96
89: ; preds = %86
%90 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %22, float* %19)
%91 = load float, float* %22
%92 = fadd float %91, 1.000000e+01
store float %92, float* %24
%93 = load float, float* %22
%94 = fpext float %93 to double
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double %94)
br label %111
96: ; preds = %86
%97 = load float, float* %22
store float %97, float* %23
%98 = load float, float* %19
store float %98, float* %20
%99 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %22, float* %19)
%100 = load float, float* %22
%101 = load float, float* %22
%102 = load float, float* %23
%103 = fsub float %101, %102
%104 = load float, float* %19
%105 = load float, float* %20
%106 = fsub float %104, %105
%107 = fdiv float %103, %106
%108 = load float, float* %19
%109 = fneg float %107
%110 = call float @llvm.fmuladd.f32(float %109, float %108, float %100)
store float %110, float* %24
br label %111
111: ; preds = %96, %89
%112 = load i32, i32* %10
%113 = add nsw i32 %112, 1
store i32 %113, i32* %10
br label %81
114: ; preds = %81
%115 = load float, float* %24
%116 = load float, float* %26
%117 = fadd float %116, 5.000000e+00
%118 = fcmp ole float %115, %117
br i1 %118, label %119, label %122
119: ; preds = %114
%120 = load float, float* %26
%121 = fadd float %120, 5.000000e+00
store float %121, float* %24
br label %122
122: ; preds = %119, %114
%123 = load float, float* %24
%124 = load float, float* %26
%125 = fadd float %124, 1.800000e+02
%126 = fcmp oge float %123, %125
br i1 %126, label %127, label %130
127: ; preds = %122
%128 = load float, float* %26
%129 = fadd float %128, 1.750000e+02
store float %129, float* %24
br label %130
130: ; preds = %127, %122
%131 = load float, float* %24
%132 = fpext float %131 to double
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), double %132)
br label %134
134: ; preds = %130
%135 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%136 = load float, float* %135
%137 = fpext float %136 to double
%138 = load float, float* %25
%139 = fpext float %138 to double
%140 = load float, float* %24
%141 = load float, float* @M_PI
%142 = fmul float %140, %141
%143 = fdiv float %142, 1.800000e+02
%144 = fptosi float %143 to i32
%145 = call double @cosf(i32 %144)
%146 = call double @llvm.fmuladd.f64(double %139, double %145, double %137)
%147 = fptrunc double %146 to float
%148 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
store float %147, float* %148
%149 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%150 = load float, float* %149
%151 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
store float %150, float* %151
%152 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%153 = load float, float* %152
%154 = fpext float %153 to double
%155 = load float, float* %25
%156 = fpext float %155 to double
%157 = load float, float* %24
%158 = load float, float* @M_PI
%159 = fmul float %157, %158
%160 = fdiv float %159, 1.800000e+02
%161 = fptosi float %160 to i32
%162 = call double @sinf(i32 %161)
%163 = call double @llvm.fmuladd.f64(double %156, double %162, double %154)
%164 = fptrunc double %163 to float
%165 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
store float %164, float* %165
%166 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%167 = load float, float* %166
%168 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
store float %167, float* %168
%169 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%170 = load float, float* %169
%171 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
store float %170, float* %171
%172 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%173 = load float, float* %172
%174 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
store float %173, float* %174
%175 = load i32*, i32** %2
%176 = call i32 @fclose(i32* %175)
%177 = 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.12, i64 0, i64 0))
store i32* %177, i32** %3
%178 = load i32*, i32** %3
%179 = call i32 (i32*, i8*, ...) @fprintf(i32* %178, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%180 = load i32*, i32** %3
%181 = load float, float* %24
%182 = fadd float 9.000000e+01, %181
%183 = load float, float* @M_PI
%184 = fmul float %182, %183
%185 = fdiv float %184, 1.800000e+02
%186 = fptosi float %185 to i32
%187 = call double @cosf(i32 %186)
%188 = load float, float* %24
%189 = fadd float 9.000000e+01, %188
%190 = load float, float* @M_PI
%191 = fmul float %189, %190
%192 = fdiv float %191, 1.800000e+02
%193 = fptosi float %192 to i32
%194 = call double @sinf(i32 %193)
%195 = call i32 (i32*, i8*, ...) @fprintf(i32* %180, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %187, double %194)
%196 = load i32*, i32** %3
%197 = call i32 (i32*, i8*, ...) @fprintf(i32* %196, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%198 = load i32*, i32** %3
%199 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%200 = load float, float* %199
%201 = fpext float %200 to double
%202 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%203 = load float, float* %202
%204 = fpext float %203 to double
%205 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 3
%206 = load float, float* %205
%207 = fpext float %206 to double
%208 = call i32 (i32*, i8*, ...) @fprintf(i32* %198, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %201, double %204, double %207)
%209 = load i32*, i32** %3
%210 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%211 = load float, float* %210
%212 = fpext float %211 to double
%213 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%214 = load float, float* %213
%215 = fpext float %214 to double
%216 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%217 = load float, float* %216
%218 = fpext float %217 to double
%219 = call i32 (i32*, i8*, ...) @fprintf(i32* %209, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %212, double %215, double %218)
%220 = load i32*, i32** %3
%221 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%222 = load float, float* %221
%223 = fpext float %222 to double
%224 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%225 = load float, float* %224
%226 = fpext float %225 to double
%227 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%228 = load float, float* %227
%229 = fpext float %228 to double
%230 = call i32 (i32*, i8*, ...) @fprintf(i32* %220, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %223, double %226, double %229)
%231 = load i32*, i32** %3
%232 = call i32 (i32*, i8*, ...) @fprintf(i32* %231, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%233 = load i32*, i32** %3
%234 = load float, float* %24
%235 = fadd float 9.000000e+01, %234
%236 = load float, float* @M_PI
%237 = fmul float %235, %236
%238 = fdiv float %237, 1.800000e+02
%239 = fptosi float %238 to i32
%240 = call double @cosf(i32 %239)
%241 = load float, float* %24
%242 = fadd float 9.000000e+01, %241
%243 = load float, float* @M_PI
%244 = fmul float %242, %243
%245 = fdiv float %244, 1.800000e+02
%246 = fptosi float %245 to i32
%247 = call double @sinf(i32 %246)
%248 = call i32 (i32*, i8*, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %240, double %247)
%249 = load i32*, i32** %3
%250 = call i32 (i32*, i8*, ...) @fprintf(i32* %249, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%251 = load i32*, i32** %3
%252 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%253 = load float, float* %252
%254 = fpext float %253 to double
%255 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%256 = load float, float* %255
%257 = fpext float %256 to double
%258 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%259 = load float, float* %258
%260 = fpext float %259 to double
%261 = call i32 (i32*, i8*, ...) @fprintf(i32* %251, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %254, double %257, double %260)
%262 = load i32*, i32** %3
%263 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%264 = load float, float* %263
%265 = fpext float %264 to double
%266 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%267 = load float, float* %266
%268 = fpext float %267 to double
%269 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%270 = load float, float* %269
%271 = fpext float %270 to double
%272 = call i32 (i32*, i8*, ...) @fprintf(i32* %262, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %265, double %268, double %271)
%273 = load i32*, i32** %3
%274 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%275 = load float, float* %274
%276 = fpext float %275 to double
%277 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%278 = load float, float* %277
%279 = fpext float %278 to double
%280 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%281 = load float, float* %280
%282 = fpext float %281 to double
%283 = call i32 (i32*, i8*, ...) @fprintf(i32* %273, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %276, double %279, double %282)
%284 = load i32*, i32** %3
%285 = call i32 (i32*, i8*, ...) @fprintf(i32* %284, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%286 = load i32*, i32** %3
%287 = call i32 (i32*, i8*, ...) @fprintf(i32* %286, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0))
%288 = load i32*, i32** %3
%289 = call i32 @fclose(i32* %288)
store i32 0, i32* %27
br label %290
290: ; preds = %134, %78, %40
%291 = load i8*, i8** %6
%292 = load i32, i32* %27
switch i32 %292, label %295 [
i32 0, label %293
i32 1, label %293
]
293: ; preds = %290, %290
%294 = load i32, i32* %1
ret i32 %294
295: ; preds = %290
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 = [19 x i8] c"./forceBalance.dat\00"
@.str.7 = [41 x i8] c"Error! Unable to locate forceBalance.dat\00"
@.str.8 = [8 x i8] c"%f %f \0A\00"
@.str.9 = [4 x i8] c"%f\0A\00"
@.str.10 = [30 x i8] c"angle_optimized is %f degree\0A\00"
@M_PI = global float 0.000000e+00
@.str.11 = [31 x i8] c"./constant/triSurface/flap.stl\00"
@.str.12 = [2 x i8] c"w\00"
@.str.13 = [12 x i8] c"solid flap\0A\00"
@.str.14 = [26 x i8] c"\09 facet normal %f 0.0 %f\0A\00"
@.str.15 = [15 x i8] c"\09\09 outer loop\0A\00"
@.str.16 = [21 x i8] c"\09\09\09 vertex %f %f %f\0A\00"
@.str.17 = [23 x i8] c"\09\09 endloop\0A\09 endfacet\0A\00"
@.str.18 = [14 x i8] c"endsolid flap\00"
define i32 @main() {
%1 = alloca [3 x float]
%2 = alloca [3 x float]
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = bitcast [3 x float]* %1 to i8*
%11 = bitcast [3 x float]* %2 to i8*
%12 = bitcast float* %3 to i8*
%13 = bitcast float* %4 to i8*
%14 = bitcast float* %5 to i8*
%15 = bitcast float* %6 to i8*
%16 = 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))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %161
20: ; preds = %0
%21 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%22 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%23 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 3
%24 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float* %21, float* %22, float* %23)
%25 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%26 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%27 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%28 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float* %25, float* %26, float* %27, float* %6, float* %5)
%29 = load float, float* %21
%30 = fpext float %29 to double
%31 = load float, float* %22
%32 = fpext float %31 to double
%33 = load float, float* %23
%34 = fpext float %33 to double
%35 = load float, float* %25
%36 = fpext float %35 to double
%37 = load float, float* %26
%38 = fpext float %37 to double
%39 = load float, float* %27
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), double %30, double %32, double %34, double %36, double %38, double %40)
%42 = call i32 @fclose(i32* %16)
%43 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %56, label %45
45: ; preds = %20
%46 = call i32* @fgets(i8* %9, i32 %7, i32* %43)
%47 = icmp eq i32* %46, null
br i1 %47, label %72, label %48
48: ; preds = %45
%49 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %4, float* %3)
%50 = load float, float* %4
%51 = fadd float %50, 1.000000e+01
%52 = fpext float %50 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double %52)
%54 = call i32* @fgets(i8* %9, i32 %7, i32* %43)
%55 = icmp eq i32* %54, null
br i1 %55, label %72, label %58
56: ; preds = %20
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
br label %161
58: ; preds = %48, %58
%59 = load float, float* %4
%60 = load float, float* %3
%61 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %4, float* %3)
%62 = load float, float* %4
%63 = load float, float* %3
%64 = call i32* @fgets(i8* %9, i32 %7, i32* %43)
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %58
66: ; preds = %58
%67 = fsub float %62, %59
%68 = fsub float %63, %60
%69 = fneg float %67
%70 = fdiv float %69, %68
%71 = call float @llvm.fmuladd.f32(float %70, float %63, float %62)
br label %72
72: ; preds = %66, %48, %45
%73 = phi float [ undef, %45 ], [ %51, %48 ], [ %71, %66 ]
%74 = load float, float* %6
%75 = fadd float %74, 5.000000e+00
%76 = fcmp ole float %73, %75
%77 = select i1 %76, float %75, float %73
%78 = fadd float %74, 1.800000e+02
%79 = fcmp ult float %77, %78
%80 = fadd float %74, 1.750000e+02
%81 = select i1 %79, float %77, float %80
%82 = fpext float %81 to double
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), double %82)
%84 = load float, float* %21
%85 = fpext float %84 to double
%86 = load float, float* %5
%87 = fpext float %86 to double
%88 = load float, float* @M_PI
%89 = fmul float %88, %81
%90 = fdiv float %89, 1.800000e+02
%91 = fptosi float %90 to i32
%92 = call double @cosf(i32 %91)
%93 = call double @llvm.fmuladd.f64(double %87, double %92, double %85)
%94 = fptrunc double %93 to float
%95 = load float, float* %22
%96 = load float, float* @M_PI
%97 = fmul float %81, %96
%98 = fdiv float %97, 1.800000e+02
%99 = fptosi float %98 to i32
%100 = call double @sinf(i32 %99)
%101 = load float, float* %26
%102 = call i32 @fclose(i32* %43)
%103 = 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.12, i64 0, i64 0))
%104 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i64 11, i64 1, i32* %103)
%105 = fadd float %81, 9.000000e+01
%106 = load float, float* @M_PI
%107 = fmul float %105, %106
%108 = fdiv float %107, 1.800000e+02
%109 = fptosi float %108 to i32
%110 = call double @cosf(i32 %109)
%111 = load float, float* @M_PI
%112 = fmul float %105, %111
%113 = fdiv float %112, 1.800000e+02
%114 = fptosi float %113 to i32
%115 = call double @sinf(i32 %114)
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %110, double %115)
%117 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64 14, i64 1, i32* %103)
%118 = load float, float* %21
%119 = fpext float %118 to double
%120 = load float, float* %22
%121 = fpext float %120 to double
%122 = load float, float* %23
%123 = fpext float %122 to double
%124 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %119, double %121, double %123)
%125 = load float, float* %25
%126 = fpext float %125 to double
%127 = load float, float* %26
%128 = fpext float %127 to double
%129 = load float, float* %27
%130 = fpext float %129 to double
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %126, double %128, double %130)
%132 = fpext float %94 to double
%133 = fpext float %95 to double
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %132, double %133, double poison)
%135 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i64 22, i64 1, i32* %103)
%136 = load float, float* @M_PI
%137 = fmul float %105, %136
%138 = fdiv float %137, 1.800000e+02
%139 = fptosi float %138 to i32
%140 = call double @cosf(i32 %139)
%141 = load float, float* @M_PI
%142 = fmul float %105, %141
%143 = fdiv float %142, 1.800000e+02
%144 = fptosi float %143 to i32
%145 = call double @sinf(i32 %144)
%146 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %140, double %145)
%147 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64 14, i64 1, i32* %103)
%148 = fpext float %101 to double
%149 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %132, double %148, double poison)
%150 = load float, float* %25
%151 = fpext float %150 to double
%152 = load float, float* %26
%153 = fpext float %152 to double
%154 = load float, float* %27
%155 = fpext float %154 to double
%156 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %151, double %153, double %155)
%157 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %132, double %133, double poison)
%158 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i64 22, i64 1, i32* %103)
%159 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i64 13, i64 1, i32* %103)
%160 = call i32 @fclose(i32* %103)
br label %161
161: ; preds = %72, %56, %18
%162 = phi i32 [ 1, %18 ], [ 1, %56 ], [ 0, %72 ]
ret i32 %162
}