#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 /*<<< orphan*/ SIGABRT;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, long long);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sched_exit(int /*<<< orphan*/);
int sched_getpid();
int /*<<< orphan*/ stderr;
void child_fcn() {
  long long i;
  for (i = 0; i < 2000000001; ++i) {
    if (i % 200000000 == 0) {
      fprintf(stderr, "In PID %d, i = %lld\n", sched_getpid(), i);
      kill(getpid(), SIGABRT);
    }
  }
  sched_exit(0);
}


x86 assembly (clang, -O0):
<child_fcn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
cmpq   $0x77359401,-0x8(%rbp)
77
jge    11db <child_fcn+0x8b>
mov    -0x8(%rbp),%rax
mov    $0xbebc200,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11c5 <child_fcn+0x75>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1070 <sched_getpid@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
mov    -0x8(%rbp),%rcx
lea    0xe57(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
jmp    11ca <child_fcn+0x7a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1160 <child_fcn+0x10>
xor    %edi,%edi
call   1060 <sched_exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<child_fcn>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e81(%rip),%r15
lea    0xe9a(%rip),%r14
mov    0x2e6b(%rip),%r12
xor    %ebx,%ebx
jmp    118d <child_fcn+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x77359401,%rbx
je     11d1 <child_fcn+0x81>
mov    %ebx,%eax
imul   $0x55e63b89,%rax,%rax
shr    $0x3a,%rax
imul   $0xf4143e00,%eax,%eax
add    %ebx,%eax
jne    1180 <child_fcn+0x30>
mov    (%r15),%ebp
xor    %eax,%eax
call   1070 <sched_getpid@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%r12),%esi
mov    %eax,%edi
call   1050 <kill@plt>
jmp    1180 <child_fcn+0x30>
xor    %edi,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <sched_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"In PID %d, i = %lld\0A\00"
@SIGABRT = global i32 0
define void @child_fcn() {
%1 = alloca i64
store i64 0, i64* %1
br label %2
2: ; preds = %18, %0
%3 = load i64, i64* %1
%4 = icmp slt i64 %3, 2000000001
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = load i64, i64* %1
%7 = srem i64 %6, 200000000
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = call i32 (...) @sched_getpid()
%12 = load i64, i64* %1
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11, i64 %12)
%14 = call i32 (...) @getpid()
%15 = load i32, i32* @SIGABRT
%16 = call i32 @kill(i32 %14, i32 %15)
br label %17
17: ; preds = %9, %5
br label %18
18: ; preds = %17
%19 = load i64, i64* %1
%20 = add nsw i64 %19, 1
store i64 %20, i64* %1
br label %2
21: ; preds = %2
%22 = call i32 @sched_exit(i32 0)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"In PID %d, i = %lld\0A\00"
@SIGABRT = global i32 0
define void @child_fcn() {
br label %1
1: ; preds = %0, %13
%2 = phi i64 [ 0, %0 ], [ %14, %13 ]
%3 = trunc i64 %2 to i32
%4 = urem i32 %3, 200000000
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 (...) @sched_getpid()
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %8, i64 %2)
%10 = tail call i32 (...) @getpid()
%11 = load i32, i32* @SIGABRT
%12 = tail call i32 @kill(i32 %10, i32 %11)
br label %13
13: ; preds = %1, %6
%14 = add nuw nsw i64 %2, 1
%15 = icmp eq i64 %14, 2000000001
br i1 %15, label %16, label %1
16: ; preds = %13
%17 = tail call i32 @sched_exit(i32 0)
ret void
}