#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 fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ wfc_util_atoh(char *, int, unsigned char *, int);
int /*<<< orphan*/ wfc_util_qcom_check_config(unsigned char *);
int wifi_check_qcom_cfg_files() {
  char macAddress[13];
  char hex[7];
  memset(macAddress, 0, 13);
  memset(hex, 0, 7);
  FILE *fp = NULL;
  int n = 0;
  fp = fopen("/persist/wifi/.macaddr", "r");
  if (fp == NULL) {
    wfc_util_qcom_check_config((unsigned char *)macAddress);
    return 0;
  } else {
    n = fread(macAddress, 12, 1, fp);
    fclose(fp);
    wfc_util_atoh(macAddress, 12, (unsigned char *)hex, 6);
    wfc_util_qcom_check_config((unsigned char *)hex);
  }
  return 1;
}


x86 assembly (clang, -O0):
<wifi_check_qcom_cfg_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1050 <memset@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe62(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ce <wifi_check_qcom_cfg_files+0x6e>
lea    -0x11(%rbp),%rdi
call   1070 <wfc_util_qcom_check_config@plt>
movl   $0x0,-0x4(%rbp)
jmp    1218 <wifi_check_qcom_cfg_files+0xb8>
lea    -0x11(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xc,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x11(%rbp),%rdi
lea    -0x18(%rbp),%rdx
mov    $0xc,%esi
mov    $0x6,%ecx
call   1060 <wfc_util_atoh@plt>
lea    -0x18(%rbp),%rdi
call   1070 <wfc_util_qcom_check_config@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wifi_check_qcom_cfg_files>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x4(%rsp),%rbx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1050 <memset@plt>
lea    0x11(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
lea    0xe64(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f0 <wifi_check_qcom_cfg_files+0x90>
mov    %rax,%rbp
lea    0x4(%rsp),%rbx
mov    $0x1,%r15d
mov    %rbx,%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
mov    %r14,%rdx
mov    $0x6,%ecx
call   1060 <wfc_util_atoh@plt>
mov    %r14,%rbx
mov    %rbx,%rdi
call   1070 <wfc_util_qcom_check_config@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"/persist/wifi/.macaddr\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @wifi_check_qcom_cfg_files() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca [7 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 13)
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 7)
store i32* null, i32** %4
store i32 0, i32* %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 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** %4
%11 = load i32*, i32** %4
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%15 = call i32 @wfc_util_qcom_check_config(i8* %14)
store i32 0, i32* %1
br label %28
16: ; preds = %0
%17 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i32 @fread(i8* %17, i32 12, i32 1, i32* %18)
store i32 %19, i32* %5
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
%22 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%24 = call i32 @wfc_util_atoh(i8* %22, i32 12, i8* %23, i32 6)
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%26 = call i32 @wfc_util_qcom_check_config(i8* %25)
br label %27
27: ; preds = %16
store i32 1, i32* %1
br label %28
28: ; preds = %27, %13
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [23 x i8] c"/persist/wifi/.macaddr\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @wifi_check_qcom_cfg_files() {
%1 = alloca [13 x i8]
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %3, i32 0, i32 13)
%6 = call i32 @memset(i8* %4, i32 0, i32 7)
%7 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = call i32 @fread(i8* %3, i32 12, i32 1, i32* %7)
%11 = call i32 @fclose(i32* %7)
%12 = call i32 @wfc_util_atoh(i8* %3, i32 12, i8* %4, i32 6)
br label %13
13: ; preds = %0, %9
%14 = phi i8* [ %4, %9 ], [ %3, %0 ]
%15 = phi i32 [ 1, %9 ], [ 0, %0 ]
%16 = call i32 @wfc_util_qcom_check_config(i8* %14)
ret i32 %15
}