#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 hdmi_read_reg(int);
int /*<<< orphan*/ hdmi_write_reg(int, int);
int i2c_read_clock_scale();
int /*<<< orphan*/ i2c_write_clock_scale(int);
int /*<<< orphan*/ writeHex(int);
int /*<<< orphan*/ writeString(char *);
void configure_hdmi(void) {
  {
    int j;
    writeString("Setting clock_scale to 0x");
    writeHex(1250);
    writeString("\n");
    i2c_write_clock_scale(1250);
    j = i2c_read_clock_scale();
    writeString("clock scale = 0x");
    writeHex(j);
    writeString("\n");
    if (j == 1250)
      writeString(" - passed\n");
    else
      writeString(" - FAILED\n");
    hdmi_write_reg(0x0f, 0);
    j = hdmi_read_reg(1);
    if (j == 0xca)
      writeString("Correct vendor ID\n");
    else {
      writeString("FAILED - Vendor ID=0x");
      writeHex(j);
      writeString(" but should be 0xca\n");
    }
    j = hdmi_read_reg(2) | ((hdmi_read_reg(3) & 0xf) << 8);
    if (j == 0x613)
      writeString("Correct device ID\n");
    else {
      writeString("FAILED - Device ID=0x");
      writeHex(j);
      writeString(" but should be 0x613\n");
    }
  }
  hdmi_write_reg(4, 0xff);
  hdmi_write_reg(4, 0x00);
  hdmi_write_reg(61, 0x10);
  {
    int reg;
    for (reg = 0xc0; reg <= 0xd0; reg++)
      hdmi_write_reg(reg, 0x00);
  }
  hdmi_write_reg(0xc3, 0x08);
  hdmi_write_reg(0xf8, 0xff);
  hdmi_write_reg(0x09, 0xff);
  hdmi_write_reg(0x0a, 0xff);
  hdmi_write_reg(0x0b, 0xff);
  hdmi_write_reg(0x0c, 0xff);
  hdmi_write_reg(0x0d, 0xff);
  hdmi_write_reg(0x0e, 0x00);
  hdmi_write_reg(0x70, 0x0);
  hdmi_write_reg(0x72, 0);
  hdmi_write_reg(0x90, 0);
  {
    int sum = 0;
    hdmi_write_reg(0x0f, 1);
    hdmi_write_reg(0x58, 0x10);
    sum += 0x10;
    hdmi_write_reg(0x59, 0x68);
    sum += 0x68;
    hdmi_write_reg(0x5a, 0);
    hdmi_write_reg(0x5b, 3);
    sum += 3;
    hdmi_write_reg(0x5c, 0);
    hdmi_write_reg(0x5e, 0);
    hdmi_write_reg(0x5f, 0);
    hdmi_write_reg(0x60, 0);
    hdmi_write_reg(0x61, 0);
    hdmi_write_reg(0x62, 0);
    hdmi_write_reg(0x63, 0);
    hdmi_write_reg(0x64, 0);
    hdmi_write_reg(0x65, 0);
    writeString("check: VIC = 0x");
    writeHex(hdmi_read_reg(0x5b));
    writeString("\n");
    hdmi_write_reg(0x5d, 0xf4);
    writeString("check: checksum = 0x");
    writeHex(hdmi_read_reg(0x5b));
    writeString("\n");
  }
  hdmi_write_reg(0x0f, 0);
  hdmi_write_reg(0xcd, 3);
  hdmi_write_reg(0xc1, 0x00);
  hdmi_write_reg(0xe0, 0x08);
  hdmi_write_reg(0xe1, 0x0);
  writeString("Completed HDMI initialisation\n");
}


