#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 */
unsigned char SD_sendCommand(int, unsigned long);
unsigned char SD_erase(unsigned long startBlock, unsigned long totalBlocks) {
  unsigned char response;
  response = SD_sendCommand((0x40 + 32), startBlock << 9);
  if (response != 0x00)
    return response;
  response = SD_sendCommand((0x40 + 33), (startBlock + totalBlocks - 1) << 9);
  if (response != 0x00)
    return response;
  response = SD_sendCommand((0x40 + 38), 0);
  if (response != 0x00)
    return response;
  return 0;
}


x86 assembly (clang, -O0):
<SD_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
shl    $0x9,%rsi
mov    $0x60,%edi
call   1030 <SD_sendCommand@plt>
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     114d <SD_erase+0x3d>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11af <SD_erase+0x9f>
mov    -0x10(%rbp),%rsi
add    -0x18(%rbp),%rsi
sub    $0x1,%rsi
shl    $0x9,%rsi
mov    $0x61,%edi
call   1030 <SD_sendCommand@plt>
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     1182 <SD_erase+0x72>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11af <SD_erase+0x9f>
mov    $0x66,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SD_sendCommand@plt>
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     11ab <SD_erase+0x9b>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11af <SD_erase+0x9f>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SD_erase>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%rsi
shl    $0x9,%rsi
mov    $0x60,%edi
call   1030 <SD_sendCommand@plt>
test   %al,%al
jne    114e <SD_erase+0x3e>
add    %r14,%rbx
shl    $0x9,%rbx
add    $0xfffffffffffffe00,%rbx
mov    $0x61,%edi
mov    %rbx,%rsi
call   1030 <SD_sendCommand@plt>
test   %al,%al
je     1156 <SD_erase+0x46>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x66,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <SD_sendCommand@plt>

LLVM IR (-O0):
define zeroext i8 @SD_erase(i64 %0, i64 %1) {
%3 = alloca i8
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8
store i64 %0, i64* %4
store i64 %1, i64* %5
%7 = load i64, i64* %4
%8 = shl i64 %7, 9
%9 = call zeroext i8 @SD_sendCommand(i32 96, i64 %8)
store i8 %9, i8* %6
%10 = load i8, i8* %6
%11 = zext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i8, i8* %6
store i8 %14, i8* %3
br label %35
15: ; preds = %2
%16 = load i64, i64* %4
%17 = load i64, i64* %5
%18 = add i64 %16, %17
%19 = sub i64 %18, 1
%20 = shl i64 %19, 9
%21 = call zeroext i8 @SD_sendCommand(i32 97, i64 %20)
store i8 %21, i8* %6
%22 = load i8, i8* %6
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = load i8, i8* %6
store i8 %26, i8* %3
br label %35
27: ; preds = %15
%28 = call zeroext i8 @SD_sendCommand(i32 102, i64 0)
store i8 %28, i8* %6
%29 = load i8, i8* %6
%30 = zext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = load i8, i8* %6
store i8 %33, i8* %3
br label %35
34: ; preds = %27
store i8 0, i8* %3
br label %35
35: ; preds = %34, %32, %25, %13
%36 = load i8, i8* %3
ret i8 %36
}

LLVM IR (-O2):
define zeroext i8 @SD_erase(i64 %0, i64 %1) {
%3 = shl i64 %0, 9
%4 = tail call zeroext i8 @SD_sendCommand(i32 96, i64 %3)
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = add i64 %1, %0
%8 = shl i64 %7, 9
%9 = add i64 %8, -512
%10 = tail call zeroext i8 @SD_sendCommand(i32 97, i64 %9)
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call zeroext i8 @SD_sendCommand(i32 102, i64 0)
br label %14
14: ; preds = %12, %6, %2
%15 = phi i8 [ %4, %2 ], [ %10, %6 ], [ %13, %12 ]
ret i8 %15
}