#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 serial_port {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ez_writer_present(struct serial_port *);
int /*<<< orphan*/ ez_writer_ram_test(struct serial_port *);
int /*<<< orphan*/ ez_writer_reset_buffer(struct serial_port *);
int /*<<< orphan*/ ez_writer_test(struct serial_port *);
bool ez_writer_initialize(struct serial_port *sport) {
  if (!ez_writer_present(sport))
    return (false);
  if (!ez_writer_reset_buffer(sport))
    return (false);
  if (!ez_writer_test(sport))
    return (false);
  if (!ez_writer_ram_test(sport))
    return (false);
  if (!ez_writer_reset_buffer(sport))
    return (false);
  return (true);
}


x86 assembly (clang, -O0):
<ez_writer_initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ez_writer_present@plt>
cmp    $0x0,%eax
jne    116a <ez_writer_initialize+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <ez_writer_initialize+0xa9>
mov    -0x10(%rbp),%rdi
call   1030 <ez_writer_reset_buffer@plt>
cmp    $0x0,%eax
jne    1188 <ez_writer_initialize+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <ez_writer_initialize+0xa9>
mov    -0x10(%rbp),%rdi
call   1050 <ez_writer_test@plt>
cmp    $0x0,%eax
jne    11a6 <ez_writer_initialize+0x66>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <ez_writer_initialize+0xa9>
mov    -0x10(%rbp),%rdi
call   1060 <ez_writer_ram_test@plt>
cmp    $0x0,%eax
jne    11c4 <ez_writer_initialize+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <ez_writer_initialize+0xa9>
mov    -0x10(%rbp),%rdi
call   1030 <ez_writer_reset_buffer@plt>
cmp    $0x0,%eax
jne    11e2 <ez_writer_initialize+0xa2>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <ez_writer_initialize+0xa9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ez_writer_initialize>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <ez_writer_present@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1185 <ez_writer_initialize+0x45>
mov    %rbx,%rdi
call   1030 <ez_writer_reset_buffer@plt>
test   %eax,%eax
je     1185 <ez_writer_initialize+0x45>
mov    %rbx,%rdi
call   1050 <ez_writer_test@plt>
test   %eax,%eax
je     1185 <ez_writer_initialize+0x45>
mov    %rbx,%rdi
call   1060 <ez_writer_ram_test@plt>
test   %eax,%eax
je     1185 <ez_writer_initialize+0x45>
mov    %rbx,%rdi
call   1030 <ez_writer_reset_buffer@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.serial_port = type { i32 }
define i32 @ez_writer_initialize(%struct.serial_port* %0) {
%2 = alloca i32
%3 = alloca %struct.serial_port*
store %struct.serial_port* %0, %struct.serial_port** %3
%4 = load %struct.serial_port*, %struct.serial_port** %3
%5 = call i32 @ez_writer_present(%struct.serial_port* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %29
8: ; preds = %1
%9 = load %struct.serial_port*, %struct.serial_port** %3
%10 = call i32 @ez_writer_reset_buffer(%struct.serial_port* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 0, i32* %2
br label %29
13: ; preds = %8
%14 = load %struct.serial_port*, %struct.serial_port** %3
%15 = call i32 @ez_writer_test(%struct.serial_port* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 0, i32* %2
br label %29
18: ; preds = %13
%19 = load %struct.serial_port*, %struct.serial_port** %3
%20 = call i32 @ez_writer_ram_test(%struct.serial_port* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 0, i32* %2
br label %29
23: ; preds = %18
%24 = load %struct.serial_port*, %struct.serial_port** %3
%25 = call i32 @ez_writer_reset_buffer(%struct.serial_port* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 0, i32* %2
br label %29
28: ; preds = %23
store i32 1, i32* %2
br label %29
29: ; preds = %28, %27, %22, %17, %12, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.serial_port = type { i32 }
define i32 @ez_writer_initialize(%struct.serial_port* %0) {
%2 = tail call i32 @ez_writer_present(%struct.serial_port* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @ez_writer_reset_buffer(%struct.serial_port* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i32 @ez_writer_test(%struct.serial_port* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i32 @ez_writer_ram_test(%struct.serial_port* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @ez_writer_reset_buffer(%struct.serial_port* %0)
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %10, %7, %4, %1
%18 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 0, %7 ], [ 0, %10 ], [ %16, %13 ]
ret i32 %18
}