#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ sd_try_read_block(int /*<<< orphan*/, int *);
bool sd_read_block(uint32_t blk, uint8_t *ptr) {
  uint8_t tries = 0;
  do {
    if (sd_try_read_block(blk, ptr))
      return true;
  } while (++tries < 5);
  return false;
}


x86 assembly (clang, -O0):
<sd_read_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <sd_try_read_block@plt>
cmp    $0x0,%rax
je     1148 <sd_read_block+0x38>
movl   $0x1,-0x4(%rbp)
jmp    1166 <sd_read_block+0x56>
jmp    114d <sd_read_block+0x3d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x5,%eax
jl     1126 <sd_read_block+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_read_block>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <sd_try_read_block@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    116a <sd_read_block+0x5a>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <sd_try_read_block@plt>
test   %rax,%rax
jne    116a <sd_read_block+0x5a>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <sd_try_read_block@plt>
test   %rax,%rax
jne    116a <sd_read_block+0x5a>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <sd_try_read_block@plt>
test   %rax,%rax
jne    116a <sd_read_block+0x5a>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <sd_try_read_block@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @sd_read_block(i32 %0, i32* %1) {
%3 = tail call i64 @sd_try_read_block(i32 %0, i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = tail call i64 @sd_try_read_block(i32 %0, i32* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = tail call i64 @sd_try_read_block(i32 %0, i32* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = tail call i64 @sd_try_read_block(i32 %0, i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i64 @sd_try_read_block(i32 %0, i32* %1)
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %14, %11, %8, %5, %2
%19 = phi i32 [ 1, %2 ], [ 1, %5 ], [ 1, %8 ], [ 1, %11 ], [ %17, %14 ]
ret i32 %19
}