#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *generateLogTime(char *);
int /*<<< orphan*/ printQuery(int /*<<< orphan*/ *, int, char *,
                              int /*<<< orphan*/, int);
void printProcessLogs(FILE *fLogFile, int pid, int fdStatProc, int fdStatm) {
  char timeStr[256] = "";
  fprintf(fLogFile, "[%s] Process(%d) ", generateLogTime(timeStr), pid);
  printQuery(fLogFile, fdStatProc, " [STAT] executable", 0, 1);
  printQuery(fLogFile, fdStatProc, " stat", 0, 2);
  printQuery(fLogFile, fdStatProc, " minorfaults", 0, 9);
  printQuery(fLogFile, fdStatProc, " majorfaults", 0, 11);
  printQuery(fLogFile, fdStatProc, " usermodetime", 0, 13);
  printQuery(fLogFile, fdStatProc, " kernelmodetime", 0, 14);
  printQuery(fLogFile, fdStatProc, " priority", 0, 17);
  printQuery(fLogFile, fdStatProc, " nice", 0, 18);
  printQuery(fLogFile, fdStatProc, " nothreads", 0, 19);
  printQuery(fLogFile, fdStatProc, " vsize", 0, 22);
  printQuery(fLogFile, fdStatProc, " rss", 0, 23);
  fprintf(fLogFile, " [STATM]");
  printQuery(fLogFile, fdStatm, " program", 0, 0);
  printQuery(fLogFile, fdStatm, " residentset", 0, 1);
  printQuery(fLogFile, fdStatm, " share", 0, 2);
  printQuery(fLogFile, fdStatm, " text", 0, 3);
  printQuery(fLogFile, fdStatm, " data", 0, 5);
  fprintf(fLogFile, "\n");
  return;
}


