#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdout;
main(int argc, char **argv) {
  int sec, i, j, seg, strip;
  int rcout = 1;
  int icout = 1;
  char name[256];
  char spname[256], csname[256];
  double voltage, offset;
  double cur_base = 1.23684e-05, cur_var;
  double res_base = 1.6, res_var;
  double length, width = 0.8;
  FILE *fp;
  setbuf(stdout, 0);
  printf("#segment:");
  scanf("%d", &seg);
  printf("#R-I section in each segment:");
  scanf("%d", &sec);
  printf("# strip in each segment:");
  scanf("%d", &strip);
  printf("fileroot:");
  scanf("%s", name);
  printf("voltage source:");
  scanf("%lf", &voltage);
  printf("voltage offset:");
  scanf("%lf", &offset);
  printf("#sec: %d\n", sec);
  printf("#seg: %d\n", seg);
  printf("#vertical strip: %d\n", strip);
  printf("filename: %s\n", name);
  printf("voltage: %g\n", voltage);
  printf("voltage offset: %g\n", offset);
  if (strip >= sec) {
    printf("Invalid p/g strip number %d", strip);
    exit(-1);
  }
  sprintf(spname, "%s.sp", name);
  sprintf(csname, "%s.cs", name);
  fp = fopen(spname, "w");
  if (!fp) {
    perror(spname);
    exit(-1);
  }
  fprintf(fp, "num_node %d\n", sec * seg + 1);
  fprintf(fp, "matrix_size %d\n\n", sec * seg + 2);
  fprintf(fp, "* %d x %d ground network\n", seg, sec);
  for (j = 0; j < seg; j++) {
    fprintf(fp, "*seg: %d\n", j + 1);
    if ((seg - j) > 1) {
      int interval = sec / strip;
      if (interval < 3) {
        printf("Serise chain circuit is too small: %d", interval);
        exit(-1);
      }
      fprintf(fp, "* inter-segment connection\n");
      for (i = 0; i < strip; i++) {
        fprintf(fp, "R%d %d %d 6.16 0.8 49.28 37\n", rcout++,
                j * sec + interval * (i + 1),
                (j + 1) * sec + interval * (i + 1));
      }
    }
    fprintf(fp, "R%d %d %d 0.4 20 80 37\n", rcout++, sec * seg + 1,
            j * sec + 1);
    for (i = 1; i < sec; i++) {
      cur_var = cur_base * ((rand() % 10) / 100.0);
      fprintf(fp, "I%d %d %d %g\n", icout++, (i + j * sec), 0,
              cur_base + cur_var);
      res_var = res_base * ((rand() % 10) / 100.0);
      length = width * (res_var + res_base) * 10.0;
      fprintf(fp, "R%d %d %d %g %g %g 37\n", rcout++, (i + j * sec),
              (i + 1 + j * sec), res_base + res_var, width, length);
    }
    fprintf(fp, "I%d %d %d 1.23684e-05\n", icout++, (i + j * sec), 0);
    fprintf(fp, "R%d %d %d 0.5 10 50 37\n", rcout++, (i + j * sec),
            sec * seg + 1);
  }
  fprintf(fp, "V1 %d %d %g \n", seg * sec + 1, 0, voltage);
  fprintf(fp, "\n.op");
  fprintf(fp, "\n.end");
  fclose(fp);
  fp = fopen(csname, "w");
  if (!fp) {
    perror(csname);
    exit(-1);
  }
  fprintf(fp, "*Layer Information\n");
  fprintf(fp, "*Layer Index Unit_Res Min_Width Max_Current_Den\n");
  fprintf(fp, "Layer 37 0.1 0.4 1.7\n");
  fprintf(fp, "\n*Voltage Constraint\n");
  for (i = 1; i <= seg * sec; i++) {
    fprintf(fp, "Const V(%D) >= %G\n", i, voltage - offset);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x390,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x348(%rbp)
ff
movsd  0xe29(%rip),%xmm0
movsd  %xmm0,-0x358(%rbp)
ff
movsd  0xe11(%rip),%xmm0
movsd  %xmm0,-0x370(%rbp)
ff
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf65(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf45(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf25(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x130(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xde7(%rip),%rdi
lea    -0x338(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdc4(%rip),%rdi
lea    -0x340(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x14(%rbp),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x130(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x338(%rbp),%xmm0
ff
lea    0xdaa(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x340(%rbp),%xmm0
ff
lea    0xda1(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     136b <main+0x1cb>
mov    -0x24(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
lea    -0x230(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xd8e(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x330(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xd7a(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x378(%rbp)
cmpq   $0x0,-0x378(%rbp)
jne    13dd <main+0x23d>
lea    -0x230(%rbp),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x378(%rbp),%rdi
mov    -0x14(%rbp),%edx
imul   -0x20(%rbp),%edx
add    $0x1,%edx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
mov    -0x14(%rbp),%edx
imul   -0x20(%rbp),%edx
add    $0x2,%edx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    175e <main+0x5be>
mov    -0x378(%rbp),%rdi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xcf7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x1,%eax
jle    153d <main+0x39d>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x37c(%rbp)
cmpl   $0x3,-0x37c(%rbp)
jge    14ab <main+0x30b>
mov    -0x37c(%rbp),%esi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x378(%rbp),%rdi
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1538 <main+0x398>
mov    -0x378(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    -0x37c(%rbp),%eax
mov    -0x18(%rbp),%esi
add    $0x1,%esi
imul   %esi,%eax
add    %eax,%ecx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
imul   -0x14(%rbp),%r8d
mov    -0x37c(%rbp),%eax
mov    -0x18(%rbp),%esi
add    $0x1,%esi
imul   %esi,%eax
add    %eax,%r8d
lea    0xc7d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14c7 <main+0x327>
jmp    153d <main+0x39d>
mov    -0x378(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1c(%rbp),%r8d
imul   -0x14(%rbp),%r8d
add    $0x1,%r8d
lea    0xc50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    16e8 <main+0x548>
movsd  -0x348(%rbp),%xmm0
ff
movsd  %xmm0,-0x390(%rbp)
ff
mov    $0x0,%al
call   10c0 <rand@plt>
movsd  -0x390(%rbp),%xmm0
ff
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm1
movsd  0xa66(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x350(%rbp)
ff
mov    -0x378(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%ecx
movsd  -0x348(%rbp),%xmm0
ff
addsd  -0x350(%rbp),%xmm0
ff
lea    0xbd6(%rip),%rsi
xor    %r8d,%r8d
mov    $0x1,%al
call   1060 <fprintf@plt>
movsd  -0x358(%rbp),%xmm0
ff
movsd  %xmm0,-0x388(%rbp)
ff
mov    $0x0,%al
call   10c0 <rand@plt>
movsd  -0x388(%rbp),%xmm0
ff
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm1
movsd  0x9e4(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x360(%rbp)
ff
movsd  -0x370(%rbp),%xmm0
ff
movsd  -0x360(%rbp),%xmm1
ff
addsd  -0x358(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
movsd  0x9a8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x368(%rbp)
ff
mov    -0x378(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%ecx
mov    -0x18(%rbp),%r8d
add    $0x1,%r8d
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%r8d
movsd  -0x358(%rbp),%xmm0
ff
addsd  -0x360(%rbp),%xmm0
ff
movsd  -0x370(%rbp),%xmm1
ff
movsd  -0x368(%rbp),%xmm2
ff
lea    0xb10(%rip),%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    157b <main+0x3db>
mov    -0x378(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%ecx
lea    0xaed(%rip),%rsi
xor    %r8d,%r8d
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%ecx
mov    -0x14(%rbp),%r8d
imul   -0x20(%rbp),%r8d
add    $0x1,%r8d
lea    0xac8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    143d <main+0x29d>
mov    -0x378(%rbp),%rdi
mov    -0x20(%rbp),%edx
imul   -0x14(%rbp),%edx
add    $0x1,%edx
movsd  -0x338(%rbp),%xmm0
ff
lea    0xaab(%rip),%rsi
xor    %ecx,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
lea    0xaa2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
lea    0xa92(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x330(%rbp),%rdi
lea    0x94f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x378(%rbp)
cmpq   $0x0,-0x378(%rbp)
jne    17fb <main+0x65b>
lea    -0x330(%rbp),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x378(%rbp),%rdi
lea    0xa39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
lea    0xa38(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
lea    0xa54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x378(%rbp),%rdi
lea    0xa55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cmp    %ecx,%eax
jg     189e <main+0x6fe>
mov    -0x378(%rbp),%rdi
mov    -0x18(%rbp),%edx
movsd  -0x338(%rbp),%xmm0
ff
subsd  -0x340(%rbp),%xmm0
ff
lea    0xa2a(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1856 <main+0x6b6>
mov    -0x378(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x390,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x358,%rsp
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf9b(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2f(%rip),%rdi
lea    0x250(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1b(%rip),%rbp
lea    0x38(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x48(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xdf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xde8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdef(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x38(%rsp),%xmm0
lea    0xde6(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x48(%rsp),%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
cmp    0xc(%rsp),%esi
jge    1812 <main+0x662>
lea    0xdf3(%rip),%rsi
lea    0x150(%rsp),%rbx
lea    0x250(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10a0 <sprintf@plt>
lea    0xdd7(%rip),%rsi
lea    0x50(%rsp),%rdi
mov    %rbp,%rdx
call   10a0 <sprintf@plt>
lea    0xdc9(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     181b <main+0x66b>
mov    %rax,%rbx
mov    0x10(%rsp),%edx
imul   0xc(%rsp),%edx
add    $0x1,%edx
lea    0xda4(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%edx
imul   0xc(%rsp),%edx
add    $0x2,%edx
lea    0xd94(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xd8c(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%edx
test   %edx,%edx
jle    16b4 <main+0x504>
mov    $0x1,%eax
lea    0xdd0(%rip),%r12
xor    %r13d,%r13d
mov    $0x1,%r14d
mov    $0x1,%ebp
mov    %rbx,0x28(%rsp)
jmp    1472 <main+0x2c2>
nopl   0x0(%rax,%rax,1)
lea    0x1(%r14),%r12d
mov    $0x1,%r15d
mov    %rbp,%rdx
add    $0x1,%ebp
imul   %r13d,%ecx
add    %r15d,%ecx
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
lea    0xde4(%rip),%rsi
xor    %r8d,%r8d
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x2,%r14d
mov    0xc(%rsp),%r8d
imul   %r8d,%r13d
add    %r15d,%r13d
imul   0x10(%rsp),%r8d
add    $0x1,%r8d
mov    %rbx,%rdi
lea    0xdcd(%rip),%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%edx
mov    0x24(%rsp),%eax
add    $0x1,%eax
mov    0x44(%rsp),%ecx
mov    %ecx,%r13d
cmp    %edx,%ecx
lea    0xd34(%rip),%r12
jge    16b4 <main+0x504>
mov    %eax,0x24(%rsp)
lea    0x1(%r13),%edx
mov    %rbx,%rdi
lea    0xcd0(%rip),%rsi
mov    %edx,0x44(%rsp)
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%eax
sub    %r13d,%eax
cmp    $0x2,%eax
jl     153a <main+0x38a>
mov    0xc(%rsp),%eax
cltd
idivl  0x14(%rsp)
mov    %eax,%r15d
cmp    $0x2,%eax
jle    17f7 <main+0x647>
mov    $0x1b,%esi
mov    $0x1,%edx
lea    0xcbf(%rip),%rdi
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
cmpl   $0x0,0x14(%rsp)
jle    153a <main+0x38a>
mov    %rbp,0x30(%rsp)
xor    %ebx,%ebx
mov    %r15d,%ebp
mov    %r13,0x18(%rsp)
mov    0x24(%rsp),%r13d
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rbx,1),%edx
mov    0xc(%rsp),%r8d
add    $0x1,%ebx
mov    0x18(%rsp),%rax
mov    %eax,%ecx
imul   %r8d,%ecx
add    %ebp,%ecx
imul   %r13d,%r8d
add    %ebp,%r8d
mov    0x28(%rsp),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    %r15d,%ebp
cmp    0x14(%rsp),%ebx
jl     14f0 <main+0x340>
add    %ebx,%r14d
mov    0x28(%rsp),%rbx
mov    0x30(%rsp),%rbp
mov    0x18(%rsp),%r13
mov    0xc(%rsp),%r8d
mov    0x10(%rsp),%ecx
imul   %r8d,%ecx
add    $0x1,%ecx
imul   %r13d,%r8d
add    $0x1,%r8d
mov    %rbx,%rdi
lea    0xc61(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x2,%ecx
jl     13f0 <main+0x240>
mov    $0x1,%r15d
mov    %r13,0x18(%rsp)
xchg   %ax,%ax
mov    %r15d,%r12d
add    $0x1,%r14d
mov    %r14,0x30(%rsp)
lea    (%r12,%rbp,1),%ebx
add    $0xffffffff,%ebx
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xa3a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xa36(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0xc(%rsp),%ecx
mov    0x18(%rsp),%r13
imul   %r13d,%ecx
add    %r15d,%ecx
addsd  %xmm1,%xmm0
mov    0x28(%rsp),%r14
mov    %r14,%rdi
lea    0xbdc(%rip),%rsi
mov    %ebx,%edx
xor    %r8d,%r8d
mov    $0x1,%al
call   1060 <fprintf@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x9c8(%rip),%xmm0
movsd  0x9d0(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,%xmm2
movsd  0x9c4(%rip),%xmm1
mulsd  %xmm1,%xmm2
mulsd  0x9c0(%rip),%xmm2
lea    0x1(%r12),%r15d
mov    0xc(%rsp),%eax
imul   %r13d,%eax
mov    %r12d,%ecx
add    %eax,%ecx
lea    (%r12,%rax,1),%r8d
add    $0x1,%r8d
mov    %r14,%rdi
mov    0x30(%rsp),%r14
lea    0xb5a(%rip),%rsi
mov    %r14d,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0xc(%rsp),%ecx
cmp    %ecx,%r15d
jl     1580 <main+0x3d0>
lea    0x1(%r14),%r12d
add    %r15d,%ebp
add    $0xffffffff,%ebp
mov    0x18(%rsp),%r13
jmp    13fa <main+0x24a>
imul   0xc(%rsp),%edx
add    $0x1,%edx
movsd  0x38(%rsp),%xmm0
lea    0xb60(%rip),%rsi
mov    %rbx,%rdi
xor    %ecx,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
lea    0xb5b(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
lea    0xb47(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xa04(%rip),%rsi
lea    0x50(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1825 <main+0x675>
mov    %rax,%rbx
lea    0xb0f(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
lea    0xb0a(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
lea    0xb22(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
lea    0xb1f(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
mov    0xc(%rsp),%eax
imul   0x10(%rsp),%eax
test   %eax,%eax
jle    17db <main+0x62b>
xor    %ebp,%ebp
lea    0xb0d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
movsd  0x38(%rsp),%xmm0
subsd  0x48(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0xc(%rsp),%eax
imul   0x10(%rsp),%eax
cmp    %eax,%ebp
jl     17b0 <main+0x600>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x358,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x960(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
lea    0x8d9(%rip),%rdi
jmp    1801 <main+0x651>
lea    0x150(%rsp),%rdi
jmp    182a <main+0x67a>
lea    0x50(%rsp),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [10 x i8] c"#segment:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"#R-I section in each segment:\00"
@.str.3 = [25 x i8] c"# strip in each segment:\00"
@.str.4 = [10 x i8] c"fileroot:\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [16 x i8] c"voltage source:\00"
@.str.7 = [4 x i8] c"%lf\00"
@.str.8 = [16 x i8] c"voltage offset:\00"
@.str.9 = [10 x i8] c"#sec: %d\0A\00"
@.str.10 = [10 x i8] c"#seg: %d\0A\00"
@.str.11 = [21 x i8] c"#vertical strip: %d\0A\00"
@.str.12 = [14 x i8] c"filename: %s\0A\00"
@.str.13 = [13 x i8] c"voltage: %g\0A\00"
@.str.14 = [20 x i8] c"voltage offset: %g\0A\00"
@.str.15 = [28 x i8] c"Invalid p/g strip number %d\00"
@.str.16 = [6 x i8] c"%s.sp\00"
@.str.17 = [6 x i8] c"%s.cs\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [13 x i8] c"num_node %d\0A\00"
@.str.20 = [17 x i8] c"matrix_size %d\0A\0A\00"
@.str.21 = [26 x i8] c"* %d x %d ground network\0A\00"
@.str.22 = [10 x i8] c"*seg: %d\0A\00"
@.str.23 = [38 x i8] c"Serise chain circuit is too small: %d\00"
@.str.24 = [28 x i8] c"* inter-segment connection\0A\00"
@.str.25 = [29 x i8] c"R%d %d %d 6.16 0.8 49.28 37\0A\00"
@.str.26 = [24 x i8] c"R%d %d %d 0.4 20 80 37\0A\00"
@.str.27 = [14 x i8] c"I%d %d %d %g\0A\00"
@.str.28 = [23 x i8] c"R%d %d %d %g %g %g 37\0A\00"
@.str.29 = [23 x i8] c"I%d %d %d 1.23684e-05\0A\00"
@.str.30 = [24 x i8] c"R%d %d %d 0.5 10 50 37\0A\00"
@.str.31 = [14 x i8] c"V1 %d %d %g \0A\00"
@.str.32 = [5 x i8] c"\0A.op\00"
@.str.33 = [6 x i8] c"\0A.end\00"
@.str.34 = [20 x i8] c"*Layer Information\0A\00"
@.str.35 = [49 x i8] c"*Layer Index Unit_Res Min_Width Max_Current_Den\0A\00"
@.str.36 = [22 x i8] c"Layer 37 0.1 0.4 1.7\0A\00"
@.str.37 = [22 x i8] c"\0A*Voltage Constraint\0A\00"
@.str.38 = [19 x i8] c"Const V(%D) >= %G\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca [256 x i8]
%15 = alloca [256 x i8]
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca i32*
%25 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %11
store i32 1, i32* %12
store double 1.236840e-05, double* %18
store double 1.600000e+00, double* %20
store double 8.000000e-01, double* %23
%26 = load i32, i32* @stdout
%27 = call i32 @setbuf(i32 %26, i32 0)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double* %16)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double* %17)
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %9
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %10
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %47)
%49 = load double, double* %16
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), double %49)
%51 = load double, double* %17
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), double %51)
%53 = load i32, i32* %10
%54 = load i32, i32* %6
%55 = icmp sge i32 %53, %54
br i1 %55, label %56, label %60
56: ; preds = %2
%57 = load i32, i32* %10
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), i32 %57)
%59 = call i32 @exit(i32 -1)
unreachable
60: ; preds = %2
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%63 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %62)
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%66 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i8* %65)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %68, i32** %24
%69 = load i32*, i32** %24
%70 = icmp ne i32* %69, null
br i1 %70, label %75, label %71
71: ; preds = %60
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%73 = call i32 @perror(i8* %72)
%74 = call i32 @exit(i32 -1)
unreachable
75: ; preds = %60
%76 = load i32*, i32** %24
%77 = load i32, i32* %6
%78 = load i32, i32* %9
%79 = mul nsw i32 %77, %78
%80 = add nsw i32 %79, 1
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0), i32 %80)
%82 = load i32*, i32** %24
%83 = load i32, i32* %6
%84 = load i32, i32* %9
%85 = mul nsw i32 %83, %84
%86 = add nsw i32 %85, 2
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %86)
%88 = load i32*, i32** %24
%89 = load i32, i32* %9
%90 = load i32, i32* %6
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0), i32 %89, i32 %90)
store i32 0, i32* %8
br label %92
92: ; preds = %242, %75
%93 = load i32, i32* %8
%94 = load i32, i32* %9
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %245
96: ; preds = %92
%97 = load i32*, i32** %24
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0), i32 %99)
%101 = load i32, i32* %9
%102 = load i32, i32* %8
%103 = sub nsw i32 %101, %102
%104 = icmp sgt i32 %103, 1
br i1 %104, label %105, label %148
105: ; preds = %96
%106 = load i32, i32* %6
%107 = load i32, i32* %10
%108 = sdiv i32 %106, %107
store i32 %108, i32* %25
%109 = load i32, i32* %25
%110 = icmp slt i32 %109, 3
br i1 %110, label %111, label %115
111: ; preds = %105
%112 = load i32, i32* %25
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0), i32 %112)
%114 = call i32 @exit(i32 -1)
unreachable
115: ; preds = %105
%116 = load i32*, i32** %24
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %7
br label %118
118: ; preds = %144, %115
%119 = load i32, i32* %7
%120 = load i32, i32* %10
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %147
122: ; preds = %118
%123 = load i32*, i32** %24
%124 = load i32, i32* %11
%125 = add nsw i32 %124, 1
store i32 %125, i32* %11
%126 = load i32, i32* %8
%127 = load i32, i32* %6
%128 = mul nsw i32 %126, %127
%129 = load i32, i32* %25
%130 = load i32, i32* %7
%131 = add nsw i32 %130, 1
%132 = mul nsw i32 %129, %131
%133 = add nsw i32 %128, %132
%134 = load i32, i32* %8
%135 = add nsw i32 %134, 1
%136 = load i32, i32* %6
%137 = mul nsw i32 %135, %136
%138 = load i32, i32* %25
%139 = load i32, i32* %7
%140 = add nsw i32 %139, 1
%141 = mul nsw i32 %138, %140
%142 = add nsw i32 %137, %141
%143 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i64 0, i64 0), i32 %124, i32 %133, i32 %142)
br label %144
144: ; preds = %122
%145 = load i32, i32* %7
%146 = add nsw i32 %145, 1
store i32 %146, i32* %7
br label %118
147: ; preds = %118
br label %148
148: ; preds = %147, %96
%149 = load i32*, i32** %24
%150 = load i32, i32* %11
%151 = add nsw i32 %150, 1
store i32 %151, i32* %11
%152 = load i32, i32* %6
%153 = load i32, i32* %9
%154 = mul nsw i32 %152, %153
%155 = add nsw i32 %154, 1
%156 = load i32, i32* %8
%157 = load i32, i32* %6
%158 = mul nsw i32 %156, %157
%159 = add nsw i32 %158, 1
%160 = call i32 (i32*, i8*, ...) @fprintf(i32* %149, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0), i32 %150, i32 %155, i32 %159)
store i32 1, i32* %7
br label %161
161: ; preds = %216, %148
%162 = load i32, i32* %7
%163 = load i32, i32* %6
%164 = icmp slt i32 %162, %163
br i1 %164, label %165, label %219
165: ; preds = %161
%166 = load double, double* %18
%167 = call i32 (...) @rand()
%168 = srem i32 %167, 10
%169 = sitofp i32 %168 to double
%170 = fdiv double %169, 1.000000e+02
%171 = fmul double %166, %170
store double %171, double* %19
%172 = load i32*, i32** %24
%173 = load i32, i32* %12
%174 = add nsw i32 %173, 1
store i32 %174, i32* %12
%175 = load i32, i32* %7
%176 = load i32, i32* %8
%177 = load i32, i32* %6
%178 = mul nsw i32 %176, %177
%179 = add nsw i32 %175, %178
%180 = load double, double* %18
%181 = load double, double* %19
%182 = fadd double %180, %181
%183 = call i32 (i32*, i8*, ...) @fprintf(i32* %172, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.27, i64 0, i64 0), i32 %173, i32 %179, i32 0, double %182)
%184 = load double, double* %20
%185 = call i32 (...) @rand()
%186 = srem i32 %185, 10
%187 = sitofp i32 %186 to double
%188 = fdiv double %187, 1.000000e+02
%189 = fmul double %184, %188
store double %189, double* %21
%190 = load double, double* %23
%191 = load double, double* %21
%192 = load double, double* %20
%193 = fadd double %191, %192
%194 = fmul double %190, %193
%195 = fmul double %194, 1.000000e+01
store double %195, double* %22
%196 = load i32*, i32** %24
%197 = load i32, i32* %11
%198 = add nsw i32 %197, 1
store i32 %198, i32* %11
%199 = load i32, i32* %7
%200 = load i32, i32* %8
%201 = load i32, i32* %6
%202 = mul nsw i32 %200, %201
%203 = add nsw i32 %199, %202
%204 = load i32, i32* %7
%205 = add nsw i32 %204, 1
%206 = load i32, i32* %8
%207 = load i32, i32* %6
%208 = mul nsw i32 %206, %207
%209 = add nsw i32 %205, %208
%210 = load double, double* %20
%211 = load double, double* %21
%212 = fadd double %210, %211
%213 = load double, double* %23
%214 = load double, double* %22
%215 = call i32 (i32*, i8*, ...) @fprintf(i32* %196, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.28, i64 0, i64 0), i32 %197, i32 %203, i32 %209, double %212, double %213, double %214)
br label %216
216: ; preds = %165
%217 = load i32, i32* %7
%218 = add nsw i32 %217, 1
store i32 %218, i32* %7
br label %161
219: ; preds = %161
%220 = load i32*, i32** %24
%221 = load i32, i32* %12
%222 = add nsw i32 %221, 1
store i32 %222, i32* %12
%223 = load i32, i32* %7
%224 = load i32, i32* %8
%225 = load i32, i32* %6
%226 = mul nsw i32 %224, %225
%227 = add nsw i32 %223, %226
%228 = call i32 (i32*, i8*, ...) @fprintf(i32* %220, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.29, i64 0, i64 0), i32 %221, i32 %227, i32 0)
%229 = load i32*, i32** %24
%230 = load i32, i32* %11
%231 = add nsw i32 %230, 1
store i32 %231, i32* %11
%232 = load i32, i32* %7
%233 = load i32, i32* %8
%234 = load i32, i32* %6
%235 = mul nsw i32 %233, %234
%236 = add nsw i32 %232, %235
%237 = load i32, i32* %6
%238 = load i32, i32* %9
%239 = mul nsw i32 %237, %238
%240 = add nsw i32 %239, 1
%241 = call i32 (i32*, i8*, ...) @fprintf(i32* %229, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.30, i64 0, i64 0), i32 %230, i32 %236, i32 %240)
br label %242
242: ; preds = %219
%243 = load i32, i32* %8
%244 = add nsw i32 %243, 1
store i32 %244, i32* %8
br label %92
245: ; preds = %92
%246 = load i32*, i32** %24
%247 = load i32, i32* %9
%248 = load i32, i32* %6
%249 = mul nsw i32 %247, %248
%250 = add nsw i32 %249, 1
%251 = load double, double* %16
%252 = call i32 (i32*, i8*, ...) @fprintf(i32* %246, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.31, i64 0, i64 0), i32 %250, i32 0, double %251)
%253 = load i32*, i32** %24
%254 = call i32 (i32*, i8*, ...) @fprintf(i32* %253, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.32, i64 0, i64 0))
%255 = load i32*, i32** %24
%256 = call i32 (i32*, i8*, ...) @fprintf(i32* %255, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.33, i64 0, i64 0))
%257 = load i32*, i32** %24
%258 = call i32 @fclose(i32* %257)
%259 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%260 = call i32* @fopen(i8* %259, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %260, i32** %24
%261 = load i32*, i32** %24
%262 = icmp ne i32* %261, null
br i1 %262, label %267, label %263
263: ; preds = %245
%264 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%265 = call i32 @perror(i8* %264)
%266 = call i32 @exit(i32 -1)
unreachable
267: ; preds = %245
%268 = load i32*, i32** %24
%269 = call i32 (i32*, i8*, ...) @fprintf(i32* %268, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.34, i64 0, i64 0))
%270 = load i32*, i32** %24
%271 = call i32 (i32*, i8*, ...) @fprintf(i32* %270, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.35, i64 0, i64 0))
%272 = load i32*, i32** %24
%273 = call i32 (i32*, i8*, ...) @fprintf(i32* %272, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.36, i64 0, i64 0))
%274 = load i32*, i32** %24
%275 = call i32 (i32*, i8*, ...) @fprintf(i32* %274, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.37, i64 0, i64 0))
store i32 1, i32* %7
br label %276
276: ; preds = %289, %267
%277 = load i32, i32* %7
%278 = load i32, i32* %9
%279 = load i32, i32* %6
%280 = mul nsw i32 %278, %279
%281 = icmp sle i32 %277, %280
br i1 %281, label %282, label %292
282: ; preds = %276
%283 = load i32*, i32** %24
%284 = load i32, i32* %7
%285 = load double, double* %16
%286 = load double, double* %17
%287 = fsub double %285, %286
%288 = call i32 (i32*, i8*, ...) @fprintf(i32* %283, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.38, i64 0, i64 0), i32 %284, double %287)
br label %289
289: ; preds = %282
%290 = load i32, i32* %7
%291 = add nsw i32 %290, 1
store i32 %291, i32* %7
br label %276
292: ; preds = %276
%293 = load i32*, i32** %24
%294 = call i32 @fclose(i32* %293)
%295 = load i32, i32* %3
ret i32 %295
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [10 x i8] c"#segment:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"#R-I section in each segment:\00"
@.str.3 = [25 x i8] c"# strip in each segment:\00"
@.str.4 = [10 x i8] c"fileroot:\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [16 x i8] c"voltage source:\00"
@.str.7 = [4 x i8] c"%lf\00"
@.str.8 = [16 x i8] c"voltage offset:\00"
@.str.9 = [10 x i8] c"#sec: %d\0A\00"
@.str.10 = [10 x i8] c"#seg: %d\0A\00"
@.str.11 = [21 x i8] c"#vertical strip: %d\0A\00"
@.str.12 = [14 x i8] c"filename: %s\0A\00"
@.str.13 = [13 x i8] c"voltage: %g\0A\00"
@.str.14 = [20 x i8] c"voltage offset: %g\0A\00"
@.str.15 = [28 x i8] c"Invalid p/g strip number %d\00"
@.str.16 = [6 x i8] c"%s.sp\00"
@.str.17 = [6 x i8] c"%s.cs\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [13 x i8] c"num_node %d\0A\00"
@.str.20 = [17 x i8] c"matrix_size %d\0A\0A\00"
@.str.21 = [26 x i8] c"* %d x %d ground network\0A\00"
@.str.22 = [10 x i8] c"*seg: %d\0A\00"
@.str.23 = [38 x i8] c"Serise chain circuit is too small: %d\00"
@.str.24 = [28 x i8] c"* inter-segment connection\0A\00"
@.str.25 = [29 x i8] c"R%d %d %d 6.16 0.8 49.28 37\0A\00"
@.str.26 = [24 x i8] c"R%d %d %d 0.4 20 80 37\0A\00"
@.str.27 = [14 x i8] c"I%d %d %d %g\0A\00"
@.str.28 = [23 x i8] c"R%d %d %d %g %g %g 37\0A\00"
@.str.29 = [23 x i8] c"I%d %d %d 1.23684e-05\0A\00"
@.str.30 = [24 x i8] c"R%d %d %d 0.5 10 50 37\0A\00"
@.str.31 = [14 x i8] c"V1 %d %d %g \0A\00"
@.str.32 = [5 x i8] c"\0A.op\00"
@.str.33 = [6 x i8] c"\0A.end\00"
@.str.34 = [20 x i8] c"*Layer Information\0A\00"
@.str.35 = [49 x i8] c"*Layer Index Unit_Res Min_Width Max_Current_Den\0A\00"
@.str.36 = [22 x i8] c"Layer 37 0.1 0.4 1.7\0A\00"
@.str.37 = [22 x i8] c"\0A*Voltage Constraint\0A\00"
@.str.38 = [19 x i8] c"Const V(%D) >= %G\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca double
%10 = alloca double
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%17 = bitcast double* %9 to i8*
%18 = bitcast double* %10 to i8*
%19 = load i32, i32* @stdout
%20 = tail call i32 @setbuf(i32 %19, i32 0)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double* %9)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double* %10)
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %5
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %14)
%40 = load double, double* %9
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), double %40)
%42 = load double, double* %10
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), double %42)
%44 = load i32, i32* %5
%45 = load i32, i32* %3
%46 = icmp slt i32 %44, %45
br i1 %46, label %50, label %47
47: ; preds = %2
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), i32 %44)
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %2
%51 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %14)
%52 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i8* %14)
%53 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 @perror(i8* %15)
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %50
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = mul nsw i32 %60, %59
%62 = add nsw i32 %61, 1
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %3
%65 = load i32, i32* %4
%66 = mul nsw i32 %65, %64
%67 = add nsw i32 %66, 2
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %4
%70 = load i32, i32* %3
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0), i32 %69, i32 %70)
%72 = load i32, i32* %4
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %173
74: ; preds = %58, %153
%75 = phi i32 [ %78, %153 ], [ 0, %58 ]
%76 = phi i32 [ %163, %153 ], [ 1, %58 ]
%77 = phi i32 [ %159, %153 ], [ 1, %58 ]
%78 = add nuw nsw i32 %75, 1
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %4
%81 = sub nsw i32 %80, %75
%82 = icmp sgt i32 %81, 1
br i1 %82, label %83, label %109
83: ; preds = %74
%84 = load i32, i32* %3
%85 = load i32, i32* %5
%86 = sdiv i32 %84, %85
%87 = icmp slt i32 %86, 3
br i1 %87, label %88, label %91
88: ; preds = %83
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0), i32 %86)
%90 = call i32 @exit(i32 -1)
unreachable
91: ; preds = %83
%92 = call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0), i64 27, i64 1, i32* %53)
%93 = load i32, i32* %5
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %109
95: ; preds = %91, %95
%96 = phi i32 [ %101, %95 ], [ 0, %91 ]
%97 = phi i32 [ %98, %95 ], [ %76, %91 ]
%98 = add nsw i32 %97, 1
%99 = load i32, i32* %3
%100 = mul nsw i32 %99, %75
%101 = add nuw nsw i32 %96, 1
%102 = mul nsw i32 %101, %86
%103 = add nsw i32 %100, %102
%104 = mul nsw i32 %99, %78
%105 = add nsw i32 %104, %102
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i64 0, i64 0), i32 %97, i32 %103, i32 %105)
%107 = load i32, i32* %5
%108 = icmp slt i32 %101, %107
br i1 %108, label %95, label %109
109: ; preds = %95, %91, %74
%110 = phi i32 [ %76, %74 ], [ %76, %91 ], [ %98, %95 ]
%111 = load i32, i32* %3
%112 = load i32, i32* %4
%113 = mul nsw i32 %112, %111
%114 = add nsw i32 %113, 1
%115 = mul nsw i32 %111, %75
%116 = add nsw i32 %115, 1
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0), i32 %110, i32 %114, i32 %116)
%118 = add nsw i32 %110, 1
%119 = load i32, i32* %3
%120 = icmp sgt i32 %119, 1
br i1 %120, label %121, label %153
121: ; preds = %109, %121
%122 = phi i32 [ %150, %121 ], [ %118, %109 ]
%123 = phi i32 [ %147, %121 ], [ 1, %109 ]
%124 = phi i32 [ %130, %121 ], [ %77, %109 ]
%125 = call i32 (...) @rand()
%126 = srem i32 %125, 10
%127 = sitofp i32 %126 to double
%128 = fdiv double %127, 1.000000e+02
%129 = fmul double %128, 1.236840e-05
%130 = add nsw i32 %124, 1
%131 = load i32, i32* %3
%132 = mul nsw i32 %131, %75
%133 = add nsw i32 %132, %123
%134 = fadd double %129, 1.236840e-05
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.27, i64 0, i64 0), i32 %124, i32 %133, i32 0, double %134)
%136 = call i32 (...) @rand()
%137 = srem i32 %136, 10
%138 = sitofp i32 %137 to double
%139 = fdiv double %138, 1.000000e+02
%140 = fmul double %139, 1.600000e+00
%141 = fadd double %140, 1.600000e+00
%142 = fmul double %141, 8.000000e-01
%143 = fmul double %142, 1.000000e+01
%144 = load i32, i32* %3
%145 = mul nsw i32 %144, %75
%146 = add nsw i32 %145, %123
%147 = add nuw nsw i32 %123, 1
%148 = add nsw i32 %145, %147
%149 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.28, i64 0, i64 0), i32 %122, i32 %146, i32 %148, double %141, double 8.000000e-01, double %143)
%150 = add nsw i32 %122, 1
%151 = load i32, i32* %3
%152 = icmp slt i32 %147, %151
br i1 %152, label %121, label %153
153: ; preds = %121, %109
%154 = phi i32 [ %77, %109 ], [ %130, %121 ]
%155 = phi i32 [ %110, %109 ], [ %122, %121 ]
%156 = phi i32 [ 1, %109 ], [ %147, %121 ]
%157 = phi i32 [ %118, %109 ], [ %150, %121 ]
%158 = phi i32 [ %119, %109 ], [ %151, %121 ]
%159 = add nsw i32 %154, 1
%160 = mul nsw i32 %158, %75
%161 = add nsw i32 %160, %156
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.29, i64 0, i64 0), i32 %154, i32 %161, i32 0)
%163 = add nsw i32 %155, 2
%164 = load i32, i32* %3
%165 = mul nsw i32 %164, %75
%166 = add nsw i32 %165, %156
%167 = load i32, i32* %4
%168 = mul nsw i32 %167, %164
%169 = add nsw i32 %168, 1
%170 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.30, i64 0, i64 0), i32 %157, i32 %166, i32 %169)
%171 = load i32, i32* %4
%172 = icmp slt i32 %78, %171
br i1 %172, label %74, label %173
173: ; preds = %153, %58
%174 = phi i32 [ %72, %58 ], [ %171, %153 ]
%175 = load i32, i32* %3
%176 = mul nsw i32 %175, %174
%177 = add nsw i32 %176, 1
%178 = load double, double* %9
%179 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.31, i64 0, i64 0), i32 %177, i32 0, double %178)
%180 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.32, i64 0, i64 0), i64 4, i64 1, i32* %53)
%181 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.33, i64 0, i64 0), i64 5, i64 1, i32* %53)
%182 = call i32 @fclose(i32* %53)
%183 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%184 = icmp eq i32* %183, null
br i1 %184, label %185, label %188
185: ; preds = %173
%186 = call i32 @perror(i8* %16)
%187 = call i32 @exit(i32 -1)
unreachable
188: ; preds = %173
%189 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.34, i64 0, i64 0), i64 19, i64 1, i32* %183)
%190 = call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.35, i64 0, i64 0), i64 48, i64 1, i32* %183)
%191 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.36, i64 0, i64 0), i64 21, i64 1, i32* %183)
%192 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.37, i64 0, i64 0), i64 21, i64 1, i32* %183)
%193 = load i32, i32* %4
%194 = load i32, i32* %3
%195 = mul nsw i32 %194, %193
%196 = icmp slt i32 %195, 1
br i1 %196, label %208, label %197
197: ; preds = %188, %197
%198 = phi i32 [ %203, %197 ], [ 1, %188 ]
%199 = load double, double* %9
%200 = load double, double* %10
%201 = fsub double %199, %200
%202 = call i32 (i32*, i8*, ...) @fprintf(i32* %183, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.38, i64 0, i64 0), i32 %198, double %201)
%203 = add nuw nsw i32 %198, 1
%204 = load i32, i32* %4
%205 = load i32, i32* %3
%206 = mul nsw i32 %205, %204
%207 = icmp slt i32 %198, %206
br i1 %207, label %197, label %208
208: ; preds = %197, %188
%209 = call i32 @fclose(i32* %183)
ret i32 0
}