#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char **argv) {
  if (argc < 3)
    exit(1);
  int count_files = atoi(argv[1]), count_num = atoi(argv[2]), offset = 1;
  char count_num_str[10];
  sprintf(count_num_str, "%d", count_num);
  for (int i = 0; i < count_files; i++) {
    char i_str[10], offset_str[10];
    sprintf(i_str, "%d", i);
    sprintf(offset_str, "%d", offset);
    if (!fork())
      execl("./helper", i_str, offset_str, count_num_str, NULL);
    offset += count_num;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    117a <main+0x2a>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x26(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe51(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1231 <main+0xe1>
lea    -0x36(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe2b(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe18(%rip),%rsi
call   1040 <sprintf@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    121a <main+0xca>
lea    -0x36(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x26(%rbp),%rcx
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <execl@plt>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <main+0x6b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jle    1213 <main+0xc3>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1030 <atoi@plt>
mov    %eax,%r15d
lea    0xe77(%rip),%rsi
lea    0x14(%rsp),%rdi
mov    %eax,%edx
call   1040 <sprintf@plt>
test   %r14d,%r14d
jle    1202 <main+0xb2>
mov    $0x1,%ebx
lea    0xe5a(%rip),%rbp
lea    0x1e(%rsp),%r13
xor    %r12d,%r12d
jmp    11bc <main+0x6c>
add    %r15d,%ebx
add    $0x1,%r12d
cmp    %r12d,%r14d
je     1202 <main+0xb2>
lea    0xa(%rsp),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1040 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    11b0 <main+0x60>
lea    0xe18(%rip),%rdi
lea    0xa(%rsp),%rsi
mov    %r13,%rdx
lea    0x14(%rsp),%rcx
xor    %r8d,%r8d
call   1060 <execl@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"./helper\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 [10 x i8]
%10 = alloca i32
%11 = alloca [10 x i8]
%12 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
store i32 1, i32* %8
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 0, i32* %10
br label %29
29: ; preds = %51, %17
%30 = load i32, i32* %10
%31 = load i32, i32* %6
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %54
33: ; preds = %29
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%35 = load i32, i32* %10
%36 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%38 = load i32, i32* %8
%39 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = call i32 (...) @fork()
%41 = icmp ne i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %33
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%46 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %43, i8* %44, i8* %45, i32* null)
br label %47
47: ; preds = %42, %33
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = add nsw i32 %49, %48
store i32 %50, i32* %8
br label %51
51: ; preds = %47
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %29
54: ; preds = %29
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"./helper\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%18 = icmp sgt i32 %12, 0
br i1 %18, label %19, label %22
19: ; preds = %9
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
br label %23
22: ; preds = %32, %9
ret i32 0
23: ; preds = %19, %32
%24 = phi i32 [ 0, %19 ], [ %34, %32 ]
%25 = phi i32 [ 1, %19 ], [ %33, %32 ]
%26 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%27 = call i32 @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%28 = call i32 (...) @fork()
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21, i8* %16, i32* null)
br label %32
32: ; preds = %30, %23
%33 = add nsw i32 %25, %15
%34 = add nuw nsw i32 %24, 1
%35 = icmp eq i32 %34, %12
br i1 %35, label %22, label %23
}