#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_sendByte(int);
unsigned char SD_sendCommand(unsigned char cmd, unsigned char *para) {
  unsigned char response = 0xff;
  unsigned char i = 0;
  SD_sendByte(0xff);
  if (cmd > 0x7f) {
    SD_sendByte(0x77);
    SD_sendByte(0);
    SD_sendByte(0);
    SD_sendByte(0);
    SD_sendByte(0);
    cmd &= 0x7f;
  }
  SD_sendByte(cmd);
  for (i = 0; i < 4; i++) {
    SD_sendByte(para[i]);
  }
  SD_sendByte(0x01);
  while (response > 0x4f)
    response = SD_sendByte(0xff);
  return response;
}


x86 assembly (clang, -O0):
<SD_sendCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0xff,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
mov    $0xff,%edi
call   1030 <SD_sendByte@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jle    1171 <SD_sendCommand+0x61>
mov    $0x77,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
movzbl -0x1(%rbp),%eax
and    $0x7f,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <SD_sendByte@plt>
movb   $0x0,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x4,%eax
jge    11a9 <SD_sendCommand+0x99>
mov    -0x10(%rbp),%rax
movzbl -0x12(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <SD_sendByte@plt>
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    117e <SD_sendCommand+0x6e>
mov    $0x1,%edi
call   1030 <SD_sendByte@plt>
movzbl -0x11(%rbp),%eax
cmp    $0x4f,%eax
jle    11d2 <SD_sendCommand+0xc2>
mov    $0xff,%edi
call   1030 <SD_sendByte@plt>
mov    %al,-0x11(%rbp)
jmp    11b3 <SD_sendCommand+0xa3>
movzbl -0x11(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SD_sendCommand>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xff,%edi
call   1030 <SD_sendByte@plt>
test   %bpl,%bpl
jns    1151 <SD_sendCommand+0x41>
mov    $0x77,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
xor    %edi,%edi
call   1030 <SD_sendByte@plt>
and    $0x7f,%bpl
movzbl %bpl,%edi
call   1030 <SD_sendByte@plt>
movzbl (%rbx),%edi
call   1030 <SD_sendByte@plt>
movzbl 0x1(%rbx),%edi
call   1030 <SD_sendByte@plt>
movzbl 0x2(%rbx),%edi
call   1030 <SD_sendByte@plt>
movzbl 0x3(%rbx),%edi
call   1030 <SD_sendByte@plt>
mov    $0x1,%edi
call   1030 <SD_sendByte@plt>
nopw   0x0(%rax,%rax,1)
mov    $0xff,%edi
call   1030 <SD_sendByte@plt>
cmp    $0x4f,%al
ja     1190 <SD_sendCommand+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @SD_sendCommand(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
store i8 %0, i8* %3
store i8* %1, i8** %4
store i8 -1, i8* %5
store i8 0, i8* %6
%7 = call zeroext i8 @SD_sendByte(i32 255)
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = icmp sgt i32 %9, 127
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = call zeroext i8 @SD_sendByte(i32 119)
%13 = call zeroext i8 @SD_sendByte(i32 0)
%14 = call zeroext i8 @SD_sendByte(i32 0)
%15 = call zeroext i8 @SD_sendByte(i32 0)
%16 = call zeroext i8 @SD_sendByte(i32 0)
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = and i32 %18, 127
%20 = trunc i32 %19 to i8
store i8 %20, i8* %3
br label %21
21: ; preds = %11, %2
%22 = load i8, i8* %3
%23 = zext i8 %22 to i32
%24 = call zeroext i8 @SD_sendByte(i32 %23)
store i8 0, i8* %6
br label %25
25: ; preds = %37, %21
%26 = load i8, i8* %6
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %27, 4
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = load i8, i8* %6
%32 = zext i8 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call zeroext i8 @SD_sendByte(i32 %35)
br label %37
37: ; preds = %29
%38 = load i8, i8* %6
%39 = add i8 %38, 1
store i8 %39, i8* %6
br label %25
40: ; preds = %25
%41 = call zeroext i8 @SD_sendByte(i32 1)
br label %42
42: ; preds = %46, %40
%43 = load i8, i8* %5
%44 = zext i8 %43 to i32
%45 = icmp sgt i32 %44, 79
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call zeroext i8 @SD_sendByte(i32 255)
store i8 %47, i8* %5
br label %42
48: ; preds = %42
%49 = load i8, i8* %5
ret i8 %49
}

LLVM IR (-O2):
define zeroext i8 @SD_sendCommand(i8 zeroext %0, i8* nocapture %1) {
%3 = tail call zeroext i8 @SD_sendByte(i32 255)
%4 = icmp slt i8 %0, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call zeroext i8 @SD_sendByte(i32 119)
%7 = tail call zeroext i8 @SD_sendByte(i32 0)
%8 = tail call zeroext i8 @SD_sendByte(i32 0)
%9 = tail call zeroext i8 @SD_sendByte(i32 0)
%10 = tail call zeroext i8 @SD_sendByte(i32 0)
%11 = and i8 %0, 127
br label %12
12: ; preds = %5, %2
%13 = phi i8 [ %11, %5 ], [ %0, %2 ]
%14 = zext i8 %13 to i32
%15 = tail call zeroext i8 @SD_sendByte(i32 %14)
%16 = load i8, i8* %1
%17 = zext i8 %16 to i32
%18 = tail call zeroext i8 @SD_sendByte(i32 %17)
%19 = getelementptr inbounds i8, i8* %1, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call zeroext i8 @SD_sendByte(i32 %21)
%23 = getelementptr inbounds i8, i8* %1, i64 2
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call zeroext i8 @SD_sendByte(i32 %25)
%27 = getelementptr inbounds i8, i8* %1, i64 3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = tail call zeroext i8 @SD_sendByte(i32 %29)
%31 = tail call zeroext i8 @SD_sendByte(i32 1)
br label %32
32: ; preds = %12, %32
%33 = tail call zeroext i8 @SD_sendByte(i32 255)
%34 = icmp ugt i8 %33, 79
br i1 %34, label %32, label %35
35: ; preds = %32
ret i8 %33
}