#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 */
struct tl880_dev {
  int dummy;
};

/* Variables and functions */
unsigned long tl880_calc_dpc_pll_const(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ tl880_set_gpio(struct tl880_dev *, int, unsigned long);
int /*<<< orphan*/ tl880_write_register(struct tl880_dev *, int, unsigned long);
void tl880_set_dpc_clock(struct tl880_dev *tl880dev, unsigned long xres,
                         unsigned long yres, long interlace) {
  unsigned long val = 0;
  unsigned long gpio_val = 1;
  switch (xres) {
  case 1024:
    val = 0x01151bb0;
    break;
  case 1440:
    val = 0x00e619b0;
    break;
  case 1280:
  case 1920:
    if (1) {
      val = 0x98280;
      gpio_val = 0;
    } else {
      val = tl880_calc_dpc_pll_const(0x14, 2, 0);
    }
    break;
  default:
    if (interlace) {
      val = 0x60070;
    } else if (1) {
      val = 0x60050;
    } else if (0) {
      val = 0x60050;
    } else {
      val = 0x60070;
    }
    break;
  }
  tl880_write_register(tl880dev, 0x5800, val);
  tl880_write_register(tl880dev, 0x5d14, 0);
  tl880_set_gpio(tl880dev, 6, gpio_val);
}


x86 assembly (clang, -O0):
<tl880_set_dpc_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
sub    $0x400,%rax
je     11a0 <tl880_set_dpc_clock+0x80>
jmp    1161 <tl880_set_dpc_clock+0x41>
mov    -0x38(%rbp),%rax
sub    $0x500,%rax
je     11ba <tl880_set_dpc_clock+0x9a>
jmp    1176 <tl880_set_dpc_clock+0x56>
mov    -0x38(%rbp),%rax
sub    $0x5a0,%rax
je     11ad <tl880_set_dpc_clock+0x8d>
jmp    118b <tl880_set_dpc_clock+0x6b>
mov    -0x38(%rbp),%rax
sub    $0x780,%rax
je     11ba <tl880_set_dpc_clock+0x9a>
jmp    11cf <tl880_set_dpc_clock+0xaf>
movq   $0x1151bb0,-0x28(%rbp)
01
jmp    11f4 <tl880_set_dpc_clock+0xd4>
movq   $0xe619b0,-0x28(%rbp)
jmp    11f4 <tl880_set_dpc_clock+0xd4>
movq   $0x98280,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
jmp    11f4 <tl880_set_dpc_clock+0xd4>
cmpq   $0x0,-0x20(%rbp)
je     11e7 <tl880_set_dpc_clock+0xc7>
movq   $0x60070,-0x28(%rbp)
jmp    11ef <tl880_set_dpc_clock+0xcf>
movq   $0x60050,-0x28(%rbp)
jmp    11f4 <tl880_set_dpc_clock+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x5800,%esi
call   1030 <tl880_write_register@plt>
mov    -0x8(%rbp),%rdi
mov    $0x5d14,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <tl880_write_register@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x6,%esi
call   1040 <tl880_set_gpio@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tl880_set_dpc_clock>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1,%r14d
cmp    $0x59f,%rsi
jg     114a <tl880_set_dpc_clock+0x2a>
cmp    $0x400,%rsi
je     1182 <tl880_set_dpc_clock+0x62>
cmp    $0x500,%rsi
je     1163 <tl880_set_dpc_clock+0x43>
jmp    116d <tl880_set_dpc_clock+0x4d>
cmp    $0x780,%rsi
je     1163 <tl880_set_dpc_clock+0x43>
cmp    $0x5a0,%rsi
jne    116d <tl880_set_dpc_clock+0x4d>
mov    $0xe619b0,%edx
jmp    1187 <tl880_set_dpc_clock+0x67>
mov    $0x98280,%edx
xor    %r14d,%r14d
jmp    1187 <tl880_set_dpc_clock+0x67>
xor    %edx,%edx
test   %rcx,%rcx
setne  %dl
shl    $0x5,%rdx
or     $0x60050,%rdx
jmp    1187 <tl880_set_dpc_clock+0x67>
mov    $0x1151bb0,%edx
mov    %rbx,%rdi
mov    $0x5800,%esi
call   1030 <tl880_write_register@plt>
mov    %rbx,%rdi
mov    $0x5d14,%esi
xor    %edx,%edx
call   1030 <tl880_write_register@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <tl880_set_gpio@plt>

LLVM IR (-O0):
%struct.tl880_dev = type { i32 }
define void @tl880_set_dpc_clock(%struct.tl880_dev* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca %struct.tl880_dev*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store %struct.tl880_dev* %0, %struct.tl880_dev** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
store i64 0, i64* %9
store i64 1, i64* %10
%11 = load i64, i64* %6
switch i64 %11, label %15 [
i64 1024, label %12
i64 1440, label %13
i64 1280, label %14
i64 1920, label %14
]
12: ; preds = %4
store i64 18160560, i64* %9
br label %21
13: ; preds = %4
store i64 15079856, i64* %9
br label %21
14: ; preds = %4, %4
store i64 623232, i64* %9
store i64 0, i64* %10
br label %21
15: ; preds = %4
%16 = load i64, i64* %8
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i64 393328, i64* %9
br label %20
19: ; preds = %15
store i64 393296, i64* %9
br label %20
20: ; preds = %19, %18
br label %21
21: ; preds = %20, %14, %13, %12
%22 = load %struct.tl880_dev*, %struct.tl880_dev** %5
%23 = load i64, i64* %9
%24 = call i32 @tl880_write_register(%struct.tl880_dev* %22, i32 22528, i64 %23)
%25 = load %struct.tl880_dev*, %struct.tl880_dev** %5
%26 = call i32 @tl880_write_register(%struct.tl880_dev* %25, i32 23828, i64 0)
%27 = load %struct.tl880_dev*, %struct.tl880_dev** %5
%28 = load i64, i64* %10
%29 = call i32 @tl880_set_gpio(%struct.tl880_dev* %27, i32 6, i64 %28)
ret void
}

LLVM IR (-O2):
%struct.tl880_dev = type { i32 }
define void @tl880_set_dpc_clock(%struct.tl880_dev* %0, i64 %1, i64 %2, i64 %3) {
switch i64 %1, label %7 [
i64 1024, label %10
i64 1440, label %5
i64 1280, label %6
i64 1920, label %6
]
5: ; preds = %4
br label %10
6: ; preds = %4, %4
br label %10
7: ; preds = %4
%8 = icmp eq i64 %3, 0
%9 = select i1 %8, i64 393296, i64 393328
br label %10
10: ; preds = %7, %4, %6, %5
%11 = phi i64 [ 623232, %6 ], [ 15079856, %5 ], [ 18160560, %4 ], [ %9, %7 ]
%12 = phi i64 [ 0, %6 ], [ 1, %5 ], [ 1, %4 ], [ 1, %7 ]
%13 = tail call i32 @tl880_write_register(%struct.tl880_dev* %0, i32 22528, i64 %11)
%14 = tail call i32 @tl880_write_register(%struct.tl880_dev* %0, i32 23828, i64 0)
%15 = tail call i32 @tl880_set_gpio(%struct.tl880_dev* %0, i32 6, i64 %12)
ret void
}