#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*/ 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;
  fp = fopen("/persist/wifi/.macaddr", "r");
  if (fp == NULL) {
    wfc_util_qcom_check_config((unsigned char *)macAddress);
    return 0;
  } else {
    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    $0x20,%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)
lea    0xe69(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c7 <wifi_check_qcom_cfg_files+0x67>
lea    -0x11(%rbp),%rdi
call   1070 <wfc_util_qcom_check_config@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <wifi_check_qcom_cfg_files+0xae>
lea    -0x11(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xc,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
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    $0x20,%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 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 13)
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 7)
store i32* null, i32** %4
%9 = 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* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%14 = call i32 @wfc_util_qcom_check_config(i8* %13)
store i32 0, i32* %1
br label %27
15: ; preds = %0
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i32 @fread(i8* %16, i32 12, i32 1, i32* %17)
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
%21 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%23 = call i32 @wfc_util_atoh(i8* %21, i32 12, i8* %22, i32 6)
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%25 = call i32 @wfc_util_qcom_check_config(i8* %24)
br label %26
26: ; preds = %15
store i32 1, i32* %1
br label %27
27: ; preds = %26, %12
%28 = load i32, i32* %1
ret i32 %28
}

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
}