#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*/ intHandler(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ serialReadTry(char *, int);
void readAck() {
  char c;
  printf("Awaiting acknowledge...");
  if (serialReadTry(&c, 1) != 0) {
    printf(" Could not read!\n");
    intHandler(0);
  }
  if (c != 0x42) {
    printf(" Was not OK!\n");
    intHandler(0);
  }
  printf(" OK\n");
}


x86 assembly (clang, -O0):
<readAck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1(%rbp),%rdi
mov    $0x1,%esi
call   1030 <serialReadTry@plt>
cmp    $0x0,%rax
je     116f <readAck+0x3f>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <intHandler@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x42,%eax
je     118f <readAck+0x5f>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <intHandler@plt>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readAck>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
call   1040 <serialReadTry@plt>
test   %rax,%rax
je     1174 <readAck+0x34>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <intHandler@plt>
cmpb   $0x42,0x7(%rsp)
je     118e <readAck+0x4e>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <intHandler@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Awaiting acknowledge...\00"
@.str.1 = [18 x i8] c" Could not read!\0A\00"
@.str.2 = [14 x i8] c" Was not OK!\0A\00"
@.str.3 = [5 x i8] c" OK\0A\00"
define void @readAck() {
%1 = alloca i8
%2 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @serialReadTry(i8* %1, i32 1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @intHandler(i32 0)
br label %8
8: ; preds = %5, %0
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 66
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @intHandler(i32 0)
br label %15
15: ; preds = %12, %8
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Awaiting acknowledge...\00"
@str = [4 x i8] c" OK\00"
@str.4 = [13 x i8] c" Was not OK!\00"
@str.5 = [17 x i8] c" Could not read!\00"
define void @readAck() {
%1 = alloca i8
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @serialReadTry(i8* %1, i32 1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%7 = call i32 @intHandler(i32 0)
br label %8
8: ; preds = %5, %0
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 66
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%13 = call i32 @intHandler(i32 0)
br label %14
14: ; preds = %11, %8
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}