x86 assembly (clang, -O0):
<configure_hdmi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x4e2,%edi
call   1050 <writeHex@plt>
lea    0xf37(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x4e2,%edi
call   1060 <i2c_write_clock_scale@plt>
mov    $0x0,%al
call   1070 <i2c_read_clock_scale@plt>
mov    %eax,-0x4(%rbp)
lea    0xe75(%rip),%rdi
call   1040 <writeString@plt>
mov    -0x4(%rbp),%edi
call   1050 <writeHex@plt>
lea    0xf03(%rip),%rdi
call   1040 <writeString@plt>
cmpl   $0x4e2,-0x4(%rbp)
jne    11dc <configure_hdmi+0x7c>
lea    0xe59(%rip),%rdi
call   1040 <writeString@plt>
jmp    11e8 <configure_hdmi+0x88>
lea    0xe53(%rip),%rdi
call   1040 <writeString@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x1,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xca,-0x4(%rbp)
jne    121f <configure_hdmi+0xbf>
lea    0xe2c(%rip),%rdi
call   1040 <writeString@plt>
jmp    123f <configure_hdmi+0xdf>
lea    0xe2e(%rip),%rdi
call   1040 <writeString@plt>
mov    -0x4(%rbp),%edi
call   1050 <writeHex@plt>
lea    0xe30(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x2,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,-0x10(%rbp)
mov    $0x3,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
and    $0xf,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x613,-0x4(%rbp)
jne    1284 <configure_hdmi+0x124>
lea    0xe05(%rip),%rdi
call   1040 <writeString@plt>
jmp    12a4 <configure_hdmi+0x144>
lea    0xe07(%rip),%rdi
call   1040 <writeString@plt>
mov    -0x4(%rbp),%edi
call   1050 <writeHex@plt>
lea    0xe09(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x4,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x3d,%edi
mov    $0x10,%esi
call   1080 <hdmi_write_reg@plt>
movl   $0xc0,-0x8(%rbp)
cmpl   $0xd0,-0x8(%rbp)
jg     12fa <configure_hdmi+0x19a>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12d5 <configure_hdmi+0x175>
mov    $0xc3,%edi
mov    $0x8,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xf8,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x9,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xa,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xb,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xd,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x70,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x72,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x90,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
movl   $0x0,-0xc(%rbp)
mov    $0xf,%edi
mov    $0x1,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x58,%edi
mov    $0x10,%esi
call   1080 <hdmi_write_reg@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
mov    $0x59,%edi
mov    $0x68,%esi
call   1080 <hdmi_write_reg@plt>
mov    -0xc(%rbp),%eax
add    $0x68,%eax
mov    %eax,-0xc(%rbp)
mov    $0x5a,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5b,%edi
mov    $0x3,%esi
call   1080 <hdmi_write_reg@plt>
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    $0x5c,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5e,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5f,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x60,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x61,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x62,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x64,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x65,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xc4e(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x5b,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%edi
call   1050 <writeHex@plt>
lea    0xc2f(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x5d,%edi
mov    $0xf4,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xc26(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x5b,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%edi
call   1050 <writeHex@plt>
lea    0xbf7(%rip),%rdi
call   1040 <writeString@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcd,%edi
mov    $0x3,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc1,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe0,%edi
mov    $0x8,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe1,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xbd0(%rip),%rdi
call   1040 <writeString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configure_hdmi>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x4e2,%edi
call   1050 <writeHex@plt>
lea    0xf3c(%rip),%rbx
mov    %rbx,%rdi
call   1040 <writeString@plt>
mov    $0x4e2,%edi
call   1060 <i2c_write_clock_scale@plt>
xor    %eax,%eax
call   1070 <i2c_read_clock_scale@plt>
mov    %eax,%ebp
lea    0xe78(%rip),%rdi
call   1040 <writeString@plt>
mov    %ebp,%edi
call   1050 <writeHex@plt>
mov    %rbx,%rdi
call   1040 <writeString@plt>
cmp    $0x4e2,%ebp
lea    0xe68(%rip),%rax
lea    0xe6c(%rip),%rdi
cmove  %rax,%rdi
call   1040 <writeString@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x1,%edi
call   1030 <hdmi_read_reg@plt>
cmp    $0xca,%eax
jne    11f9 <configure_hdmi+0x99>
lea    0xe4a(%rip),%rdi
jmp    1215 <configure_hdmi+0xb5>
mov    %eax,%ebx
lea    0xe52(%rip),%rdi
call   1040 <writeString@plt>
mov    %ebx,%edi
call   1050 <writeHex@plt>
lea    0xe55(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x2,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%ebp
mov    $0x3,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%ebx
and    $0xf,%ebx
shl    $0x8,%ebx
or     %ebp,%ebx
cmp    $0x613,%ebx
jne    124b <configure_hdmi+0xeb>
lea    0xe36(%rip),%rdi
jmp    1265 <configure_hdmi+0x105>
lea    0xe40(%rip),%rdi
call   1040 <writeString@plt>
mov    %ebx,%edi
call   1050 <writeHex@plt>
lea    0xe43(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x4,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x3d,%edi
mov    $0x10,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc0,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc1,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc2,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc3,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc4,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc5,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc6,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc7,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc8,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc9,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xca,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcb,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcc,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcd,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xce,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcf,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xd0,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc3,%edi
mov    $0x8,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xf8,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x9,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xa,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xb,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xd,%edi
mov    $0xff,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x70,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x72,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x90,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x58,%edi
mov    $0x10,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x59,%edi
mov    $0x68,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5a,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5b,%edi
mov    $0x3,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5c,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5e,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x5f,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x60,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x61,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x62,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x64,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0x65,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xc0a(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x5b,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%edi
call   1050 <writeHex@plt>
lea    0xbeb(%rip),%rbx
mov    %rbx,%rdi
call   1040 <writeString@plt>
mov    $0x5d,%edi
mov    $0xf4,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xbdf(%rip),%rdi
call   1040 <writeString@plt>
mov    $0x5b,%edi
call   1030 <hdmi_read_reg@plt>
mov    %eax,%edi
call   1050 <writeHex@plt>
mov    %rbx,%rdi
call   1040 <writeString@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xcd,%edi
mov    $0x3,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xc1,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe0,%edi
mov    $0x8,%esi
call   1080 <hdmi_write_reg@plt>
mov    $0xe1,%edi
xor    %esi,%esi
call   1080 <hdmi_write_reg@plt>
lea    0xb8d(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <writeString@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Setting clock_scale to 0x\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"clock scale = 0x\00"
@.str.3 = [11 x i8] c" - passed\0A\00"
@.str.4 = [11 x i8] c" - FAILED\0A\00"
@.str.5 = [19 x i8] c"Correct vendor ID\0A\00"
@.str.6 = [22 x i8] c"FAILED - Vendor ID=0x\00"
@.str.7 = [21 x i8] c" but should be 0xca\0A\00"
@.str.8 = [19 x i8] c"Correct device ID\0A\00"
@.str.9 = [22 x i8] c"FAILED - Device ID=0x\00"
@.str.10 = [22 x i8] c" but should be 0x613\0A\00"
@.str.11 = [16 x i8] c"check: VIC = 0x\00"
@.str.12 = [21 x i8] c"check: checksum = 0x\00"
@.str.13 = [31 x i8] c"Completed HDMI initialisation\0A\00"
define void @configure_hdmi() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @writeString(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @writeHex(i32 1250)
%6 = call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @i2c_write_clock_scale(i32 1250)
%8 = call i32 (...) @i2c_read_clock_scale()
store i32 %8, i32* %1
%9 = call i32 @writeString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @writeHex(i32 %10)
%12 = call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 1250
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @writeString(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %0
%18 = call i32 @writeString(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
%20 = call i32 @hdmi_write_reg(i32 15, i32 0)
%21 = call i32 @hdmi_read_reg(i32 1)
store i32 %21, i32* %1
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 202
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @writeString(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %31
26: ; preds = %19
%27 = call i32 @writeString(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* %1
%29 = call i32 @writeHex(i32 %28)
%30 = call i32 @writeString(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %26, %24
%32 = call i32 @hdmi_read_reg(i32 2)
%33 = call i32 @hdmi_read_reg(i32 3)
%34 = and i32 %33, 15
%35 = shl i32 %34, 8
%36 = or i32 %32, %35
store i32 %36, i32* %1
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 1555
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = call i32 @writeString(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %46
41: ; preds = %31
%42 = call i32 @writeString(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%43 = load i32, i32* %1
%44 = call i32 @writeHex(i32 %43)
%45 = call i32 @writeString(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %46
46: ; preds = %41, %39
%47 = call i32 @hdmi_write_reg(i32 4, i32 255)
%48 = call i32 @hdmi_write_reg(i32 4, i32 0)
%49 = call i32 @hdmi_write_reg(i32 61, i32 16)
store i32 192, i32* %2
br label %50
50: ; preds = %56, %46
%51 = load i32, i32* %2
%52 = icmp sle i32 %51, 208
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load i32, i32* %2
%55 = call i32 @hdmi_write_reg(i32 %54, i32 0)
br label %56
56: ; preds = %53
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %50
59: ; preds = %50
%60 = call i32 @hdmi_write_reg(i32 195, i32 8)
%61 = call i32 @hdmi_write_reg(i32 248, i32 255)
%62 = call i32 @hdmi_write_reg(i32 9, i32 255)
%63 = call i32 @hdmi_write_reg(i32 10, i32 255)
%64 = call i32 @hdmi_write_reg(i32 11, i32 255)
%65 = call i32 @hdmi_write_reg(i32 12, i32 255)
%66 = call i32 @hdmi_write_reg(i32 13, i32 255)
%67 = call i32 @hdmi_write_reg(i32 14, i32 0)
%68 = call i32 @hdmi_write_reg(i32 112, i32 0)
%69 = call i32 @hdmi_write_reg(i32 114, i32 0)
%70 = call i32 @hdmi_write_reg(i32 144, i32 0)
store i32 0, i32* %3
%71 = call i32 @hdmi_write_reg(i32 15, i32 1)
%72 = call i32 @hdmi_write_reg(i32 88, i32 16)
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 16
store i32 %74, i32* %3
%75 = call i32 @hdmi_write_reg(i32 89, i32 104)
%76 = load i32, i32* %3
%77 = add nsw i32 %76, 104
store i32 %77, i32* %3
%78 = call i32 @hdmi_write_reg(i32 90, i32 0)
%79 = call i32 @hdmi_write_reg(i32 91, i32 3)
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 3
store i32 %81, i32* %3
%82 = call i32 @hdmi_write_reg(i32 92, i32 0)
%83 = call i32 @hdmi_write_reg(i32 94, i32 0)
%84 = call i32 @hdmi_write_reg(i32 95, i32 0)
%85 = call i32 @hdmi_write_reg(i32 96, i32 0)
%86 = call i32 @hdmi_write_reg(i32 97, i32 0)
%87 = call i32 @hdmi_write_reg(i32 98, i32 0)
%88 = call i32 @hdmi_write_reg(i32 99, i32 0)
%89 = call i32 @hdmi_write_reg(i32 100, i32 0)
%90 = call i32 @hdmi_write_reg(i32 101, i32 0)
%91 = call i32 @writeString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%92 = call i32 @hdmi_read_reg(i32 91)
%93 = call i32 @writeHex(i32 %92)
%94 = call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%95 = call i32 @hdmi_write_reg(i32 93, i32 244)
%96 = call i32 @writeString(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%97 = call i32 @hdmi_read_reg(i32 91)
%98 = call i32 @writeHex(i32 %97)
%99 = call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%100 = call i32 @hdmi_write_reg(i32 15, i32 0)
%101 = call i32 @hdmi_write_reg(i32 205, i32 3)
%102 = call i32 @hdmi_write_reg(i32 193, i32 0)
%103 = call i32 @hdmi_write_reg(i32 224, i32 8)
%104 = call i32 @hdmi_write_reg(i32 225, i32 0)
%105 = call i32 @writeString(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Setting clock_scale to 0x\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"clock scale = 0x\00"
@.str.3 = [11 x i8] c" - passed\0A\00"
@.str.4 = [11 x i8] c" - FAILED\0A\00"
@.str.5 = [19 x i8] c"Correct vendor ID\0A\00"
@.str.6 = [22 x i8] c"FAILED - Vendor ID=0x\00"
@.str.7 = [21 x i8] c" but should be 0xca\0A\00"
@.str.8 = [19 x i8] c"Correct device ID\0A\00"
@.str.9 = [22 x i8] c"FAILED - Device ID=0x\00"
@.str.10 = [22 x i8] c" but should be 0x613\0A\00"
@.str.11 = [16 x i8] c"check: VIC = 0x\00"
@.str.12 = [21 x i8] c"check: checksum = 0x\00"
@.str.13 = [31 x i8] c"Completed HDMI initialisation\0A\00"
define void @configure_hdmi() {
%1 = tail call i32 @writeString(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @writeHex(i32 1250)
%3 = tail call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @i2c_write_clock_scale(i32 1250)
%5 = tail call i32 (...) @i2c_read_clock_scale()
%6 = tail call i32 @writeString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @writeHex(i32 %5)
%8 = tail call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %5, 1250
%10 = select i1 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0)
%11 = tail call i32 @writeString(i8* %10)
%12 = tail call i32 @hdmi_write_reg(i32 15, i32 0)
%13 = tail call i32 @hdmi_read_reg(i32 1)
%14 = icmp eq i32 %13, 202
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = tail call i32 @writeString(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 @writeHex(i32 %13)
br label %18
18: ; preds = %0, %15
%19 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), %15 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %0 ]
%20 = tail call i32 @writeString(i8* %19)
%21 = tail call i32 @hdmi_read_reg(i32 2)
%22 = tail call i32 @hdmi_read_reg(i32 3)
%23 = shl i32 %22, 8
%24 = and i32 %23, 3840
%25 = or i32 %24, %21
%26 = icmp eq i32 %25, 1555
br i1 %26, label %30, label %27
27: ; preds = %18
%28 = tail call i32 @writeString(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%29 = tail call i32 @writeHex(i32 %25)
br label %30
30: ; preds = %18, %27
%31 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), %27 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), %18 ]
%32 = tail call i32 @writeString(i8* %31)
%33 = tail call i32 @hdmi_write_reg(i32 4, i32 255)
%34 = tail call i32 @hdmi_write_reg(i32 4, i32 0)
%35 = tail call i32 @hdmi_write_reg(i32 61, i32 16)
%36 = tail call i32 @hdmi_write_reg(i32 192, i32 0)
%37 = tail call i32 @hdmi_write_reg(i32 193, i32 0)
%38 = tail call i32 @hdmi_write_reg(i32 194, i32 0)
%39 = tail call i32 @hdmi_write_reg(i32 195, i32 0)
%40 = tail call i32 @hdmi_write_reg(i32 196, i32 0)
%41 = tail call i32 @hdmi_write_reg(i32 197, i32 0)
%42 = tail call i32 @hdmi_write_reg(i32 198, i32 0)
%43 = tail call i32 @hdmi_write_reg(i32 199, i32 0)
%44 = tail call i32 @hdmi_write_reg(i32 200, i32 0)
%45 = tail call i32 @hdmi_write_reg(i32 201, i32 0)
%46 = tail call i32 @hdmi_write_reg(i32 202, i32 0)
%47 = tail call i32 @hdmi_write_reg(i32 203, i32 0)
%48 = tail call i32 @hdmi_write_reg(i32 204, i32 0)
%49 = tail call i32 @hdmi_write_reg(i32 205, i32 0)
%50 = tail call i32 @hdmi_write_reg(i32 206, i32 0)
%51 = tail call i32 @hdmi_write_reg(i32 207, i32 0)
%52 = tail call i32 @hdmi_write_reg(i32 208, i32 0)
%53 = tail call i32 @hdmi_write_reg(i32 195, i32 8)
%54 = tail call i32 @hdmi_write_reg(i32 248, i32 255)
%55 = tail call i32 @hdmi_write_reg(i32 9, i32 255)
%56 = tail call i32 @hdmi_write_reg(i32 10, i32 255)
%57 = tail call i32 @hdmi_write_reg(i32 11, i32 255)
%58 = tail call i32 @hdmi_write_reg(i32 12, i32 255)
%59 = tail call i32 @hdmi_write_reg(i32 13, i32 255)
%60 = tail call i32 @hdmi_write_reg(i32 14, i32 0)
%61 = tail call i32 @hdmi_write_reg(i32 112, i32 0)
%62 = tail call i32 @hdmi_write_reg(i32 114, i32 0)
%63 = tail call i32 @hdmi_write_reg(i32 144, i32 0)
%64 = tail call i32 @hdmi_write_reg(i32 15, i32 1)
%65 = tail call i32 @hdmi_write_reg(i32 88, i32 16)
%66 = tail call i32 @hdmi_write_reg(i32 89, i32 104)
%67 = tail call i32 @hdmi_write_reg(i32 90, i32 0)
%68 = tail call i32 @hdmi_write_reg(i32 91, i32 3)
%69 = tail call i32 @hdmi_write_reg(i32 92, i32 0)
%70 = tail call i32 @hdmi_write_reg(i32 94, i32 0)
%71 = tail call i32 @hdmi_write_reg(i32 95, i32 0)
%72 = tail call i32 @hdmi_write_reg(i32 96, i32 0)
%73 = tail call i32 @hdmi_write_reg(i32 97, i32 0)
%74 = tail call i32 @hdmi_write_reg(i32 98, i32 0)
%75 = tail call i32 @hdmi_write_reg(i32 99, i32 0)
%76 = tail call i32 @hdmi_write_reg(i32 100, i32 0)
%77 = tail call i32 @hdmi_write_reg(i32 101, i32 0)
%78 = tail call i32 @writeString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%79 = tail call i32 @hdmi_read_reg(i32 91)
%80 = tail call i32 @writeHex(i32 %79)
%81 = tail call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%82 = tail call i32 @hdmi_write_reg(i32 93, i32 244)
%83 = tail call i32 @writeString(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%84 = tail call i32 @hdmi_read_reg(i32 91)
%85 = tail call i32 @writeHex(i32 %84)
%86 = tail call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%87 = tail call i32 @hdmi_write_reg(i32 15, i32 0)
%88 = tail call i32 @hdmi_write_reg(i32 205, i32 3)
%89 = tail call i32 @hdmi_write_reg(i32 193, i32 0)
%90 = tail call i32 @hdmi_write_reg(i32 224, i32 8)
%91 = tail call i32 @hdmi_write_reg(i32 225, i32 0)
%92 = tail call i32 @writeString(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
ret void
}