#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_raw_rec_byte();
int /*<<< orphan*/ sd_raw_send_byte(int);
unsigned char sd_raw_send_command_r1(unsigned char command, unsigned int arg) {
  unsigned char response;
  unsigned char i;
  sd_raw_rec_byte();
  sd_raw_send_byte(0x40 | command);
  sd_raw_send_byte((arg >> 24) & 0xff);
  sd_raw_send_byte((arg >> 16) & 0xff);
  sd_raw_send_byte((arg >> 8) & 0xff);
  sd_raw_send_byte((arg >> 0) & 0xff);
  sd_raw_send_byte((command == 0x00) ? 0x95 : 0xff);
  for (i = 0; i < 10; ++i) {
    response = sd_raw_rec_byte();
    if (response != 0xff)
      break;
  }
  return response;
}


x86 assembly (clang, -O0):
<sd_raw_send_command_r1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <sd_raw_rec_byte@plt>
movzbl -0x1(%rbp),%edi
or     $0x40,%edi
call   1030 <sd_raw_send_byte@plt>
mov    -0x8(%rbp),%edi
shr    $0x18,%edi
and    $0xff,%edi
call   1030 <sd_raw_send_byte@plt>
mov    -0x8(%rbp),%edi
shr    $0x10,%edi
and    $0xff,%edi
call   1030 <sd_raw_send_byte@plt>
mov    -0x8(%rbp),%edi
shr    $0x8,%edi
and    $0xff,%edi
call   1030 <sd_raw_send_byte@plt>
mov    -0x8(%rbp),%edi
shr    $0x0,%edi
and    $0xff,%edi
call   1030 <sd_raw_send_byte@plt>
movzbl -0x1(%rbp),%ecx
mov    $0xff,%edi
mov    $0x95,%eax
cmp    $0x0,%ecx
cmove  %eax,%edi
call   1030 <sd_raw_send_byte@plt>
movb   $0x0,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
cmp    $0xa,%eax
jge    11e2 <sd_raw_send_command_r1+0xc2>
mov    $0x0,%al
call   1040 <sd_raw_rec_byte@plt>
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0xff,%eax
je     11d0 <sd_raw_send_command_r1+0xb0>
jmp    11e2 <sd_raw_send_command_r1+0xc2>
jmp    11d5 <sd_raw_send_command_r1+0xb5>
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
jmp    11a5 <sd_raw_send_command_r1+0x85>
movzbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_raw_send_command_r1>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
mov    %ebp,%eax
or     $0x40,%al
movzbl %al,%edi
call   1030 <sd_raw_send_byte@plt>
mov    %ebx,%eax
shr    $0x18,%eax
mov    %eax,%edi
call   1030 <sd_raw_send_byte@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
call   1030 <sd_raw_send_byte@plt>
movzbl %bh,%edi
call   1030 <sd_raw_send_byte@plt>
movzbl %bl,%edi
call   1030 <sd_raw_send_byte@plt>
test   %ebp,%ebp
mov    $0x95,%eax
mov    $0xff,%edi
cmove  %eax,%edi
call   1030 <sd_raw_send_byte@plt>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
jne    11da <sd_raw_send_command_r1+0xba>
xor    %eax,%eax
call   1040 <sd_raw_rec_byte@plt>
cmp    $0xff,%al
je     11e1 <sd_raw_send_command_r1+0xc1>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <sd_raw_rec_byte@plt>

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

LLVM IR (-O2):
define zeroext i8 @sd_raw_send_command_r1(i8 zeroext %0, i32 %1) {
%3 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%4 = or i8 %0, 64
%5 = zext i8 %4 to i32
%6 = tail call i32 @sd_raw_send_byte(i32 %5)
%7 = lshr i32 %1, 24
%8 = tail call i32 @sd_raw_send_byte(i32 %7)
%9 = lshr i32 %1, 16
%10 = and i32 %9, 255
%11 = tail call i32 @sd_raw_send_byte(i32 %10)
%12 = lshr i32 %1, 8
%13 = and i32 %12, 255
%14 = tail call i32 @sd_raw_send_byte(i32 %13)
%15 = and i32 %1, 255
%16 = tail call i32 @sd_raw_send_byte(i32 %15)
%17 = icmp eq i8 %0, 0
%18 = select i1 %17, i32 149, i32 255
%19 = tail call i32 @sd_raw_send_byte(i32 %18)
%20 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%21 = icmp eq i8 %20, -1
br i1 %21, label %22, label %48
22: ; preds = %2
%23 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%24 = icmp eq i8 %23, -1
br i1 %24, label %25, label %48
25: ; preds = %22
%26 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%27 = icmp eq i8 %26, -1
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%30 = icmp eq i8 %29, -1
br i1 %30, label %31, label %48
31: ; preds = %28
%32 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%33 = icmp eq i8 %32, -1
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%36 = icmp eq i8 %35, -1
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%39 = icmp eq i8 %38, -1
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%42 = icmp eq i8 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = tail call zeroext i8 (...) @sd_raw_rec_byte()
%45 = icmp eq i8 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = tail call zeroext i8 (...) @sd_raw_rec_byte()
br label %48
48: ; preds = %46, %43, %40, %37, %34, %31, %28, %25, %22, %2
%49 = phi i8 [ %20, %2 ], [ %23, %22 ], [ %26, %25 ], [ %29, %28 ], [ %32, %31 ], [ %35, %34 ], [ %38, %37 ], [ %41, %40 ], [ %44, %43 ], [ %47, %46 ]
ret i8 %49
}