#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;
  int flag;
  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;
    flag = 0;
    while (fgets(buff, sizeof buff, input) != NULL) {
      if (i < 1) {
        sscanf(buff, "%f %f \n", &angle_1, &moment_1);
        angle_optimized = angle_1 + 4;
        printf("%f\n", angle_1);
      } else {
        angle_2 = angle_1;
        moment_2 = moment_1;
        sscanf(buff, "%f %f \n", &angle_1, &moment_1);
        if (moment_1 * moment_2 < 0)
          flag = 1;
        if (flag == 0)
          angle_optimized = angle_1 + moment_1 * 1e5;
        else
          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,-0x7c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
lea    0xe21(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123e <main+0xae>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xd8(%rbp)
jmp    1958 <main+0x7c8>
mov    -0x20(%rbp),%rdi
lea    -0x6c(%rbp),%rdx
add    $0x4,%rdx
lea    -0x6c(%rbp),%rcx
add    $0x8,%rcx
lea    -0x6c(%rbp),%r8
add    $0xc,%r8
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x78(%rbp),%rdx
add    $0x4,%rdx
lea    -0x78(%rbp),%rcx
add    $0x8,%rcx
lea    -0x78(%rbp),%r8
add    $0xc,%r8
lea    0xdf9(%rip),%rsi
lea    -0xd4(%rbp),%r9
lea    -0xd0(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <fscanf@plt>
add    $0x10,%rsp
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x64(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x60(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x74(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x70(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x6c(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xdac(%rip),%rdi
mov    $0x6,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdc6(%rip),%rdi
lea    0xd3a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    133f <main+0x1af>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xd8(%rbp)
jmp    1958 <main+0x7c8>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     14dd <main+0x34d>
cmpl   $0x1,-0x50(%rbp)
jge    13d2 <main+0x242>
mov    -0xe0(%rbp),%rdi
lea    0xcf4(%rip),%rsi
lea    -0xc4(%rbp),%rdx
lea    -0xb8(%rbp),%rcx
call   10a0 <sscanf@plt>
movss  0xc6d(%rip),%xmm0
addss  -0xc4(%rbp),%xmm0
ff
movss  %xmm0,-0xcc(%rbp)
ff
movss  -0xc4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd9d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    14cf <main+0x33f>
mov    -0xe0(%rbp),%rdi
movss  -0xc4(%rbp),%xmm0
ff
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xb8(%rbp),%xmm0
ff
movss  %xmm0,-0xbc(%rbp)
ff
lea    0xc7c(%rip),%rsi
lea    -0xc4(%rbp),%rdx
lea    -0xb8(%rbp),%rcx
call   10a0 <sscanf@plt>
movss  -0xb8(%rbp),%xmm1
ff
mulss  -0xbc(%rbp),%xmm1
ff
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    1436 <main+0x2a6>
movl   $0x1,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    1479 <main+0x2e9>
movss  -0xc4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movss  -0xb8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xbb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
jmp    14ca <main+0x33a>
movss  -0xc4(%rbp),%xmm1
ff
movss  -0xc4(%rbp),%xmm0
ff
subss  -0xc8(%rbp),%xmm0
ff
movss  -0xb8(%rbp),%xmm2
ff
subss  -0xbc(%rbp),%xmm2
ff
divss  %xmm2,%xmm0
movss  -0xb8(%rbp),%xmm2
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
jmp    14cf <main+0x33f>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    134d <main+0x1bd>
movss  -0xcc(%rbp),%xmm1
ff
movss  0xb13(%rip),%xmm0
addss  -0xd4(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jb     1516 <main+0x386>
movss  0xafa(%rip),%xmm0
addss  -0xd4(%rbp),%xmm0
ff
movss  %xmm0,-0xcc(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
movss  0xade(%rip),%xmm1
addss  -0xd4(%rbp),%xmm1
ff
ucomiss %xmm1,%xmm0
jb     154f <main+0x3bf>
movss  0xac9(%rip),%xmm0
addss  -0xd4(%rbp),%xmm0
ff
movss  %xmm0,-0xcc(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xba0(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x128(%rbp)
ff
movss  -0xd0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x120(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
mov    0x2a4b(%rip),%rax
mulss  (%rax),%xmm0
movss  0xa5b(%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,-0x80(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
movss  -0xd0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
mov    0x29d0(%rip),%rax
mulss  (%rax),%xmm0
movss  0x9e0(%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,-0x78(%rbp)
movss  -0x80(%rbp),%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x88(%rbp)
ff
movss  -0x78(%rbp),%xmm0
movss  %xmm0,-0x84(%rbp)
ff
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xa94(%rip),%rdi
lea    0xaac(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xa9a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x108(%rbp)
movss  0x94b(%rip),%xmm0
addss  -0xcc(%rbp),%xmm0
ff
mov    0x2918(%rip),%rax
mulss  (%rax),%xmm0
movss  0x928(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0x100(%rbp)
ff
movss  0x913(%rip),%xmm0
addss  -0xcc(%rbp),%xmm0
mov    0x28e0(%rip),%rax
mulss  (%rax),%xmm0
movss  0x8f0(%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    0xa13(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xa1b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x64(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x60(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x9fd(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x70(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x6c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x9d0(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x80(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x7c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x78(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x9a3(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x9a6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xf8(%rbp)
movss  0x80d(%rip),%xmm0
addss  -0xcc(%rbp),%xmm0
ff
mov    0x27da(%rip),%rax
mulss  (%rax),%xmm0
movss  0x7ea(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movss  0x7d5(%rip),%xmm0
addss  -0xcc(%rbp),%xmm0
ff
mov    0x27a2(%rip),%rax
mulss  (%rax),%xmm0
movss  0x7b2(%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    0x8d5(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x8dd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x8c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0x88(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0x84(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    0x8b6(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x70(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x6c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x889(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x80(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x7c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x78(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0x85c(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x85f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x864(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0xd8(%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),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe4d(%rip),%rdi
lea    0xe67(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13c8 <main+0x228>
mov    %rax,%r15
lea    -0x60(%rbp),%rdx
lea    -0x5c(%rbp),%rcx
lea    -0x58(%rbp),%r8
lea    0xe7b(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    -0x50(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
lea    -0x48(%rbp),%r8
sub    $0x8,%rsp
lea    -0x80(%rbp),%r10
lea    0xe61(%rip),%rsi
lea    -0x7c(%rbp),%r9
mov    %r15,%rdi
xor    %eax,%eax
push   %r10
call   1070 <fscanf@plt>
add    $0x10,%rsp
movss  -0x60(%rbp),%xmm0
movss  -0x5c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x58(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x50(%rbp),%xmm3
movss  -0x4c(%rbp),%xmm4
cvtss2sd %xmm3,%xmm3
cvtss2sd %xmm4,%xmm4
movss  -0x48(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xe21(%rip),%rdi
mov    $0x6,%al
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xe3c(%rip),%rdi
lea    0xdb0(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13d1 <main+0x231>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13e9 <main+0x249>
lea    0xdbc(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x58(%rbp),%rcx
mov    %rbx,%rdi
call   10a0 <sscanf@plt>
movss  -0x2c(%rbp),%xmm0
movaps %xmm0,-0x40(%rbp)
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13eb <main+0x24b>
xor    %r13d,%r13d
lea    -0x58(%rbp),%r12
jmp    134c <main+0x1ac>
nopl   0x0(%rax,%rax,1)
movaps %xmm3,%xmm1
subss  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
subss  %xmm4,%xmm2
divss  %xmm2,%xmm1
mulss  %xmm0,%xmm1
subss  %xmm1,%xmm3
movaps %xmm3,-0x40(%rbp)
mov    $0x1,%r13d
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13fb <main+0x25b>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x58(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    %rbx,%rdi
lea    0xd12(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    %r12,%rcx
call   10a0 <sscanf@plt>
movss  -0x40(%rbp),%xmm4
movss  -0x58(%rbp),%xmm0
movaps %xmm4,%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm1,%xmm2
movss  -0x2c(%rbp),%xmm3
ja     1310 <main+0x170>
test   %r13d,%r13d
jne    1310 <main+0x170>
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  0xc64(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movaps %xmm0,-0x40(%rbp)
xor    %r13d,%r13d
jmp    1335 <main+0x195>
lea    0xc74(%rip),%rdi
jmp    13d8 <main+0x238>
lea    0xd01(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    1742 <main+0x5a2>
jmp    13fb <main+0x25b>
movaps -0x40(%rbp),%xmm0
addss  0xc09(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movss  -0x7c(%rbp),%xmm0
movss  0xbfc(%rip),%xmm1
addss  %xmm0,%xmm1
movaps -0x40(%rbp),%xmm3
movaps %xmm3,%xmm2
cmpless %xmm1,%xmm2
andps  %xmm2,%xmm1
andnps %xmm3,%xmm2
orps   %xmm1,%xmm2
movaps %xmm0,%xmm3
addss  0xbdc(%rip),%xmm3
addss  0xbd8(%rip),%xmm0
cmpnless %xmm2,%xmm3
movaps %xmm3,%xmm1
andps  %xmm2,%xmm1
andnps %xmm0,%xmm3
orps   %xmm1,%xmm3
movaps %xmm3,-0x40(%rbp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xcab(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x80(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    0x2b67(%rip),%r12
movss  (%r12),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  0xb74(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
mulsd  -0x78(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x5c(%rbp),%xmm0
movss  %xmm0,-0x70(%rbp)
movss  (%r12),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  0xb3b(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xc31(%rip),%rdi
lea    0xc49(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0xc3c(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
movaps -0x40(%rbp),%xmm1
addss  0xaed(%rip),%xmm1
movaps %xmm1,-0x40(%rbp)
movss  (%r12),%xmm0
mulss  %xmm1,%xmm0
divss  0xacf(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movss  (%r12),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  0xaab(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
lea    0xbdd(%rip),%rsi
mov    %rbx,%rdi
movsd  -0x88(%rbp),%xmm0
ff
mov    $0x2,%al
call   1090 <fprintf@plt>
lea    0xbde(%rip),%r15
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  -0x60(%rbp),%xmm0
movss  -0x5c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x58(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xbb6(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x48(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x48(%rbp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,-0x48(%rbp)
movss  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,-0x70(%rbp)
mov    %rbx,%rdi
mov    %r14,%rsi
movaps %xmm2,%xmm0
mov    $0x3,%al
call   1090 <fprintf@plt>
lea    0xb5d(%rip),%r13
mov    $0x16,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  (%r12),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  0x9b2(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1050 <cosf@plt>
movaps -0x40(%rbp),%xmm1
mulss  (%r12),%xmm1
movsd  %xmm0,-0x40(%rbp)
divss  0x992(%rip),%xmm1
cvttss2si %xmm1,%edi
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
lea    0xac1(%rip),%rsi
movsd  -0x40(%rbp),%xmm0
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
movss  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  -0x48(%rbp),%xmm0
mov    $0x3,%al
call   1090 <fprintf@plt>
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  -0x48(%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  -0x48(%rbp),%xmm0
movsd  -0x70(%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    0xa7c(%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 i32
%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 [3 x float]
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca 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** %6
%32 = alloca i8, i64 %30
store i64 %30, i64* %7
%33 = load i32, i32* @BUFSIZ
%34 = zext i32 %33 to i64
%35 = alloca i8, i64 %34
store i64 %34, i64* %8
%36 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
store float 0.000000e+00, float* %36
%37 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
store float 0.000000e+00, float* %37
%38 = 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* %38, i32** %4
%39 = load i32*, i32** %4
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %43
41: ; preds = %0
%42 = 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
43: ; preds = %0
%44 = load i32*, i32** %4
%45 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%46 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%47 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%48 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %44, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float* %45, float* %46, float* %47)
%49 = load i32*, i32** %4
%50 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%51 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%52 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%53 = call i32 (i32*, i8*, float*, float*, float*, ...) @fscanf(i32* %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float* %50, float* %51, float* %52, float* %27, float* %26)
%54 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%58 = load float, float* %57
%59 = fpext float %58 to double
%60 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%61 = load float, float* %60
%62 = fpext float %61 to double
%63 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%64 = load float, float* %63
%65 = fpext float %64 to double
%66 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), double %56, double %59, double %62, double %65, double %68, double %71)
%73 = load i32*, i32** %4
%74 = call i32 @fclose(i32* %73)
br label %75
75: ; preds = %43
%76 = 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* %76, i32** %2
%77 = load i32*, i32** %2
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = 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* %28
br label %308
81: ; preds = %75
store i32 0, i32* %10
store i32 0, i32* %11
br label %82
82: ; preds = %129, %81
%83 = trunc i64 %30 to i32
%84 = load i32*, i32** %2
%85 = call i32* @fgets(i8* %32, i32 %83, i32* %84)
%86 = icmp ne i32* %85, null
br i1 %86, label %87, label %132
87: ; preds = %82
%88 = load i32, i32* %10
%89 = icmp slt i32 %88, 1
br i1 %89, label %90, label %97
90: ; preds = %87
%91 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %23, float* %20)
%92 = load float, float* %23
%93 = fadd float %92, 4.000000e+00
store float %93, float* %25
%94 = load float, float* %23
%95 = fpext float %94 to double
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double %95)
br label %129
97: ; preds = %87
%98 = load float, float* %23
store float %98, float* %24
%99 = load float, float* %20
store float %99, float* %21
%100 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %23, float* %20)
%101 = load float, float* %20
%102 = load float, float* %21
%103 = fmul float %101, %102
%104 = fcmp olt float %103, 0.000000e+00
br i1 %104, label %105, label %106
105: ; preds = %97
store i32 1, i32* %11
br label %106
106: ; preds = %105, %97
%107 = load i32, i32* %11
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %116
109: ; preds = %106
%110 = load float, float* %23
%111 = fpext float %110 to double
%112 = load float, float* %20
%113 = fpext float %112 to double
%114 = call double @llvm.fmuladd.f64(double %113, double 1.000000e+05, double %111)
%115 = fptrunc double %114 to float
store float %115, float* %25
br label %128
116: ; preds = %106
%117 = load float, float* %23
%118 = load float, float* %23
%119 = load float, float* %24
%120 = fsub float %118, %119
%121 = load float, float* %20
%122 = load float, float* %21
%123 = fsub float %121, %122
%124 = fdiv float %120, %123
%125 = load float, float* %20
%126 = fneg float %124
%127 = call float @llvm.fmuladd.f32(float %126, float %125, float %117)
store float %127, float* %25
br label %128
128: ; preds = %116, %109
br label %129
129: ; preds = %128, %90
%130 = load i32, i32* %10
%131 = add nsw i32 %130, 1
store i32 %131, i32* %10
br label %82
132: ; preds = %82
%133 = load float, float* %25
%134 = load float, float* %27
%135 = fadd float %134, 5.000000e+00
%136 = fcmp ole float %133, %135
br i1 %136, label %137, label %140
137: ; preds = %132
%138 = load float, float* %27
%139 = fadd float %138, 5.000000e+00
store float %139, float* %25
br label %140
140: ; preds = %137, %132
%141 = load float, float* %25
%142 = load float, float* %27
%143 = fadd float %142, 1.800000e+02
%144 = fcmp oge float %141, %143
br i1 %144, label %145, label %148
145: ; preds = %140
%146 = load float, float* %27
%147 = fadd float %146, 1.750000e+02
store float %147, float* %25
br label %148
148: ; preds = %145, %140
%149 = load float, float* %25
%150 = fpext float %149 to double
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), double %150)
br label %152
152: ; preds = %148
%153 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%154 = load float, float* %153
%155 = fpext float %154 to double
%156 = load float, float* %26
%157 = fpext float %156 to double
%158 = load float, float* %25
%159 = load float, float* @M_PI
%160 = fmul float %158, %159
%161 = fdiv float %160, 1.800000e+02
%162 = fptosi float %161 to i32
%163 = call double @cosf(i32 %162)
%164 = call double @llvm.fmuladd.f64(double %157, double %163, double %155)
%165 = fptrunc double %164 to float
%166 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
store float %165, float* %166
%167 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%168 = load float, float* %167
%169 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
store float %168, float* %169
%170 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%171 = load float, float* %170
%172 = fpext float %171 to double
%173 = load float, float* %26
%174 = fpext float %173 to double
%175 = load float, float* %25
%176 = load float, float* @M_PI
%177 = fmul float %175, %176
%178 = fdiv float %177, 1.800000e+02
%179 = fptosi float %178 to i32
%180 = call double @sinf(i32 %179)
%181 = call double @llvm.fmuladd.f64(double %174, double %180, double %172)
%182 = fptrunc double %181 to float
%183 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
store float %182, float* %183
%184 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%185 = load float, float* %184
%186 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
store float %185, float* %186
%187 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%188 = load float, float* %187
%189 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
store float %188, float* %189
%190 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%191 = load float, float* %190
%192 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
store float %191, float* %192
%193 = load i32*, i32** %2
%194 = call i32 @fclose(i32* %193)
%195 = 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* %195, i32** %3
%196 = load i32*, i32** %3
%197 = call i32 (i32*, i8*, ...) @fprintf(i32* %196, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%198 = load i32*, i32** %3
%199 = load float, float* %25
%200 = fadd float 9.000000e+01, %199
%201 = load float, float* @M_PI
%202 = fmul float %200, %201
%203 = fdiv float %202, 1.800000e+02
%204 = fptosi float %203 to i32
%205 = call double @cosf(i32 %204)
%206 = load float, float* %25
%207 = fadd float 9.000000e+01, %206
%208 = load float, float* @M_PI
%209 = fmul float %207, %208
%210 = fdiv float %209, 1.800000e+02
%211 = fptosi float %210 to i32
%212 = call double @sinf(i32 %211)
%213 = call i32 (i32*, i8*, ...) @fprintf(i32* %198, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %205, double %212)
%214 = load i32*, i32** %3
%215 = call i32 (i32*, i8*, ...) @fprintf(i32* %214, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%216 = load i32*, i32** %3
%217 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 1
%218 = load float, float* %217
%219 = fpext float %218 to double
%220 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 2
%221 = load float, float* %220
%222 = fpext float %221 to double
%223 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 3
%224 = load float, float* %223
%225 = fpext float %224 to double
%226 = call i32 (i32*, i8*, ...) @fprintf(i32* %216, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %219, double %222, double %225)
%227 = load i32*, i32** %3
%228 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%229 = load float, float* %228
%230 = fpext float %229 to double
%231 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%232 = load float, float* %231
%233 = fpext float %232 to double
%234 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%235 = load float, float* %234
%236 = fpext float %235 to double
%237 = call i32 (i32*, i8*, ...) @fprintf(i32* %227, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %230, double %233, double %236)
%238 = load i32*, i32** %3
%239 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%240 = load float, float* %239
%241 = fpext float %240 to double
%242 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%243 = load float, float* %242
%244 = fpext float %243 to double
%245 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%246 = load float, float* %245
%247 = fpext float %246 to double
%248 = call i32 (i32*, i8*, ...) @fprintf(i32* %238, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %241, double %244, double %247)
%249 = load i32*, i32** %3
%250 = call i32 (i32*, i8*, ...) @fprintf(i32* %249, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%251 = load i32*, i32** %3
%252 = load float, float* %25
%253 = fadd float 9.000000e+01, %252
%254 = load float, float* @M_PI
%255 = fmul float %253, %254
%256 = fdiv float %255, 1.800000e+02
%257 = fptosi float %256 to i32
%258 = call double @cosf(i32 %257)
%259 = load float, float* %25
%260 = fadd float 9.000000e+01, %259
%261 = load float, float* @M_PI
%262 = fmul float %260, %261
%263 = fdiv float %262, 1.800000e+02
%264 = fptosi float %263 to i32
%265 = call double @sinf(i32 %264)
%266 = call i32 (i32*, i8*, ...) @fprintf(i32* %251, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %258, double %265)
%267 = load i32*, i32** %3
%268 = call i32 (i32*, i8*, ...) @fprintf(i32* %267, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%269 = load i32*, i32** %3
%270 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%271 = load float, float* %270
%272 = fpext float %271 to double
%273 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%274 = load float, float* %273
%275 = fpext float %274 to double
%276 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 3
%277 = load float, float* %276
%278 = fpext float %277 to double
%279 = call i32 (i32*, i8*, ...) @fprintf(i32* %269, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %272, double %275, double %278)
%280 = load i32*, i32** %3
%281 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%282 = load float, float* %281
%283 = fpext float %282 to double
%284 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%285 = load float, float* %284
%286 = fpext float %285 to double
%287 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 3
%288 = load float, float* %287
%289 = fpext float %288 to double
%290 = call i32 (i32*, i8*, ...) @fprintf(i32* %280, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %283, double %286, double %289)
%291 = load i32*, i32** %3
%292 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%293 = load float, float* %292
%294 = fpext float %293 to double
%295 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%296 = load float, float* %295
%297 = fpext float %296 to double
%298 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 3
%299 = load float, float* %298
%300 = fpext float %299 to double
%301 = call i32 (i32*, i8*, ...) @fprintf(i32* %291, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %294, double %297, double %300)
%302 = load i32*, i32** %3
%303 = call i32 (i32*, i8*, ...) @fprintf(i32* %302, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%304 = load i32*, i32** %3
%305 = call i32 (i32*, i8*, ...) @fprintf(i32* %304, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0))
%306 = load i32*, i32** %3
%307 = call i32 @fclose(i32* %306)
store i32 0, i32* %28
br label %308
308: ; preds = %152, %79, %41
%309 = load i8*, i8** %6
%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 = [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 %174
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 %85, 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, 4.000000e+00
%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 %85, 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 %174
58: ; preds = %48, %80
%59 = phi i32 [ %81, %80 ], [ 0, %48 ]
%60 = load float, float* %4
%61 = load float, float* %3
%62 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), float* %4, float* %3)
%63 = load float, float* %3
%64 = fmul float %61, %63
%65 = fcmp uge float %64, 0.000000e+00
%66 = icmp eq i32 %59, 0
%67 = and i1 %65, %66
%68 = load float, float* %4
br i1 %67, label %69, label %74
69: ; preds = %58
%70 = fpext float %68 to double
%71 = fpext float %63 to double
%72 = call double @llvm.fmuladd.f64(double %71, double 1.000000e+05, double %70)
%73 = fptrunc double %72 to float
br label %80
74: ; preds = %58
%75 = fsub float %68, %60
%76 = fsub float %63, %61
%77 = fneg float %75
%78 = fdiv float %77, %76
%79 = call float @llvm.fmuladd.f32(float %78, float %63, float %68)
br label %80
80: ; preds = %69, %74
%81 = phi i32 [ 0, %69 ], [ 1, %74 ]
%82 = phi float [ %73, %69 ], [ %79, %74 ]
%83 = call i32* @fgets(i8* %9, i32 %7, i32* %43)
%84 = icmp eq i32* %83, null
br i1 %84, label %85, label %58
85: ; preds = %80, %48, %45
%86 = phi float [ undef, %45 ], [ %51, %48 ], [ %82, %80 ]
%87 = load float, float* %6
%88 = fadd float %87, 5.000000e+00
%89 = fcmp ole float %86, %88
%90 = select i1 %89, float %88, float %86
%91 = fadd float %87, 1.800000e+02
%92 = fcmp ult float %90, %91
%93 = fadd float %87, 1.750000e+02
%94 = select i1 %92, float %90, float %93
%95 = fpext float %94 to double
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), double %95)
%97 = load float, float* %21
%98 = fpext float %97 to double
%99 = load float, float* %5
%100 = fpext float %99 to double
%101 = load float, float* @M_PI
%102 = fmul float %101, %94
%103 = fdiv float %102, 1.800000e+02
%104 = fptosi float %103 to i32
%105 = call double @cosf(i32 %104)
%106 = call double @llvm.fmuladd.f64(double %100, double %105, double %98)
%107 = fptrunc double %106 to float
%108 = load float, float* %22
%109 = load float, float* @M_PI
%110 = fmul float %94, %109
%111 = fdiv float %110, 1.800000e+02
%112 = fptosi float %111 to i32
%113 = call double @sinf(i32 %112)
%114 = load float, float* %26
%115 = call i32 @fclose(i32* %43)
%116 = 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))
%117 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i64 11, i64 1, i32* %116)
%118 = fadd float %94, 9.000000e+01
%119 = load float, float* @M_PI
%120 = fmul float %118, %119
%121 = fdiv float %120, 1.800000e+02
%122 = fptosi float %121 to i32
%123 = call double @cosf(i32 %122)
%124 = load float, float* @M_PI
%125 = fmul float %118, %124
%126 = fdiv float %125, 1.800000e+02
%127 = fptosi float %126 to i32
%128 = call double @sinf(i32 %127)
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %123, double %128)
%130 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64 14, i64 1, i32* %116)
%131 = load float, float* %21
%132 = fpext float %131 to double
%133 = load float, float* %22
%134 = fpext float %133 to double
%135 = load float, float* %23
%136 = fpext float %135 to double
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %132, double %134, double %136)
%138 = load float, float* %25
%139 = fpext float %138 to double
%140 = load float, float* %26
%141 = fpext float %140 to double
%142 = load float, float* %27
%143 = fpext float %142 to double
%144 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %139, double %141, double %143)
%145 = fpext float %107 to double
%146 = fpext float %108 to double
%147 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %145, double %146, double poison)
%148 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i64 22, i64 1, i32* %116)
%149 = load float, float* @M_PI
%150 = fmul float %118, %149
%151 = fdiv float %150, 1.800000e+02
%152 = fptosi float %151 to i32
%153 = call double @cosf(i32 %152)
%154 = load float, float* @M_PI
%155 = fmul float %118, %154
%156 = fdiv float %155, 1.800000e+02
%157 = fptosi float %156 to i32
%158 = call double @sinf(i32 %157)
%159 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), double %153, double %158)
%160 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64 14, i64 1, i32* %116)
%161 = fpext float %114 to double
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %145, double %161, double poison)
%163 = load float, float* %25
%164 = fpext float %163 to double
%165 = load float, float* %26
%166 = fpext float %165 to double
%167 = load float, float* %27
%168 = fpext float %167 to double
%169 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %164, double %166, double %168)
%170 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), double %145, double %146, double poison)
%171 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i64 22, i64 1, i32* %116)
%172 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i64 13, i64 1, i32* %116)
%173 = call i32 @fclose(i32* %116)
br label %174
174: ; preds = %85, %56, %18
%175 = phi i32 [ 1, %18 ], [ 1, %56 ], [ 0, %85 ]
ret i32 %175
}