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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int _config_STX_FLASH(char *BASE1, int write_FPGA, int print) {
  int temp = 0;
  if ((*((unsigned int *)(BASE1 + 0x00)) & 0x00000001) == 0) {
    fprintf(stderr, "FPGA not properly configured");
    return -1;
  }
  *((unsigned int *)(BASE1 + 0x00)) =
      (*((unsigned int *)(BASE1 + 0x00)) | 0x00000010);
  *((unsigned int *)(BASE1 + 0x00)) =
      (*((unsigned int *)(BASE1 + 0x00)) | 0x00000020);
  if ((*((unsigned int *)(BASE1 + 0x00)) & 0x00000001) == 0) {
    fprintf(stderr, "FPGA not properly configured");
    temp = 1;
    return -1;
  }
  if (print == 1) {
    printf("	STX_FLASH PARAMETERS:\n");
    if (temp == 0) {
      printf("	  FPGA configured properly\n");
    }
    printf("	  GC314FS_SF_CSR=	0x%x\n",
           *((unsigned int *)(BASE1 + 0x00)));
    printf("	  FLASH VERSION=	0x%x\n",
           *((unsigned int *)(BASE1 + 0x3c)));
  }
  return 1;
}


x86 assembly (clang, -O0):
<_config_STX_FLASH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    116c <_config_STX_FLASH+0x4c>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1224 <_config_STX_FLASH+0x104>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x10,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x20,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11c4 <_config_STX_FLASH+0xa4>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
movl   $0xffffffff,-0x4(%rbp)
jmp    1224 <_config_STX_FLASH+0x104>
cmpl   $0x1,-0x18(%rbp)
jne    121d <_config_STX_FLASH+0xfd>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    11f4 <_config_STX_FLASH+0xd4>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x3c(%rax),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_config_STX_FLASH>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%eax
test   $0x1,%al
jne    1155 <_config_STX_FLASH+0x25>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    11a0 <_config_STX_FLASH+0x70>
mov    %rdi,%rbx
or     $0x30,%eax
mov    %eax,(%rdi)
mov    $0x1,%ebp
cmp    $0x1,%edx
jne    11a0 <_config_STX_FLASH+0x70>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rbx),%esi
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"FPGA not properly configured\00"
@.str.1 = [24 x i8] c"\09STX_FLASH PARAMETERS:\0A\00"
@.str.2 = [29 x i8] c"\09 FPGA configured properly\0A\00"
@.str.3 = [25 x i8] c"\09 GC314FS_SF_CSR=\090x%x\0A\00"
@.str.4 = [24 x i8] c"\09 FLASH VERSION=\090x%x\0A\00"
define i32 @_config_STX_FLASH(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %65
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = bitcast i8* %20 to i32*
%22 = load i32, i32* %21
%23 = or i32 %22, 16
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = bitcast i8* %25 to i32*
store i32 %23, i32* %26
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = bitcast i8* %28 to i32*
%30 = load i32, i32* %29
%31 = or i32 %30, 32
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = bitcast i8* %33 to i32*
store i32 %31, i32* %34
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = bitcast i8* %36 to i32*
%38 = load i32, i32* %37
%39 = and i32 %38, 1
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %18
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %8
store i32 -1, i32* %4
br label %65
44: ; preds = %18
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %64
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
%54 = load i8*, i8** %5
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = bitcast i8* %55 to i32*
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %57)
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 60
%61 = bitcast i8* %60 to i32*
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %53, %44
store i32 1, i32* %4
br label %65
65: ; preds = %64, %41, %15
%66 = load i32, i32* %4
ret i32 %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"FPGA not properly configured\00"
@.str.3 = [25 x i8] c"\09 GC314FS_SF_CSR=\090x%x\0A\00"
@.str.4 = [24 x i8] c"\09 FLASH VERSION=\090x%x\0A\00"
@str = [23 x i8] c"\09STX_FLASH PARAMETERS:\00"
@str.5 = [28 x i8] c"\09 FPGA configured properly\00"
define i32 @_config_STX_FLASH(i8* nocapture %0, i32 %1, i32 %2) {
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %23
11: ; preds = %3
%12 = or i32 %5, 48
store i32 %12, i32* %4
%13 = icmp eq i32 %2, 1
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i8, i8* %0, i64 60
%20 = bitcast i8* %19 to i32*
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %11, %14, %8
%24 = phi i32 [ -1, %8 ], [ 1, %14 ], [ 1, %11 ]
ret i32 %24
}