#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*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, unsigned long long *,
           unsigned long long *, unsigned long long *, unsigned long long *,
           unsigned long long *, unsigned long long *, unsigned long long *);
int /*<<< orphan*/ printf(char *, int);
int DetectProcStatStyle() {
  FILE *fp;
  unsigned long long x1, x2, x3, x4, x5, x6, x7;
  int res;
  fp = fopen("/proc/stat", "r");
  res = fscanf(fp, "cpu %lld %lld %lld %lld %lld %lld %lld\n", &x1, &x2, &x3,
               &x4, &x5, &x6, &x7);
  printf("%d\n", res);
  return res;
}


x86 assembly (clang, -O0):
<DetectProcStatStyle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xec1(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%r9
lea    -0x30(%rbp),%r11
lea    -0x38(%rbp),%r10
lea    -0x40(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <fscanf@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DetectProcStatStyle>:
push   %rbx
sub    $0x40,%rsp
lea    0xec4(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1050 <fopen@plt>
sub    $0x8,%rsp
lea    0x10(%rsp),%rbx
lea    0x18(%rsp),%r10
lea    0x20(%rsp),%r11
lea    0xeab(%rip),%rsi
lea    0x40(%rsp),%rdx
lea    0x38(%rsp),%rcx
lea    0x30(%rsp),%r8
lea    0x28(%rsp),%r9
mov    %rax,%rdi
push   %rbx
push   %r10
push   %r11
call   1040 <fscanf@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    0xea5(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c"cpu %lld %lld %lld %lld %lld %lld %lld\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @DetectProcStatStyle() {
%1 = alloca i32*
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = 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* %10, i32** %1
%11 = load i32*, i32** %1
%12 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i64* %2, i64* %3, i64* %4, i64* %5, i64* %6, i64* %7, i64* %8)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %9
ret i32 %15
}

LLVM IR (-O2):
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c"cpu %lld %lld %lld %lld %lld %lld %lld\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @DetectProcStatStyle() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = bitcast i64* %1 to i8*
%9 = bitcast i64* %2 to i8*
%10 = bitcast i64* %3 to i8*
%11 = bitcast i64* %4 to i8*
%12 = bitcast i64* %5 to i8*
%13 = bitcast i64* %6 to i8*
%14 = bitcast i64* %7 to i8*
%15 = 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))
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i64* %1, i64* %2, i64* %3, i64* %4, i64* %5, i64* %6, i64* %7)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
ret i32 %16
}