#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*/ prussdrv_pru_disable(int);
int /*<<< orphan*/ prussdrv_pru_write_memory(unsigned int, int /*<<< orphan*/,
                                             unsigned int const *, int);
int prussdrv_load_data(int prunum, const unsigned int *code, int codelen) {
  unsigned int pru_ram_id;
  if (prunum == 0)
    pru_ram_id = 0;
  else if (prunum == 1)
    pru_ram_id = 1;
  else
    return -1;
  prussdrv_pru_disable(prunum);
  prussdrv_pru_write_memory(pru_ram_id, 0, code, codelen);
  return 0;
}


x86 assembly (clang, -O0):
<prussdrv_load_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1148 <prussdrv_load_data+0x28>
movl   $0x0,-0x18(%rbp)
jmp    116f <prussdrv_load_data+0x4f>
cmpl   $0x1,-0x8(%rbp)
jne    115e <prussdrv_load_data+0x3e>
movl   $0x1,-0x18(%rbp)
jmp    116a <prussdrv_load_data+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    118f <prussdrv_load_data+0x6f>
jmp    116f <prussdrv_load_data+0x4f>
mov    -0x8(%rbp),%edi
call   1030 <prussdrv_pru_disable@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
call   1040 <prussdrv_pru_write_memory@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prussdrv_load_data>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebx
test   %edi,%edi
je     1142 <prussdrv_load_data+0x22>
mov    $0xffffffff,%ebp
cmp    $0x1,%edi
jne    1158 <prussdrv_load_data+0x38>
mov    $0x1,%ebx
call   1030 <prussdrv_pru_disable@plt>
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1040 <prussdrv_pru_write_memory@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @prussdrv_load_data(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 0, i32* %8
br label %18
12: ; preds = %3
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 1, i32* %8
br label %17
16: ; preds = %12
store i32 -1, i32* %4
br label %25
17: ; preds = %15
br label %18
18: ; preds = %17, %11
%19 = load i32, i32* %5
%20 = call i32 @prussdrv_pru_disable(i32 %19)
%21 = load i32, i32* %8
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = call i32 @prussdrv_pru_write_memory(i32 %21, i32 0, i32* %22, i32 %23)
store i32 0, i32* %4
br label %25
25: ; preds = %18, %16
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
define i32 @prussdrv_load_data(i32 %0, i32* %1, i32 %2) {
switch i32 %0, label %9 [
i32 0, label %5
i32 1, label %4
]
4: ; preds = %3
br label %5
5: ; preds = %3, %4
%6 = phi i32 [ 1, %4 ], [ %0, %3 ]
%7 = tail call i32 @prussdrv_pru_disable(i32 %0)
%8 = tail call i32 @prussdrv_pru_write_memory(i32 %6, i32 0, i32* %1, i32 %2)
br label %9
9: ; preds = %3, %5
%10 = phi i32 [ 0, %5 ], [ -1, %3 ]
ret i32 %10
}