#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ do_instruction(int, int *, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int, int);
int /*<<< orphan*/ resetn_low();
int /*<<< orphan*/ stderr;
int enable_programming(int spidev) {
  uint8_t tx[4], rx[4];
  if (!resetn_low())
    return 0;
  tx[0] = 0xac;
  tx[1] = 0x53;
  tx[2] = tx[3] = 0;
  if (!do_instruction(spidev, tx, rx))
    return 0;
  if (rx[2] == 0x53)
    return 1;
  fprintf(stderr,
          "Unacknowledged 'Programming Enable' instruction "
          "(%02x %02x %02x %02x)\n",
          rx[0], rx[1], rx[2], rx[3]);
  return 0;
}


x86 assembly (clang, -O0):
<enable_programming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <resetn_low@plt>
cmp    $0x0,%eax
jne    1157 <enable_programming+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <enable_programming+0xa8>
movl   $0xac,-0x20(%rbp)
movl   $0x53,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <do_instruction@plt>
cmp    $0x0,%eax
jne    1198 <enable_programming+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <enable_programming+0xa8>
cmpl   $0x53,-0x28(%rbp)
jne    11ae <enable_programming+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    11d8 <enable_programming+0xa8>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xe34(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enable_programming>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <resetn_low@plt>
test   %eax,%eax
je     1197 <enable_programming+0x67>
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <do_instruction@plt>
test   %eax,%eax
je     1197 <enable_programming+0x67>
mov    0x8(%rsp),%r8d
mov    $0x1,%ebx
cmp    $0x53,%r8d
je     1197 <enable_programming+0x67>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    0xc(%rsp),%r9d
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [71 x i8] c"Unacknowledged 'Programming Enable' instruction (%02x %02x %02x %02x)\0A\00"
define i32 @enable_programming(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca [4 x i32]
store i32 %0, i32* %3
%6 = call i32 (...) @resetn_low()
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %36
9: ; preds = %1
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
store i32 172, i32* %10
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
store i32 83, i32* %11
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
store i32 0, i32* %12
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
store i32 0, i32* %13
%14 = load i32, i32* %3
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%17 = call i32 @do_instruction(i32 %14, i32* %15, i32* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %9
store i32 0, i32* %2
br label %36
20: ; preds = %9
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 83
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %2
br label %36
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%30 = load i32, i32* %29
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%32 = load i32, i32* %31
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%34 = load i32, i32* %33
%35 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %30, i32 %32, i32 %34)
store i32 0, i32* %2
br label %36
36: ; preds = %25, %24, %19, %8
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [71 x i8] c"Unacknowledged 'Programming Enable' instruction (%02x %02x %02x %02x)\0A\00"
define i32 @enable_programming(i32 %0) {
%2 = alloca <4 x i32>
%3 = alloca [4 x i32]
%4 = bitcast <4 x i32>* %2 to i8*
%5 = bitcast [4 x i32]* %3 to i8*
%6 = tail call i32 (...) @resetn_low()
%7 = icmp eq i32 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %1
%9 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 0
store <4 x i32> <i32 172, i32 83, i32 0, i32 0>, <4 x i32>* %2
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%11 = call i32 @do_instruction(i32 %0, i32* %9, i32* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 83
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i32, i32* %10
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%23 = load i32, i32* %22
%24 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %21, i32 %15, i32 %23)
br label %25
25: ; preds = %13, %8, %1, %17
%26 = phi i32 [ 0, %17 ], [ 0, %1 ], [ 0, %8 ], [ 1, %13 ]
ret i32 %26
}