#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*/ delayUS(int);
int /*<<< orphan*/ i2cslowread(int, unsigned char *, int, int);
unsigned char read_ublox() {
  unsigned char idat[2];
  int ix;
  for (ix = 0; ix < 10; ix++) {
    idat[0] = 0;
    i2cslowread(0x42, (unsigned char *)idat, 1, 1);
    if (idat[0] != 0xff)
      return idat[0];
    delayUS(100);
  }
  return 0xff;
}


x86 assembly (clang, -O0):
<read_ublox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1184 <read_ublox+0x64>
movb   $0x0,-0x3(%rbp)
lea    -0x3(%rbp),%rsi
mov    $0x42,%edi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1040 <i2cslowread@plt>
movzbl -0x3(%rbp),%eax
cmp    $0xff,%eax
je     116c <read_ublox+0x4c>
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    1188 <read_ublox+0x68>
mov    $0x64,%edi
call   1030 <delayUS@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112f <read_ublox+0xf>
movb   $0xff,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ublox>:
push   %rax
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
je     1149 <read_ublox+0x29>
pop    %rcx
ret
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x42,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <i2cslowread@plt>
mov    0x6(%rsp),%al
cmp    $0xff,%al
jne    1147 <read_ublox+0x27>
mov    $0x64,%edi
call   1030 <delayUS@plt>
mov    $0xff,%al
pop    %rcx
ret

LLVM IR (-O0):
define zeroext i8 @read_ublox() {
%1 = alloca i8
%2 = alloca [2 x i8]
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %20, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
store i8 0, i8* %8
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%10 = call i32 @i2cslowread(i32 66, i8* %9, i32 1, i32 1)
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp ne i32 %13, 255
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%17 = load i8, i8* %16
store i8 %17, i8* %1
br label %24
18: ; preds = %7
%19 = call i32 @delayUS(i32 100)
br label %20
20: ; preds = %18
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %4
23: ; preds = %4
store i8 -1, i8* %1
br label %24
24: ; preds = %23, %15
%25 = load i8, i8* %1
ret i8 %25
}

LLVM IR (-O2):
define zeroext i8 @read_ublox() {
%1 = alloca [2 x i8]
%2 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%3 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, -1
br i1 %5, label %6, label %53
6: ; preds = %0
%7 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%8 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%9 = load i8, i8* %2
%10 = icmp eq i8 %9, -1
br i1 %10, label %11, label %53
11: ; preds = %6
%12 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%13 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%14 = load i8, i8* %2
%15 = icmp eq i8 %14, -1
br i1 %15, label %16, label %53
16: ; preds = %11
%17 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%18 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%19 = load i8, i8* %2
%20 = icmp eq i8 %19, -1
br i1 %20, label %21, label %53
21: ; preds = %16
%22 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%23 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%24 = load i8, i8* %2
%25 = icmp eq i8 %24, -1
br i1 %25, label %26, label %53
26: ; preds = %21
%27 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%28 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%29 = load i8, i8* %2
%30 = icmp eq i8 %29, -1
br i1 %30, label %31, label %53
31: ; preds = %26
%32 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%33 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%34 = load i8, i8* %2
%35 = icmp eq i8 %34, -1
br i1 %35, label %36, label %53
36: ; preds = %31
%37 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%38 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%39 = load i8, i8* %2
%40 = icmp eq i8 %39, -1
br i1 %40, label %41, label %53
41: ; preds = %36
%42 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%43 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%44 = load i8, i8* %2
%45 = icmp eq i8 %44, -1
br i1 %45, label %46, label %53
46: ; preds = %41
%47 = call i32 @delayUS(i32 100)
store i8 0, i8* %2
%48 = call i32 @i2cslowread(i32 66, i8* %2, i32 1, i32 1)
%49 = load i8, i8* %2
%50 = icmp eq i8 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @delayUS(i32 100)
br label %53
53: ; preds = %51, %46, %41, %36, %31, %26, %21, %16, %11, %6, %0
%54 = phi i8 [ %4, %0 ], [ %9, %6 ], [ %14, %11 ], [ %19, %16 ], [ %24, %21 ], [ %29, %26 ], [ %34, %31 ], [ %39, %36 ], [ %44, %41 ], [ %49, %46 ], [ -1, %51 ]
ret i8 %54
}