#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 pid_t;

/* Variables and functions */
int getpid();
int /*<<< orphan*/ printf(char *, ...);
void trabajo_padre(pid_t resultado_fork) {
  int i;
  for (i = 1; i <= 200000; i++)
    printf("padre trabajando (%d:%d), valor = %d\n", getpid(), resultado_fork,
           i);
  printf("*** proceso hijo finalizado ***\n");
  return;
}


x86 assembly (clang, -O0):
<trabajo_padre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x30d40,-0x8(%rbp)
jg     116a <trabajo_padre+0x4a>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <trabajo_padre+0x12>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trabajo_padre>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x1,%ebp
lea    0xebe(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x30d41,%ebp
jne    1150 <trabajo_padre+0x20>
lea    0xead(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"padre trabajando (%d:%d), valor = %d\0A\00"
@.str.1 = [33 x i8] c"*** proceso hijo finalizado ***\0A\00"
define void @trabajo_padre(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %12, %1
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 200000
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i32 (...) @getpid()
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"padre trabajando (%d:%d), valor = %d\0A\00"
@str = [32 x i8] c"*** proceso hijo finalizado ***\00"
define void @trabajo_padre(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 1, %1 ], [ %6, %2 ]
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %0, i32 %3)
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 200001
br i1 %7, label %8, label %2
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
ret void
}