#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 mcp23017 {
  int dummy;
};
struct hd44780 {
  int dummy;
};
typedef int /*<<< orphan*/ int8_t;

/* Variables and functions */
int /*<<< orphan*/ hd44780Clear(struct mcp23017 *, struct hd44780 *);
int /*<<< orphan*/ hd44780WriteByte(struct mcp23017 *, struct hd44780 *, int,
                                    int);
int /*<<< orphan*/ usleep(int);
int8_t hd44780Init(struct mcp23017 *mcp23017, struct hd44780 *hd44780,
                   bool data, bool lines, bool font, bool display, bool cursor,
                   bool blink, bool counter, bool shift, bool mode,
                   bool direction) {
  usleep(40000);
  hd44780WriteByte(mcp23017, hd44780, 0x30, 1);
  usleep(4100);
  hd44780WriteByte(mcp23017, hd44780, 0x30, 1);
  usleep(100);
  hd44780WriteByte(mcp23017, hd44780, 0x30, 1);
  usleep(100);
  hd44780WriteByte(mcp23017, hd44780,
                   0x20 | (data * 0x10) | (lines * 0x08) | (font * 0x04), 0);
  hd44780WriteByte(mcp23017, hd44780, 0x08, 0);
  hd44780WriteByte(mcp23017, hd44780, 0x04 | (counter * 0x02) | (shift * 0x01),
                   0);
  hd44780WriteByte(mcp23017, hd44780,
                   0x08 | (display * 0x04) | (cursor * 0x02) | (blink * 0x01),
                   0);
  hd44780WriteByte(mcp23017, hd44780, 0x10 | (mode * 0x08) | (direction * 0x04),
                   0);
  hd44780WriteByte(mcp23017, hd44780, 0x80, 0);
  hd44780Clear(mcp23017, hd44780);
  return 0;
}


