#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*/ uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
scalar_t__ get_eqep_base(int /*<<< orphan*/);
int /*<<< orphan*/ raw_write16(int, scalar_t__);
int /*<<< orphan*/ raw_write32(int, scalar_t__);
int eqep_init(uint8_t eqep_num) {
  uint32_t eqep_base = get_eqep_base(eqep_num);
  if (eqep_base == 0)
    return 0;
  raw_write16(0x0, eqep_base + (0x2A));
  raw_write32(0xffffffff, eqep_base + (0x8));
  raw_write32((0x80000000), eqep_base + (0x4));
  raw_write32((0x80000000), eqep_base + (0x0));
  raw_write16((0x1008), eqep_base + (0x2A));
  return 0;
}


x86 assembly (clang, -O0):
<eqep_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <get_eqep_base@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115e <eqep_init+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11bc <eqep_init+0x8c>
mov    -0x10(%rbp),%rsi
add    $0x2a,%rsi
xor    %edi,%edi
call   1030 <raw_write16@plt>
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    $0xffffffff,%edi
call   1050 <raw_write32@plt>
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    $0x80000000,%edi
call   1050 <raw_write32@plt>
mov    -0x10(%rbp),%rsi
add    $0x0,%rsi
mov    $0x80000000,%edi
call   1050 <raw_write32@plt>
mov    -0x10(%rbp),%rsi
add    $0x2a,%rsi
mov    $0x1008,%edi
call   1030 <raw_write16@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eqep_init>:
push   %r14
push   %rbx
push   %rax
call   1040 <get_eqep_base@plt>
test   %rax,%rax
je     1188 <eqep_init+0x58>
mov    %rax,%rbx
lea    0x2a(%rax),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <raw_write16@plt>
lea    0x8(%rbx),%rsi
mov    $0xffffffff,%edi
call   1050 <raw_write32@plt>
mov    %rbx,%rsi
add    $0x4,%rsi
mov    $0x80000000,%edi
call   1050 <raw_write32@plt>
mov    $0x80000000,%edi
mov    %rbx,%rsi
call   1050 <raw_write32@plt>
mov    $0x1008,%edi
mov    %r14,%rsi
call   1030 <raw_write16@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @eqep_init(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @get_eqep_base(i32 %5)
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %26
10: ; preds = %1
%11 = load i64, i64* %4
%12 = add nsw i64 %11, 42
%13 = call i32 @raw_write16(i32 0, i64 %12)
%14 = load i64, i64* %4
%15 = add nsw i64 %14, 8
%16 = call i32 @raw_write32(i32 -1, i64 %15)
%17 = load i64, i64* %4
%18 = add nsw i64 %17, 4
%19 = call i32 @raw_write32(i32 -2147483648, i64 %18)
%20 = load i64, i64* %4
%21 = add nsw i64 %20, 0
%22 = call i32 @raw_write32(i32 -2147483648, i64 %21)
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 42
%25 = call i32 @raw_write16(i32 4104, i64 %24)
store i32 0, i32* %2
br label %26
26: ; preds = %10, %9
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @eqep_init(i32 %0) {
%2 = tail call i64 @get_eqep_base(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = add nsw i64 %2, 42
%6 = tail call i32 @raw_write16(i32 0, i64 %5)
%7 = add nsw i64 %2, 8
%8 = tail call i32 @raw_write32(i32 -1, i64 %7)
%9 = add nsw i64 %2, 4
%10 = tail call i32 @raw_write32(i32 -2147483648, i64 %9)
%11 = tail call i32 @raw_write32(i32 -2147483648, i64 %2)
%12 = tail call i32 @raw_write16(i32 4104, i64 %5)
br label %13
13: ; preds = %1, %4
ret i32 0
}