#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 /*<<< orphan*/ strlen(char *);
int main(void) {
  FILE *pp, *in, *result;
  char out_name[128], in_name[128];
  int i, j;
  result = fopen("result.txt", "wb");
  for (i = 32; i < 321; i += 32) {
    for (j = 32; j < 513; j += 32) {
      char command[128];
      sprintf(in_name, "%d_%d.param", i, j);
      sprintf(command, "./a.out 3 %s", in_name);
      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    $0x5b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x20,-0x124(%rbp)
cmpl   $0x141,-0x124(%rbp)
jge    1309 <main+0x179>
movl   $0x20,-0x128(%rbp)
cmpl   $0x201,-0x128(%rbp)
jge    12f0 <main+0x160>
lea    -0x120(%rbp),%rdi
mov    -0x124(%rbp),%edx
mov    -0x128(%rbp),%ecx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x124(%rbp),%esi
mov    -0x128(%rbp),%edx
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12d7 <main+0x147>
jmp    1269 <main+0xd9>
lea    -0x5a0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
mov    %rax,-0x1b8(%rbp)
cmpq   $0x0,-0x1b8(%rbp)
jne    1298 <main+0x108>
jmp    12ce <main+0x13e>
lea    -0x5a0(%rbp),%rax
mov    %rax,-0x5a8(%rbp)
lea    -0x5a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5a8(%rbp),%rdi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    1269 <main+0xd9>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
jmp    12dc <main+0x14c>
mov    -0x128(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x128(%rbp)
jmp    11dd <main+0x4d>
jmp    12f5 <main+0x165>
mov    -0x124(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x124(%rbp)
jmp    11c3 <main+0x33>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x5b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e8,%rsp
lea    0xe58(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    $0x20,%r14d
lea    0x100(%rsp),%r15
jmp    11e4 <main+0x54>
nopw   0x0(%rax,%rax,1)
lea    0x20(%r14),%eax
cmp    $0x121,%r14d
mov    %eax,%r14d
jae    12a5 <main+0x115>
mov    $0x20,%r13d
jmp    1208 <main+0x78>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1060 <pclose@plt>
lea    0x20(%r13),%eax
cmp    $0x1e1,%r13d
mov    %eax,%r13d
jae    11d0 <main+0x40>
lea    0x80(%rsp),%rbp
mov    %rbp,%rdi
lea    0xdf4(%rip),%rsi
mov    %r14d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rsp,%r12
mov    %r12,%rdi
lea    0xde6(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xde2(%rip),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
call   1050 <printf@plt>
mov    %r12,%rdi
lea    0xddb(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     11f8 <main+0x68>
mov    %rax,%r12
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
jmp    1270 <main+0xe0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x4e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"result.txt\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [12 x i8] c"%d_%d.param\00"
@.str.3 = [13 x i8] c"./a.out 3 %s\00"
@.str.4 = [14 x i8] c"i=%d , j=%d \0A\00"
@.str.5 = [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 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %0, %30
%9 = phi i32 [ 32, %0 ], [ %31, %30 ]
br label %10
10: ; preds = %8, %27
%11 = phi i32 [ 32, %8 ], [ %28, %27 ]
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %11)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %9, i32 %11)
%15 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %27, label %17
17: ; preds = %10
%18 = call i8* @fgets(i8* %7, 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* %7)
%22 = call i32 @fwrite(i8* %7, i32 1, i32 %21, i32* %5)
%23 = call i8* @fgets(i8* %7, 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, %10
%28 = add nuw nsw i32 %11, 32
%29 = icmp ult i32 %11, 481
br i1 %29, label %10, label %30
30: ; preds = %27
%31 = add nuw nsw i32 %9, 32
%32 = icmp ult i32 %9, 289
br i1 %32, label %8, label %33
33: ; preds = %30
%34 = call i32 @fclose(i32* %5)
ret i32 0
}