x86 assembly (clang, -O0):
<hd44780Init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    $0x9c40,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x1004,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x64,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x64,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
shl    $0x4,%edx
or     $0x20,%edx
mov    -0x18(%rbp),%eax
shl    $0x3,%eax
or     %eax,%edx
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
or     %eax,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x20(%rbp),%edx
shl    $0x1,%edx
or     $0x4,%edx
mov    0x28(%rbp),%eax
shl    $0x0,%eax
or     %eax,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
shl    $0x2,%edx
or     $0x8,%edx
mov    0x10(%rbp),%eax
shl    $0x1,%eax
or     %eax,%edx
mov    0x18(%rbp),%eax
shl    $0x0,%eax
or     %eax,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x30(%rbp),%edx
shl    $0x3,%edx
or     $0x10,%edx
mov    0x38(%rbp),%eax
shl    $0x2,%eax
or     %eax,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x80,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <hd44780Clear@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hd44780Init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,(%rsp)
mov    %rsi,%r14
mov    %rdi,%r13
mov    0x40(%rsp),%ebp
mov    0x50(%rsp),%ebx
mov    $0x9c40,%edi
call   1050 <usleep@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x1004,%edi
call   1050 <usleep@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x64,%edi
call   1050 <usleep@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x30,%edx
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
mov    $0x64,%edi
call   1050 <usleep@plt>
mov    (%rsp),%eax
shl    $0x4,%eax
shl    $0x3,%r12d
or     %eax,%r12d
shl    $0x2,%r15d
or     %r12d,%r15d
or     $0x20,%r15d
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
add    %ebx,%ebx
or     0x58(%rsp),%ebx
or     $0x4,%ebx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    0x4(%rsp),%eax
shl    $0x2,%eax
add    %ebp,%ebp
or     %eax,%ebp
or     0x48(%rsp),%ebp
or     $0x8,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    0x60(%rsp),%eax
shl    $0x3,%eax
mov    0x68(%rsp),%edx
shl    $0x2,%edx
or     %eax,%edx
or     $0x10,%edx
mov    %r13,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x80,%edx
xor    %ecx,%ecx
call   1030 <hd44780WriteByte@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <hd44780Clear@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mcp23017 = type { i32 }
%struct.hd44780 = type { i32 }
define i32 @hd44780Init(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%13 = alloca %struct.mcp23017*
%14 = alloca %struct.hd44780*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store %struct.mcp23017* %0, %struct.mcp23017** %13
store %struct.hd44780* %1, %struct.hd44780** %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%25 = call i32 @usleep(i32 40000)
%26 = load %struct.mcp23017*, %struct.mcp23017** %13
%27 = load %struct.hd44780*, %struct.hd44780** %14
%28 = call i32 @hd44780WriteByte(%struct.mcp23017* %26, %struct.hd44780* %27, i32 48, i32 1)
%29 = call i32 @usleep(i32 4100)
%30 = load %struct.mcp23017*, %struct.mcp23017** %13
%31 = load %struct.hd44780*, %struct.hd44780** %14
%32 = call i32 @hd44780WriteByte(%struct.mcp23017* %30, %struct.hd44780* %31, i32 48, i32 1)
%33 = call i32 @usleep(i32 100)
%34 = load %struct.mcp23017*, %struct.mcp23017** %13
%35 = load %struct.hd44780*, %struct.hd44780** %14
%36 = call i32 @hd44780WriteByte(%struct.mcp23017* %34, %struct.hd44780* %35, i32 48, i32 1)
%37 = call i32 @usleep(i32 100)
%38 = load %struct.mcp23017*, %struct.mcp23017** %13
%39 = load %struct.hd44780*, %struct.hd44780** %14
%40 = load i32, i32* %15
%41 = mul nsw i32 %40, 16
%42 = or i32 32, %41
%43 = load i32, i32* %16
%44 = mul nsw i32 %43, 8
%45 = or i32 %42, %44
%46 = load i32, i32* %17
%47 = mul nsw i32 %46, 4
%48 = or i32 %45, %47
%49 = call i32 @hd44780WriteByte(%struct.mcp23017* %38, %struct.hd44780* %39, i32 %48, i32 0)
%50 = load %struct.mcp23017*, %struct.mcp23017** %13
%51 = load %struct.hd44780*, %struct.hd44780** %14
%52 = call i32 @hd44780WriteByte(%struct.mcp23017* %50, %struct.hd44780* %51, i32 8, i32 0)
%53 = load %struct.mcp23017*, %struct.mcp23017** %13
%54 = load %struct.hd44780*, %struct.hd44780** %14
%55 = load i32, i32* %21
%56 = mul nsw i32 %55, 2
%57 = or i32 4, %56
%58 = load i32, i32* %22
%59 = mul nsw i32 %58, 1
%60 = or i32 %57, %59
%61 = call i32 @hd44780WriteByte(%struct.mcp23017* %53, %struct.hd44780* %54, i32 %60, i32 0)
%62 = load %struct.mcp23017*, %struct.mcp23017** %13
%63 = load %struct.hd44780*, %struct.hd44780** %14
%64 = load i32, i32* %18
%65 = mul nsw i32 %64, 4
%66 = or i32 8, %65
%67 = load i32, i32* %19
%68 = mul nsw i32 %67, 2
%69 = or i32 %66, %68
%70 = load i32, i32* %20
%71 = mul nsw i32 %70, 1
%72 = or i32 %69, %71
%73 = call i32 @hd44780WriteByte(%struct.mcp23017* %62, %struct.hd44780* %63, i32 %72, i32 0)
%74 = load %struct.mcp23017*, %struct.mcp23017** %13
%75 = load %struct.hd44780*, %struct.hd44780** %14
%76 = load i32, i32* %23
%77 = mul nsw i32 %76, 8
%78 = or i32 16, %77
%79 = load i32, i32* %24
%80 = mul nsw i32 %79, 4
%81 = or i32 %78, %80
%82 = call i32 @hd44780WriteByte(%struct.mcp23017* %74, %struct.hd44780* %75, i32 %81, i32 0)
%83 = load %struct.mcp23017*, %struct.mcp23017** %13
%84 = load %struct.hd44780*, %struct.hd44780** %14
%85 = call i32 @hd44780WriteByte(%struct.mcp23017* %83, %struct.hd44780* %84, i32 128, i32 0)
%86 = load %struct.mcp23017*, %struct.mcp23017** %13
%87 = load %struct.hd44780*, %struct.hd44780** %14
%88 = call i32 @hd44780Clear(%struct.mcp23017* %86, %struct.hd44780* %87)
ret i32 0
}

LLVM IR (-O2):
%struct.mcp23017 = type { i32 }
%struct.hd44780 = type { i32 }
define i32 @hd44780Init(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%13 = tail call i32 @usleep(i32 40000)
%14 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 48, i32 1)
%15 = tail call i32 @usleep(i32 4100)
%16 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 48, i32 1)
%17 = tail call i32 @usleep(i32 100)
%18 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 48, i32 1)
%19 = tail call i32 @usleep(i32 100)
%20 = shl nsw i32 %2, 4
%21 = shl nsw i32 %3, 3
%22 = shl nsw i32 %4, 2
%23 = or i32 %20, %21
%24 = or i32 %23, %22
%25 = or i32 %24, 32
%26 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %25, i32 0)
%27 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 8, i32 0)
%28 = shl nsw i32 %8, 1
%29 = or i32 %28, %9
%30 = or i32 %29, 4
%31 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %30, i32 0)
%32 = shl nsw i32 %5, 2
%33 = shl nsw i32 %6, 1
%34 = or i32 %32, %33
%35 = or i32 %34, %7
%36 = or i32 %35, 8
%37 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %36, i32 0)
%38 = shl nsw i32 %10, 3
%39 = shl nsw i32 %11, 2
%40 = or i32 %38, %39
%41 = or i32 %40, 16
%42 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 %41, i32 0)
%43 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i32 128, i32 0)
%44 = tail call i32 @hd44780Clear(%struct.mcp23017* %0, %struct.hd44780* %1)
ret i32 0
}