#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 int uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ dac7568_en();
int /*<<< orphan*/ dac7568_setup_cmd(int *, int /*<<< orphan*/,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ dac7568_write_cmd(int);
int dac7568_write(uint32_t cmd, uint8_t ch, uint16_t data) {
  dac7568_en();
  switch (cmd) {
  case (0x00000000):
  case (0x01000000):
  case (0x02000000):
  case (0x03000000):
    dac7568_setup_cmd(&cmd, ch, data);
    dac7568_write_cmd(cmd);
    break;
  case (0x06000000):
  case (0x04000000):
  case (0x04000100):
  case (0x04000200):
  case (0x04000300):
    dac7568_write_cmd(cmd);
    break;
  case (0x05000000):
  case (0x05000001):
  case (0x05000002):
  case (0x05000003):
  case (0x07000000):
  case (0x08000000):
  case (0x08000001):
  case (0x09080000):
  case (0x09A00000):
  case (0x09B00000):
  case (0x09000000):
    dac7568_write_cmd(cmd);
    break;
  default:
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dac7568_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xor    %eax,%eax
call   1040 <dac7568_en@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     127e <dac7568_write+0x14e>
jmp    115b <dac7568_write+0x2b>
mov    -0x14(%rbp),%eax
sub    $0x1000000,%eax
je     127e <dac7568_write+0x14e>
jmp    116e <dac7568_write+0x3e>
mov    -0x14(%rbp),%eax
sub    $0x2000000,%eax
je     127e <dac7568_write+0x14e>
jmp    1181 <dac7568_write+0x51>
mov    -0x14(%rbp),%eax
sub    $0x3000000,%eax
je     127e <dac7568_write+0x14e>
jmp    1194 <dac7568_write+0x64>
mov    -0x14(%rbp),%eax
sub    $0x4000000,%eax
je     129a <dac7568_write+0x16a>
jmp    11a7 <dac7568_write+0x77>
mov    -0x14(%rbp),%eax
sub    $0x4000100,%eax
je     129a <dac7568_write+0x16a>
jmp    11ba <dac7568_write+0x8a>
mov    -0x14(%rbp),%eax
sub    $0x4000200,%eax
je     129a <dac7568_write+0x16a>
jmp    11cd <dac7568_write+0x9d>
mov    -0x14(%rbp),%eax
sub    $0x4000300,%eax
je     129a <dac7568_write+0x16a>
jmp    11e0 <dac7568_write+0xb0>
mov    -0x14(%rbp),%eax
add    $0xfb000000,%eax
sub    $0x4,%eax
jb     12a7 <dac7568_write+0x177>
jmp    11f6 <dac7568_write+0xc6>
mov    -0x14(%rbp),%eax
sub    $0x6000000,%eax
je     129a <dac7568_write+0x16a>
jmp    1209 <dac7568_write+0xd9>
mov    -0x14(%rbp),%eax
sub    $0x7000000,%eax
je     12a7 <dac7568_write+0x177>
jmp    121c <dac7568_write+0xec>
mov    -0x14(%rbp),%eax
add    $0xf8000000,%eax
sub    $0x2,%eax
jb     12a7 <dac7568_write+0x177>
jmp    1232 <dac7568_write+0x102>
mov    -0x14(%rbp),%eax
sub    $0x9000000,%eax
je     12a7 <dac7568_write+0x177>
jmp    1245 <dac7568_write+0x115>
mov    -0x14(%rbp),%eax
sub    $0x9080000,%eax
je     12a7 <dac7568_write+0x177>
jmp    1258 <dac7568_write+0x128>
mov    -0x14(%rbp),%eax
sub    $0x9a00000,%eax
je     12a7 <dac7568_write+0x177>
jmp    126b <dac7568_write+0x13b>
mov    -0x14(%rbp),%eax
sub    $0x9b00000,%eax
je     12a7 <dac7568_write+0x177>
jmp    12b4 <dac7568_write+0x184>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x8(%rbp),%rdi
call   1050 <dac7568_setup_cmd@plt>
mov    -0x8(%rbp),%edi
call   1030 <dac7568_write_cmd@plt>
jmp    12c0 <dac7568_write+0x190>
mov    -0x8(%rbp),%edi
call   1030 <dac7568_write_cmd@plt>
jmp    12c0 <dac7568_write+0x190>
mov    -0x8(%rbp),%edi
call   1030 <dac7568_write_cmd@plt>
jmp    12c0 <dac7568_write+0x190>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c7 <dac7568_write+0x197>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dac7568_write>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    %edi,0xc(%rsp)
xor    %eax,%eax
call   1040 <dac7568_en@plt>
mov    $0xffffffff,%eax
cmp    $0x5ffffff,%ebx
jg     1190 <dac7568_write+0x60>
cmp    $0x40001ff,%ebx
jg     11bd <dac7568_write+0x8d>
cmp    $0x2ffffff,%ebx
jg     11f4 <dac7568_write+0xc4>
test   %ebx,%ebx
je     120e <dac7568_write+0xde>
cmp    $0x1000000,%ebx
je     120e <dac7568_write+0xde>
cmp    $0x2000000,%ebx
je     120e <dac7568_write+0xde>
jmp    123c <dac7568_write+0x10c>
cmp    $0x8ffffff,%ebx
jg     11da <dac7568_write+0xaa>
lea    -0x8000000(%rbx),%ecx
cmp    $0x2,%ecx
jb     1233 <dac7568_write+0x103>
cmp    $0x6000000,%ebx
je     1233 <dac7568_write+0x103>
cmp    $0x7000000,%ebx
je     1233 <dac7568_write+0x103>
jmp    123c <dac7568_write+0x10c>
lea    -0x5000000(%rbx),%ecx
cmp    $0x4,%ecx
jb     1233 <dac7568_write+0x103>
cmp    $0x4000200,%ebx
je     1233 <dac7568_write+0x103>
cmp    $0x4000300,%ebx
je     1233 <dac7568_write+0x103>
jmp    123c <dac7568_write+0x10c>
cmp    $0x99fffff,%ebx
jg     1223 <dac7568_write+0xf3>
cmp    $0x9000000,%ebx
je     1233 <dac7568_write+0x103>
cmp    $0x9080000,%ebx
je     1233 <dac7568_write+0x103>
jmp    123c <dac7568_write+0x10c>
cmp    $0x3000000,%ebx
je     120e <dac7568_write+0xde>
cmp    $0x4000000,%ebx
je     1233 <dac7568_write+0x103>
cmp    $0x4000100,%ebx
je     1233 <dac7568_write+0x103>
jmp    123c <dac7568_write+0x10c>
lea    0xc(%rsp),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <dac7568_setup_cmd@plt>
mov    0xc(%rsp),%edi
jmp    1235 <dac7568_write+0x105>
cmp    $0x9a00000,%ebx
je     1233 <dac7568_write+0x103>
cmp    $0x9b00000,%ebx
jne    123c <dac7568_write+0x10c>
mov    %ebx,%edi
call   1030 <dac7568_write_cmd@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dac7568_write(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = call i32 (...) @dac7568_en()
%9 = load i32, i32* %5
switch i32 %9, label %22 [
i32 0, label %10
i32 16777216, label %10
i32 33554432, label %10
i32 50331648, label %10
i32 100663296, label %16
i32 67108864, label %16
i32 67109120, label %16
i32 67109376, label %16
i32 67109632, label %16
i32 83886080, label %19
i32 83886081, label %19
i32 83886082, label %19
i32 83886083, label %19
i32 117440512, label %19
i32 134217728, label %19
i32 134217729, label %19
i32 151519232, label %19
i32 161480704, label %19
i32 162529280, label %19
i32 150994944, label %19
]
10: ; preds = %3, %3, %3, %3
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @dac7568_setup_cmd(i32* %5, i32 %11, i32 %12)
%14 = load i32, i32* %5
%15 = call i32 @dac7568_write_cmd(i32 %14)
br label %23
16: ; preds = %3, %3, %3, %3, %3
%17 = load i32, i32* %5
%18 = call i32 @dac7568_write_cmd(i32 %17)
br label %23
19: ; preds = %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3
%20 = load i32, i32* %5
%21 = call i32 @dac7568_write_cmd(i32 %20)
br label %23
22: ; preds = %3
store i32 -1, i32* %4
br label %24
23: ; preds = %19, %16, %10
store i32 0, i32* %4
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
define i32 @dac7568_write(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %0, i32* %4
%5 = tail call i32 (...) @dac7568_en()
switch i32 %0, label %14 [
i32 0, label %6
i32 16777216, label %6
i32 33554432, label %6
i32 50331648, label %6
i32 100663296, label %10
i32 67108864, label %10
i32 67109120, label %10
i32 67109376, label %10
i32 67109632, label %10
i32 83886080, label %12
i32 83886081, label %12
i32 83886082, label %12
i32 83886083, label %12
i32 117440512, label %12
i32 134217728, label %12
i32 134217729, label %12
i32 151519232, label %12
i32 161480704, label %12
i32 162529280, label %12
i32 150994944, label %12
]
6: ; preds = %3, %3, %3, %3
%7 = call i32 @dac7568_setup_cmd(i32* %4, i32 %1, i32 %2)
%8 = load i32, i32* %4
%9 = call i32 @dac7568_write_cmd(i32 %8)
br label %14
10: ; preds = %3, %3, %3, %3, %3
%11 = tail call i32 @dac7568_write_cmd(i32 %0)
br label %14
12: ; preds = %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3
%13 = tail call i32 @dac7568_write_cmd(i32 %0)
br label %14
14: ; preds = %6, %10, %12, %3
%15 = phi i32 [ -1, %3 ], [ 0, %12 ], [ 0, %10 ], [ 0, %6 ]
ret i32 %15
}