x86 assembly (clang, -O0):
<printProcessLogs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1060 <generateLogTime@plt>
mov    -0x128(%rbp),%rdi
mov    %rax,%rdx
mov    -0xc(%rbp),%ecx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe67(%rip),%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe5f(%rip),%rdx
xor    %ecx,%ecx
mov    $0x2,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe4a(%rip),%rdx
xor    %ecx,%ecx
mov    $0x9,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe3c(%rip),%rdx
xor    %ecx,%ecx
mov    $0xb,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe2e(%rip),%rdx
xor    %ecx,%ecx
mov    $0xd,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe21(%rip),%rdx
xor    %ecx,%ecx
mov    $0xe,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe16(%rip),%rdx
xor    %ecx,%ecx
mov    $0x11,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xe05(%rip),%rdx
xor    %ecx,%ecx
mov    $0x12,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xdf0(%rip),%rdx
xor    %ecx,%ecx
mov    $0x13,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xde0(%rip),%rdx
xor    %ecx,%ecx
mov    $0x16,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    0xdcc(%rip),%rdx
xor    %ecx,%ecx
mov    $0x17,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xdad(%rip),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xd9d(%rip),%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xd8f(%rip),%rdx
xor    %ecx,%ecx
mov    $0x2,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xd7b(%rip),%rdx
xor    %ecx,%ecx
mov    $0x3,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xd66(%rip),%rdx
xor    %ecx,%ecx
mov    $0x5,%r8d
call   1050 <printQuery@plt>
mov    -0x8(%rbp),%rdi
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProcessLogs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1060 <generateLogTime@plt>
lea    0xe1f(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe1a(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1050 <printQuery@plt>
lea    0xe14(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x2,%r8d
call   1050 <printQuery@plt>
lea    0xe01(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x9,%r8d
call   1050 <printQuery@plt>
lea    0xdf5(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0xb,%r8d
call   1050 <printQuery@plt>
lea    0xde9(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0xd,%r8d
call   1050 <printQuery@plt>
lea    0xdde(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0xe,%r8d
call   1050 <printQuery@plt>
lea    0xdd5(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x11,%r8d
call   1050 <printQuery@plt>
lea    0xdc6(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x12,%r8d
call   1050 <printQuery@plt>
lea    0xdb3(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x13,%r8d
call   1050 <printQuery@plt>
lea    0xda5(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x16,%r8d
call   1050 <printQuery@plt>
lea    0xd93(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
mov    $0x17,%r8d
call   1050 <printQuery@plt>
lea    0xd7f(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xd6f(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <printQuery@plt>
lea    0xd61(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1050 <printQuery@plt>
lea    0xd54(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %ecx,%ecx
mov    $0x2,%r8d
call   1050 <printQuery@plt>
lea    0xd41(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %ecx,%ecx
mov    $0x3,%r8d
call   1050 <printQuery@plt>
lea    0xd2d(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %ecx,%ecx
mov    $0x5,%r8d
call   1050 <printQuery@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"[%s] Process(%d) \00"
@.str.1 = [19 x i8] c" [STAT] executable\00"
@.str.2 = [6 x i8] c" stat\00"
@.str.3 = [13 x i8] c" minorfaults\00"
@.str.4 = [13 x i8] c" majorfaults\00"
@.str.5 = [14 x i8] c" usermodetime\00"
@.str.6 = [16 x i8] c" kernelmodetime\00"
@.str.7 = [10 x i8] c" priority\00"
@.str.8 = [6 x i8] c" nice\00"
@.str.9 = [11 x i8] c" nothreads\00"
@.str.10 = [7 x i8] c" vsize\00"
@.str.11 = [5 x i8] c" rss\00"
@.str.12 = [9 x i8] c" [STATM]\00"
@.str.13 = [9 x i8] c" program\00"
@.str.14 = [13 x i8] c" residentset\00"
@.str.15 = [7 x i8] c" share\00"
@.str.16 = [6 x i8] c" text\00"
@.str.17 = [6 x i8] c" data\00"
@.str.18 = [2 x i8] c"\0A\00"
define void @printProcessLogs(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = bitcast [256 x i8]* %9 to i8*
%11 = load i32*, i32** %5
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%13 = call i8* @generateLogTime(i8* %12)
%14 = load i32, i32* %6
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14)
%16 = load i32*, i32** %5
%17 = load i32, i32* %7
%18 = call i32 @printQuery(i32* %16, i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1)
%19 = load i32*, i32** %5
%20 = load i32, i32* %7
%21 = call i32 @printQuery(i32* %19, i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 2)
%22 = load i32*, i32** %5
%23 = load i32, i32* %7
%24 = call i32 @printQuery(i32* %22, i32 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 9)
%25 = load i32*, i32** %5
%26 = load i32, i32* %7
%27 = call i32 @printQuery(i32* %25, i32 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 11)
%28 = load i32*, i32** %5
%29 = load i32, i32* %7
%30 = call i32 @printQuery(i32* %28, i32 %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 13)
%31 = load i32*, i32** %5
%32 = load i32, i32* %7
%33 = call i32 @printQuery(i32* %31, i32 %32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 14)
%34 = load i32*, i32** %5
%35 = load i32, i32* %7
%36 = call i32 @printQuery(i32* %34, i32 %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 0, i32 17)
%37 = load i32*, i32** %5
%38 = load i32, i32* %7
%39 = call i32 @printQuery(i32* %37, i32 %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 0, i32 18)
%40 = load i32*, i32** %5
%41 = load i32, i32* %7
%42 = call i32 @printQuery(i32* %40, i32 %41, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 0, i32 19)
%43 = load i32*, i32** %5
%44 = load i32, i32* %7
%45 = call i32 @printQuery(i32* %43, i32 %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 0, i32 22)
%46 = load i32*, i32** %5
%47 = load i32, i32* %7
%48 = call i32 @printQuery(i32* %46, i32 %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 0, i32 23)
%49 = load i32*, i32** %5
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%51 = load i32*, i32** %5
%52 = load i32, i32* %8
%53 = call i32 @printQuery(i32* %51, i32 %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i32 0, i32 0)
%54 = load i32*, i32** %5
%55 = load i32, i32* %8
%56 = call i32 @printQuery(i32* %54, i32 %55, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i32 0, i32 1)
%57 = load i32*, i32** %5
%58 = load i32, i32* %8
%59 = call i32 @printQuery(i32* %57, i32 %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 0, i32 2)
%60 = load i32*, i32** %5
%61 = load i32, i32* %8
%62 = call i32 @printQuery(i32* %60, i32 %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 0, i32 3)
%63 = load i32*, i32** %5
%64 = load i32, i32* %8
%65 = call i32 @printQuery(i32* %63, i32 %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 0, i32 5)
%66 = load i32*, i32** %5
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"[%s] Process(%d) \00"
@.str.1 = [19 x i8] c" [STAT] executable\00"
@.str.2 = [6 x i8] c" stat\00"
@.str.3 = [13 x i8] c" minorfaults\00"
@.str.4 = [13 x i8] c" majorfaults\00"
@.str.5 = [14 x i8] c" usermodetime\00"
@.str.6 = [16 x i8] c" kernelmodetime\00"
@.str.7 = [10 x i8] c" priority\00"
@.str.8 = [6 x i8] c" nice\00"
@.str.9 = [11 x i8] c" nothreads\00"
@.str.10 = [7 x i8] c" vsize\00"
@.str.11 = [5 x i8] c" rss\00"
@.str.12 = [9 x i8] c" [STATM]\00"
@.str.13 = [9 x i8] c" program\00"
@.str.14 = [13 x i8] c" residentset\00"
@.str.15 = [7 x i8] c" share\00"
@.str.16 = [6 x i8] c" text\00"
@.str.17 = [6 x i8] c" data\00"
define void @printProcessLogs(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i8* @generateLogTime(i8* %6)
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %1)
%9 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1)
%10 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 2)
%11 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 9)
%12 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 11)
%13 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 13)
%14 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 14)
%15 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 0, i32 17)
%16 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 0, i32 18)
%17 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 0, i32 19)
%18 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 0, i32 22)
%19 = call i32 @printQuery(i32* %0, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 0, i32 23)
%20 = call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i64 8, i64 1, i32* %0)
%21 = call i32 @printQuery(i32* %0, i32 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i32 0, i32 0)
%22 = call i32 @printQuery(i32* %0, i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i32 0, i32 1)
%23 = call i32 @printQuery(i32* %0, i32 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 0, i32 2)
%24 = call i32 @printQuery(i32* %0, i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 0, i32 3)
%25 = call i32 @printQuery(i32* %0, i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 0, i32 5)
%26 = call i32 @fputc(i32 10, i32* %0)
ret void
}