#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 uint16_t;
typedef scalar_t__ int16_t;

/* Variables and functions */
scalar_t__ OSD9616_send(int, int);
int /*<<< orphan*/ USBSTK5515_I2C_init();
int /*<<< orphan*/ USBSTK5515_I2C_write(int, int *, int);
int oled_init(void) {
  int16_t i2c_err;
  uint16_t cmd[10];
  USBSTK5515_I2C_init();
  i2c_err = OSD9616_send(0x00, 0x00);
  i2c_err = OSD9616_send(0x00, 0x10);
  if (i2c_err)
    return 1;
  OSD9616_send(0x00, 0x40);
  cmd[0] = 0x00 & 0x00FF;
  cmd[1] = 0x81;
  cmd[2] = 0x7f;
  USBSTK5515_I2C_write(0x3C, cmd, 3);
  OSD9616_send(0x00, 0xa1);
  OSD9616_send(0x00, 0xa6);
  cmd[0] = 0x00 & 0x00FF;
  cmd[1] = 0xa8;
  cmd[2] = 0x0f;
  USBSTK5515_I2C_write(0x3C, cmd, 3);
  OSD9616_send(0x00, 0xd3);
  OSD9616_send(0x00, 0x00);
  OSD9616_send(0x00, 0xd5);
  OSD9616_send(0x00, 0xf0);
  cmd[0] = 0x00 & 0x00FF;
  cmd[1] = 0xd9;
  cmd[2] = 0x22;
  USBSTK5515_I2C_write(0x3C, cmd, 3);
  cmd[0] = 0x00 & 0x00FF;
  cmd[1] = 0xda;
  cmd[2] = 0x02;
  USBSTK5515_I2C_write(0x3C, cmd, 3);
  OSD9616_send(0x00, 0xdb);
  OSD9616_send(0x00, 0x49);
  cmd[0] = 0x00 & 0x00FF;
  cmd[1] = 0x8d;
  cmd[2] = 0x14;
  USBSTK5515_I2C_write(0x3C, cmd, 3);
  OSD9616_send(0x00, 0xaf);
  OSD9616_send(0x00, 0x00);
  OSD9616_send(0x00, 0x10);
  OSD9616_send(0x00, 0xb0 + 0);
  return 0;
}


