#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*/ exit(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  int i;
  for (i = 0; i < atoi(argv[2]); i++) {
    printf("[child %d] step %d\n", atoi(argv[1]), i);
    sleep(1);
  }
  exit(i);
  return i;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11b3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
mov    -0x14(%rbp),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1040 <atoi@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    118f <main+0x4f>
xor    %ebp,%ebp
lea    0xea1(%rip),%r14
nop
mov    0x8(%rbx),%rdi
call   1040 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
add    $0x1,%ebp
mov    0x10(%rbx),%rdi
call   1040 <atoi@plt>
cmp    %eax,%ebp
jl     1160 <main+0x20>
mov    %ebp,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"[child %d] step %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %22, %2
%8 = load i32, i32* %6
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
%13 = icmp slt i32 %8, %12
br i1 %13, label %14, label %25
14: ; preds = %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
%21 = call i32 @sleep(i32 1)
br label %22
22: ; preds = %14
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %7
25: ; preds = %7
%26 = load i32, i32* %6
%27 = call i32 @exit(i32 %26)
unreachable
}

LLVM IR (-O2):
@.str = [20 x i8] c"[child %d] step %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %15, %9 ]
%11 = load i8*, i8** %8
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %10)
%14 = tail call i32 @sleep(i32 1)
%15 = add nuw nsw i32 %10, 1
%16 = load i8*, i8** %3
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %9, label %19
19: ; preds = %9, %2
%20 = phi i32 [ 0, %2 ], [ %15, %9 ]
%21 = tail call i32 @exit(i32 %20)
unreachable
}