#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 uint8_t;
typedef int int8_t;

/* Variables and functions */
scalar_t__ dmd_hw_init();
int hd44780_entry_mode_set(int, int /*<<< orphan*/);
int8_t dmd_init_5x7(uint8_t *progress) {
  if (*progress == 0) {
    if (dmd_hw_init()) {
      return (-1);
    } else {
      *progress = *progress + 1;
    }
  }
  if (*progress == 1) {
    return (hd44780_entry_mode_set(1, 0));
  } else {
    return (-1);
  }
}


x86 assembly (clang, -O0):
<dmd_init_5x7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    116a <dmd_init_5x7+0x4a>
mov    $0x0,%al
call   1040 <dmd_hw_init@plt>
cmp    $0x0,%rax
je     1156 <dmd_init_5x7+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <dmd_init_5x7+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    116a <dmd_init_5x7+0x4a>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jne    118b <dmd_init_5x7+0x6b>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <hd44780_entry_mode_set@plt>
mov    %eax,-0x4(%rbp)
jmp    1192 <dmd_init_5x7+0x72>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmd_init_5x7>:
push   %rbx
mov    (%rdi),%eax
test   %eax,%eax
je     1139 <dmd_init_5x7+0x19>
cmp    $0x1,%eax
jne    1154 <dmd_init_5x7+0x34>
mov    $0x1,%edi
xor    %esi,%esi
pop    %rbx
jmp    1030 <hd44780_entry_mode_set@plt>
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <dmd_hw_init@plt>
test   %rax,%rax
jne    1154 <dmd_init_5x7+0x34>
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
cmp    $0x1,%eax
je     112c <dmd_init_5x7+0xc>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @dmd_init_5x7(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = call i64 (...) @dmd_hw_init()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 -1, i32* %2
br label %24
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = load i32*, i32** %3
store i32 %14, i32* %15
br label %16
16: ; preds = %11
br label %17
17: ; preds = %16, %1
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @hd44780_entry_mode_set(i32 1, i32 0)
store i32 %22, i32* %2
br label %24
23: ; preds = %17
store i32 -1, i32* %2
br label %24
24: ; preds = %23, %21, %10
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @dmd_init_5x7(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call i64 (...) @dmd_hw_init()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %0
%9 = add nsw i32 %8, 1
store i32 %9, i32* %0
br label %10
10: ; preds = %7, %1
%11 = phi i32 [ %9, %7 ], [ %2, %1 ]
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @hd44780_entry_mode_set(i32 1, i32 0)
br label %15
15: ; preds = %10, %4, %13
%16 = phi i32 [ %14, %13 ], [ -1, %4 ], [ -1, %10 ]
ret i32 %16
}