x86 assembly (clang, -O0):
<oled_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1040 <USBSTK5515_I2C_init@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <OSD9616_send@plt>
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1173 <oled_init+0x43>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <oled_init+0x1a8>
xor    %edi,%edi
mov    $0x40,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x81,-0x3c(%rbp)
movl   $0x7f,-0x38(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x3c,%edi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xa1,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xa6,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x40(%rbp)
movl   $0xa8,-0x3c(%rbp)
movl   $0xf,-0x38(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x3c,%edi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xd3,%esi
call   1050 <OSD9616_send@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xd5,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xf0,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x40(%rbp)
movl   $0xd9,-0x3c(%rbp)
movl   $0x22,-0x38(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x3c,%edi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
movl   $0x0,-0x40(%rbp)
movl   $0xda,-0x3c(%rbp)
movl   $0x2,-0x38(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x3c,%edi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xdb,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x49,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x8d,-0x3c(%rbp)
movl   $0x14,-0x38(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x3c,%edi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xaf,%esi
call   1050 <OSD9616_send@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb0,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oled_init>:
push   %rbx
sub    $0x30,%rsp
xor    %eax,%eax
call   1040 <USBSTK5515_I2C_init@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    12c5 <oled_init+0x195>
xor    %edi,%edi
mov    $0x40,%esi
call   1050 <OSD9616_send@plt>
movabs $0x8100000000,%rax
mov    %rax,(%rsp)
movl   $0x7f,0x8(%rsp)
mov    %rsp,%rbx
mov    $0x3c,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xa1,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xa6,%esi
call   1050 <OSD9616_send@plt>
movabs $0xa800000000,%rax
mov    %rax,(%rsp)
movl   $0xf,0x8(%rsp)
mov    $0x3c,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xd3,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xd5,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xf0,%esi
call   1050 <OSD9616_send@plt>
movabs $0xd900000000,%rax
mov    %rax,(%rsp)
movl   $0x22,0x8(%rsp)
mov    $0x3c,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
movabs $0xda00000000,%rax
mov    %rax,(%rsp)
movl   $0x2,0x8(%rsp)
mov    $0x3c,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xdb,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x49,%esi
call   1050 <OSD9616_send@plt>
movabs $0x8d00000000,%rax
mov    %rax,(%rsp)
movl   $0x14,0x8(%rsp)
mov    $0x3c,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <USBSTK5515_I2C_write@plt>
xor    %edi,%edi
mov    $0xaf,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb0,%esi
call   1050 <OSD9616_send@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @oled_init() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [10 x i32]
%4 = call i32 (...) @USBSTK5515_I2C_init()
%5 = call i64 @OSD9616_send(i32 0, i32 0)
store i64 %5, i64* %2
%6 = call i64 @OSD9616_send(i32 0, i32 16)
store i64 %6, i64* %2
%7 = load i64, i64* %2
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %49
10: ; preds = %0
%11 = call i64 @OSD9616_send(i32 0, i32 64)
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 129, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 127, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%16 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %15, i32 3)
%17 = call i64 @OSD9616_send(i32 0, i32 161)
%18 = call i64 @OSD9616_send(i32 0, i32 166)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %19
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 168, i32* %20
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 15, i32* %21
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%23 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %22, i32 3)
%24 = call i64 @OSD9616_send(i32 0, i32 211)
%25 = call i64 @OSD9616_send(i32 0, i32 0)
%26 = call i64 @OSD9616_send(i32 0, i32 213)
%27 = call i64 @OSD9616_send(i32 0, i32 240)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %28
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 217, i32* %29
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 34, i32* %30
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%32 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %31, i32 3)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %33
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 218, i32* %34
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 2, i32* %35
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%37 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %36, i32 3)
%38 = call i64 @OSD9616_send(i32 0, i32 219)
%39 = call i64 @OSD9616_send(i32 0, i32 73)
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %40
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 141, i32* %41
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 20, i32* %42
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%44 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %43, i32 3)
%45 = call i64 @OSD9616_send(i32 0, i32 175)
%46 = call i64 @OSD9616_send(i32 0, i32 0)
%47 = call i64 @OSD9616_send(i32 0, i32 16)
%48 = call i64 @OSD9616_send(i32 0, i32 176)
store i32 0, i32* %1
br label %49
49: ; preds = %10, %9
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
define i32 @oled_init() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (...) @USBSTK5515_I2C_init()
%4 = tail call i64 @OSD9616_send(i32 0, i32 0)
%5 = tail call i64 @OSD9616_send(i32 0, i32 16)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %29
7: ; preds = %0
%8 = tail call i64 @OSD9616_send(i32 0, i32 64)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 0, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 129, i32* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 127, i32* %11
%12 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %9, i32 3)
%13 = call i64 @OSD9616_send(i32 0, i32 161)
%14 = call i64 @OSD9616_send(i32 0, i32 166)
store i32 0, i32* %9
store i32 168, i32* %10
store i32 15, i32* %11
%15 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %9, i32 3)
%16 = call i64 @OSD9616_send(i32 0, i32 211)
%17 = call i64 @OSD9616_send(i32 0, i32 0)
%18 = call i64 @OSD9616_send(i32 0, i32 213)
%19 = call i64 @OSD9616_send(i32 0, i32 240)
store i32 0, i32* %9
store i32 217, i32* %10
store i32 34, i32* %11
%20 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %9, i32 3)
store i32 0, i32* %9
store i32 218, i32* %10
store i32 2, i32* %11
%21 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %9, i32 3)
%22 = call i64 @OSD9616_send(i32 0, i32 219)
%23 = call i64 @OSD9616_send(i32 0, i32 73)
store i32 0, i32* %9
store i32 141, i32* %10
store i32 20, i32* %11
%24 = call i32 @USBSTK5515_I2C_write(i32 60, i32* %9, i32 3)
%25 = call i64 @OSD9616_send(i32 0, i32 175)
%26 = call i64 @OSD9616_send(i32 0, i32 0)
%27 = call i64 @OSD9616_send(i32 0, i32 16)
%28 = call i64 @OSD9616_send(i32 0, i32 176)
br label %29
29: ; preds = %0, %7
%30 = phi i32 [ 0, %7 ], [ 1, %0 ]
ret i32 %30
}