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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  FILE *pp, *in, *result;
  char out_name[128];
  int i, j;
  for (i = 32; i < 321; i += 32) {
    for (j = 32; j < 513; j += 32) {
      char command[128];
      sprintf(command, "sudo ./genaparam %d %d", i, j);
      sprintf(out_name, "%d_%d.param", i, j);
      result = fopen(out_name, "wb");
      printf("i = %d, j= %d\n", i, j);
      pp = popen(command, "r");
      if (pp != NULL) {
        while (1) {
          char *line;
          char buf[1000];
          line = fgets(buf, sizeof(buf), pp);
          if (line == NULL)
            break;
          fwrite(buf, 1, strlen(buf), result);
        }
        pclose(pp);
      }
      fclose(result);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x20,-0xa4(%rbp)
cmpl   $0x141,-0xa4(%rbp)
jge    130e <main+0x17e>
movl   $0x20,-0xa8(%rbp)
cmpl   $0x201,-0xa8(%rbp)
jge    12f5 <main+0x165>
lea    -0x130(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0xa8(%rbp),%ecx
lea    0xe10(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0xa8(%rbp),%ecx
lea    0xe08(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0xa4(%rbp),%esi
mov    -0xa8(%rbp),%edx
lea    0xde8(%rip),%rdi
call   1050 <printf@plt>
lea    -0x130(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12d8 <main+0x148>
jmp    126a <main+0xda>
lea    -0x520(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    1299 <main+0x109>
jmp    12cf <main+0x13f>
lea    -0x520(%rbp),%rax
mov    %rax,-0x528(%rbp)
lea    -0x520(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x528(%rbp),%rdi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    126a <main+0xda>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xa8(%rbp)
jmp    11c6 <main+0x36>
jmp    12fa <main+0x16a>
mov    -0xa4(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xa4(%rbp)
jmp    11ac <main+0x1c>
xor    %eax,%eax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e8,%rsp
mov    $0x20,%r13d
lea    0x100(%rsp),%rbp
jmp    11d4 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x20(%r13),%eax
cmp    $0x121,%r13d
mov    %eax,%r13d
jae    12b5 <main+0x125>
mov    $0x20,%r14d
jmp    1200 <main+0x70>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1060 <pclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    0x20(%r14),%eax
cmp    $0x1e1,%r14d
mov    %eax,%r14d
jae    11c0 <main+0x30>
mov    %rsp,%r15
mov    %r15,%rdi
lea    0xdf3(%rip),%rsi
mov    %r13d,%edx
mov    %r14d,%ecx
call   10a0 <sprintf@plt>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
lea    0xded(%rip),%rsi
mov    %r13d,%edx
mov    %r14d,%ecx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xde4(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0xdd8(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0xdd2(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     11e8 <main+0x58>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11e0 <main+0x50>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r12,%rcx
call   10b0 <fwrite@plt>
jmp    1280 <main+0xf0>
xor    %eax,%eax
add    $0x4e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"sudo ./genaparam %d %d\00"
@.str.1 = [12 x i8] c"%d_%d.param\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [15 x i8] c"i = %d, j= %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [128 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [128 x i8]
%9 = alloca i8*
%10 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 32, i32* %6
br label %11
11: ; preds = %60, %0
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 321
br i1 %13, label %14, label %63
14: ; preds = %11
store i32 32, i32* %7
br label %15
15: ; preds = %56, %14
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 513
br i1 %17, label %18, label %59
18: ; preds = %15
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %28, i32** %4
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %30)
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%33 = call i32* @popen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %33, i32** %2
%34 = load i32*, i32** %2
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %53
36: ; preds = %18
br label %37
37: ; preds = %36, %44
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%39 = load i32*, i32** %2
%40 = call i8* @fgets(i8* %38, i32 1000, i32* %39)
store i8* %40, i8** %9
%41 = load i8*, i8** %9
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %44
43: ; preds = %37
br label %50
44: ; preds = %37
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = load i32*, i32** %4
%49 = call i32 @fwrite(i8* %45, i32 1, i32 %47, i32* %48)
br label %37
50: ; preds = %43
%51 = load i32*, i32** %2
%52 = call i32 @pclose(i32* %51)
br label %53
53: ; preds = %50, %18
%54 = load i32*, i32** %4
%55 = call i32 @fclose(i32* %54)
br label %56
56: ; preds = %53
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 32
store i32 %58, i32* %7
br label %15
59: ; preds = %15
br label %60
60: ; preds = %59
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 32
store i32 %62, i32* %6
br label %11
63: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"sudo ./genaparam %d %d\00"
@.str.1 = [12 x i8] c"%d_%d.param\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [15 x i8] c"i = %d, j= %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %0, %31
%8 = phi i32 [ 32, %0 ], [ %32, %31 ]
br label %9
9: ; preds = %7, %27
%10 = phi i32 [ 32, %7 ], [ %29, %27 ]
%11 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10)
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
%13 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %8, i32 %10)
%15 = call i32* @popen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %27, label %17
17: ; preds = %9
%18 = call i8* @fgets(i8* %6, i32 1000, i32* %15)
%19 = icmp eq i8* %18, null
br i1 %19, label %25, label %20
20: ; preds = %17, %20
%21 = call i32 @strlen(i8* %6)
%22 = call i32 @fwrite(i8* %6, i32 1, i32 %21, i32* %13)
%23 = call i8* @fgets(i8* %6, i32 1000, i32* %15)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %20
25: ; preds = %20, %17
%26 = call i32 @pclose(i32* %15)
br label %27
27: ; preds = %25, %9
%28 = call i32 @fclose(i32* %13)
%29 = add nuw nsw i32 %10, 32
%30 = icmp ult i32 %10, 481
br i1 %30, label %9, label %31
31: ; preds = %27
%32 = add nuw nsw i32 %8, 32
%33 = icmp ult i32 %8, 289
br i1 %33, label %7, label %34
34: ; preds = %31
ret i32 0
}