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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getpid();
int main(int argc, char *argv[]) {
  int i;
  FILE *archivo;
  archivo = fopen("salida.txt", "w");
  i = 0;
  while (i < 1000) {
    double aux = 2.5 * 4.3;
    fprintf(archivo, "Soy el proceso hijo \n");
    i++;
  }
  fprintf(archivo, "Mi PID es %i \n", getpid());
  fclose(archivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeab(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    11ae <main+0x6e>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x34>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xea5(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    $0x3e8,%ebp
lea    0xe97(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    $0x15,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1070 <fwrite@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x30>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"salida.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"Soy el proceso hijo \0A\00"
@.str.3 = [15 x i8] c"Mi PID es %i \0A\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 double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
store i32 0, i32* %6
br label %10
10: ; preds = %13, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %18
13: ; preds = %10
store double 1.075000e+01, double* %8
%14 = load i32*, i32** %7
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %10
18: ; preds = %10
%19 = load i32*, i32** %7
%20 = call i32 (...) @getpid()
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %7
%23 = call i32 @fclose(i32* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"salida.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"Soy el proceso hijo \0A\00"
@.str.3 = [15 x i8] c"Mi PID es %i \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %7, %4 ]
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 21, i64 1, i32* %3)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 1000
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 (...) @getpid()
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = tail call i32 @fclose(i32* %3)
ret i32 0
}