#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 /*<<< orphan*/ infohelper_output(int, char *, unsigned char);
int serialport_read(unsigned char *, int);
int serialport_receive_C0(void) {
  unsigned char b;
  b = 0x00;
  if (serialport_read(&b, 1) != 1) {
    return 0;
  }
  if (b != 0xC0) {
    infohelper_output(3, "serialport_receive_C0: %02X instead of C0", b);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<serialport_receive_C0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x5(%rbp)
lea    -0x5(%rbp),%rdi
mov    $0x1,%esi
call   1030 <serialport_read@plt>
cmp    $0x1,%eax
je     114f <serialport_receive_C0+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1186 <serialport_receive_C0+0x66>
movzbl -0x5(%rbp),%eax
cmp    $0xc0,%eax
je     117f <serialport_receive_C0+0x5f>
mov    $0x3,%edi
lea    0xe96(%rip),%rsi
movzbl -0x5(%rbp),%edx
call   1040 <infohelper_output@plt>
movl   $0x0,-0x4(%rbp)
jmp    1186 <serialport_receive_C0+0x66>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serialport_receive_C0>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xf(%rsp)
lea    0xf(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
call   1030 <serialport_read@plt>
cmp    $0x1,%eax
jne    115f <serialport_receive_C0+0x3f>
mov    0xf(%rsp),%al
cmp    $0xc0,%al
je     1161 <serialport_receive_C0+0x41>
movzbl %al,%edx
lea    0xeab(%rip),%rsi
mov    $0x3,%edi
call   1040 <infohelper_output@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"serialport_receive_C0: %02X instead of C0\00"
define i32 @serialport_receive_C0() {
%1 = alloca i32
%2 = alloca i8
store i8 0, i8* %2
%3 = call i32 @serialport_read(i8* %2, i32 1)
%4 = icmp ne i32 %3, 1
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 0, i32* %1
br label %14
6: ; preds = %0
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = icmp ne i32 %8, 192
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8, i8* %2
%12 = call i32 @infohelper_output(i32 3, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8 zeroext %11)
store i32 0, i32* %1
br label %14
13: ; preds = %6
store i32 1, i32* %1
br label %14
14: ; preds = %13, %10, %5
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [42 x i8] c"serialport_receive_C0: %02X instead of C0\00"
define i32 @serialport_receive_C0() {
%1 = alloca i8
store i8 0, i8* %1
%2 = call i32 @serialport_read(i8* %1, i32 1)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, -64
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = call i32 @infohelper_output(i32 3, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
br label %9
9: ; preds = %4, %0, %7
%10 = phi i32 [ 0, %7 ], [ 0, %0 ], [ 1, %4 ]
ret i32 %10
}