#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*/ sd_raw_available();
int sd_raw_rec_byte();
scalar_t__ sd_raw_send_command_r1(int, int /*<<< orphan*/);
int sd_raw_get_cid_csd(char *info) {
  if (!info || !sd_raw_available())
    return 0;
  (*(volatile unsigned long *)(0xE0028000 + 0x0C)) |= (1 << 7);
  if (sd_raw_send_command_r1(0x0a, 0)) {
    (*(volatile unsigned long *)(0xE0028000 + 0x04)) |= (1 << 7);
    return 1;
  }
  while (sd_raw_rec_byte() != 0xfe)
    ;
  unsigned char i;
  for (i = 0; i < 18; ++i) {
    info[i] = sd_raw_rec_byte();
  }
  if (sd_raw_send_command_r1(0x09, 0)) {
    (*(volatile unsigned long *)(0xE0028000 + 0x04)) |= (1 << 7);
    return 2;
  }
  while (sd_raw_rec_byte() != 0xfe)
    ;
  for (i = 0; i < 18; ++i) {
    info[i + 18] = sd_raw_rec_byte();
  }
  (*(volatile unsigned long *)(0xE0028000 + 0x04)) |= (1 << 7);
  return 3;
}


x86 assembly (clang, -O0):
<sd_raw_get_cid_csd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1157 <sd_raw_get_cid_csd+0x27>
mov    $0x0,%al
call   1040 <sd_raw_available@plt>
cmp    $0x0,%eax
jne    1163 <sd_raw_get_cid_csd+0x33>
movl   $0x0,-0x4(%rbp)
jmp    12ac <sd_raw_get_cid_csd+0x17c>
mov    $0xe002800c,%eax
mov    (%rax),%rcx
or     $0x80,%rcx
mov    $0xe002800c,%eax
mov    %rcx,(%rax)
mov    $0xa,%edi
xor    %esi,%esi
call   1030 <sd_raw_send_command_r1@plt>
cmp    $0x0,%rax
je     11b3 <sd_raw_get_cid_csd+0x83>
mov    $0xe0028004,%eax
mov    (%rax),%rcx
or     $0x80,%rcx
mov    $0xe0028004,%eax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    12ac <sd_raw_get_cid_csd+0x17c>
jmp    11b8 <sd_raw_get_cid_csd+0x88>
mov    $0x0,%al
call   1050 <sd_raw_rec_byte@plt>
cmp    $0xfe,%eax
je     11cf <sd_raw_get_cid_csd+0x9f>
jmp    11b8 <sd_raw_get_cid_csd+0x88>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x12,%eax
jge    1201 <sd_raw_get_cid_csd+0xd1>
mov    $0x0,%al
call   1050 <sd_raw_rec_byte@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11d3 <sd_raw_get_cid_csd+0xa3>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <sd_raw_send_command_r1@plt>
cmp    $0x0,%rax
je     123a <sd_raw_get_cid_csd+0x10a>
mov    $0xe0028004,%eax
mov    (%rax),%rcx
or     $0x80,%rcx
mov    $0xe0028004,%eax
mov    %rcx,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    12ac <sd_raw_get_cid_csd+0x17c>
jmp    123f <sd_raw_get_cid_csd+0x10f>
mov    $0x0,%al
call   1050 <sd_raw_rec_byte@plt>
cmp    $0xfe,%eax
je     1256 <sd_raw_get_cid_csd+0x126>
jmp    123f <sd_raw_get_cid_csd+0x10f>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x12,%eax
jge    128e <sd_raw_get_cid_csd+0x15e>
mov    $0x0,%al
call   1050 <sd_raw_rec_byte@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
add    $0x12,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    125a <sd_raw_get_cid_csd+0x12a>
mov    $0xe0028004,%eax
mov    (%rax),%rcx
or     $0x80,%rcx
mov    $0xe0028004,%eax
mov    %rcx,(%rax)
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_raw_get_cid_csd>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1330 <sd_raw_get_cid_csd+0x200>
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <sd_raw_available@plt>
test   %eax,%eax
je     1332 <sd_raw_get_cid_csd+0x202>
mov    $0xe0028004,%r14d
orq    $0x80,0x8(%r14)
mov    $0xa,%edi
xor    %esi,%esi
call   1030 <sd_raw_send_command_r1@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1327 <sd_raw_get_cid_csd+0x1f7>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
cmp    $0xfe,%eax
jne    1180 <sd_raw_get_cid_csd+0x50>
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x3(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x5(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x7(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x8(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x9(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xa(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xb(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xc(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xd(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xe(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0xf(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x10(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x11(%rbx)
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <sd_raw_send_command_r1@plt>
mov    $0x2,%ebp
test   %rax,%rax
jne    1327 <sd_raw_get_cid_csd+0x1f7>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
cmp    $0xfe,%eax
jne    1260 <sd_raw_get_cid_csd+0x130>
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x12(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x13(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x14(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x15(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x16(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x17(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x18(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x19(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1a(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1b(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1c(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1d(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1e(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x1f(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x20(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x21(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x22(%rbx)
xor    %eax,%eax
call   1050 <sd_raw_rec_byte@plt>
mov    %al,0x23(%rbx)
mov    $0x3,%ebp
orq    $0x80,(%r14)
jmp    1332 <sd_raw_get_cid_csd+0x202>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sd_raw_get_cid_csd(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 (...) @sd_raw_available()
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %7, %1
store i32 0, i32* %2
br label %70
11: ; preds = %7
%12 = load volatile i64, i64* inttoptr (i64 3758260236 to i64*)
%13 = or i64 %12, 128
store volatile i64 %13, i64* inttoptr (i64 3758260236 to i64*)
%14 = call i64 @sd_raw_send_command_r1(i32 10, i32 0)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load volatile i64, i64* inttoptr (i64 3758260228 to i64*)
%18 = or i64 %17, 128
store volatile i64 %18, i64* inttoptr (i64 3758260228 to i64*)
store i32 1, i32* %2
br label %70
19: ; preds = %11
br label %20
20: ; preds = %23, %19
%21 = call i32 (...) @sd_raw_rec_byte()
%22 = icmp ne i32 %21, 254
br i1 %22, label %23, label %24
23: ; preds = %20
br label %20
24: ; preds = %20
store i8 0, i8* %4
br label %25
25: ; preds = %36, %24
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %27, 18
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = call i32 (...) @sd_raw_rec_byte()
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %3
%33 = load i8, i8* %4
%34 = zext i8 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %29
%37 = load i8, i8* %4
%38 = add i8 %37, 1
store i8 %38, i8* %4
br label %25
39: ; preds = %25
%40 = call i64 @sd_raw_send_command_r1(i32 9, i32 0)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load volatile i64, i64* inttoptr (i64 3758260228 to i64*)
%44 = or i64 %43, 128
store volatile i64 %44, i64* inttoptr (i64 3758260228 to i64*)
store i32 2, i32* %2
br label %70
45: ; preds = %39
br label %46
46: ; preds = %49, %45
%47 = call i32 (...) @sd_raw_rec_byte()
%48 = icmp ne i32 %47, 254
br i1 %48, label %49, label %50
49: ; preds = %46
br label %46
50: ; preds = %46
store i8 0, i8* %4
br label %51
51: ; preds = %64, %50
%52 = load i8, i8* %4
%53 = zext i8 %52 to i32
%54 = icmp slt i32 %53, 18
br i1 %54, label %55, label %67
55: ; preds = %51
%56 = call i32 (...) @sd_raw_rec_byte()
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %3
%59 = load i8, i8* %4
%60 = zext i8 %59 to i32
%61 = add nsw i32 %60, 18
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %58, i64 %62
store i8 %57, i8* %63
br label %64
64: ; preds = %55
%65 = load i8, i8* %4
%66 = add i8 %65, 1
store i8 %66, i8* %4
br label %51
67: ; preds = %51
%68 = load volatile i64, i64* inttoptr (i64 3758260228 to i64*)
%69 = or i64 %68, 128
store volatile i64 %69, i64* inttoptr (i64 3758260228 to i64*)
store i32 3, i32* %2
br label %70
70: ; preds = %67, %42, %16, %10
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
define i32 @sd_raw_get_cid_csd(i8* writeonly %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %132, label %3
3: ; preds = %1
%4 = tail call i32 (...) @sd_raw_available()
%5 = icmp eq i32 %4, 0
br i1 %5, label %132, label %6
6: ; preds = %3
%7 = load volatile i64, i64* inttoptr (i64 3758260236 to i64*)
%8 = or i64 %7, 128
store volatile i64 %8, i64* inttoptr (i64 3758260236 to i64*)
%9 = tail call i64 @sd_raw_send_command_r1(i32 10, i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %128
11: ; preds = %6, %11
%12 = tail call i32 (...) @sd_raw_rec_byte()
%13 = icmp eq i32 %12, 254
br i1 %13, label %14, label %11
14: ; preds = %11
%15 = tail call i32 (...) @sd_raw_rec_byte()
%16 = trunc i32 %15 to i8
store i8 %16, i8* %0
%17 = tail call i32 (...) @sd_raw_rec_byte()
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %18, i8* %19
%20 = tail call i32 (...) @sd_raw_rec_byte()
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %21, i8* %22
%23 = tail call i32 (...) @sd_raw_rec_byte()
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %24, i8* %25
%26 = tail call i32 (...) @sd_raw_rec_byte()
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %27, i8* %28
%29 = tail call i32 (...) @sd_raw_rec_byte()
%30 = trunc i32 %29 to i8
%31 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %30, i8* %31
%32 = tail call i32 (...) @sd_raw_rec_byte()
%33 = trunc i32 %32 to i8
%34 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %33, i8* %34
%35 = tail call i32 (...) @sd_raw_rec_byte()
%36 = trunc i32 %35 to i8
%37 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %36, i8* %37
%38 = tail call i32 (...) @sd_raw_rec_byte()
%39 = trunc i32 %38 to i8
%40 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %39, i8* %40
%41 = tail call i32 (...) @sd_raw_rec_byte()
%42 = trunc i32 %41 to i8
%43 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %42, i8* %43
%44 = tail call i32 (...) @sd_raw_rec_byte()
%45 = trunc i32 %44 to i8
%46 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %45, i8* %46
%47 = tail call i32 (...) @sd_raw_rec_byte()
%48 = trunc i32 %47 to i8
%49 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %48, i8* %49
%50 = tail call i32 (...) @sd_raw_rec_byte()
%51 = trunc i32 %50 to i8
%52 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %51, i8* %52
%53 = tail call i32 (...) @sd_raw_rec_byte()
%54 = trunc i32 %53 to i8
%55 = getelementptr inbounds i8, i8* %0, i64 13
store i8 %54, i8* %55
%56 = tail call i32 (...) @sd_raw_rec_byte()
%57 = trunc i32 %56 to i8
%58 = getelementptr inbounds i8, i8* %0, i64 14
store i8 %57, i8* %58
%59 = tail call i32 (...) @sd_raw_rec_byte()
%60 = trunc i32 %59 to i8
%61 = getelementptr inbounds i8, i8* %0, i64 15
store i8 %60, i8* %61
%62 = tail call i32 (...) @sd_raw_rec_byte()
%63 = trunc i32 %62 to i8
%64 = getelementptr inbounds i8, i8* %0, i64 16
store i8 %63, i8* %64
%65 = tail call i32 (...) @sd_raw_rec_byte()
%66 = trunc i32 %65 to i8
%67 = getelementptr inbounds i8, i8* %0, i64 17
store i8 %66, i8* %67
%68 = tail call i64 @sd_raw_send_command_r1(i32 9, i32 0)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %128
70: ; preds = %14, %70
%71 = tail call i32 (...) @sd_raw_rec_byte()
%72 = icmp eq i32 %71, 254
br i1 %72, label %73, label %70
73: ; preds = %70
%74 = tail call i32 (...) @sd_raw_rec_byte()
%75 = trunc i32 %74 to i8
%76 = getelementptr inbounds i8, i8* %0, i64 18
store i8 %75, i8* %76
%77 = tail call i32 (...) @sd_raw_rec_byte()
%78 = trunc i32 %77 to i8
%79 = getelementptr inbounds i8, i8* %0, i64 19
store i8 %78, i8* %79
%80 = tail call i32 (...) @sd_raw_rec_byte()
%81 = trunc i32 %80 to i8
%82 = getelementptr inbounds i8, i8* %0, i64 20
store i8 %81, i8* %82
%83 = tail call i32 (...) @sd_raw_rec_byte()
%84 = trunc i32 %83 to i8
%85 = getelementptr inbounds i8, i8* %0, i64 21
store i8 %84, i8* %85
%86 = tail call i32 (...) @sd_raw_rec_byte()
%87 = trunc i32 %86 to i8
%88 = getelementptr inbounds i8, i8* %0, i64 22
store i8 %87, i8* %88
%89 = tail call i32 (...) @sd_raw_rec_byte()
%90 = trunc i32 %89 to i8
%91 = getelementptr inbounds i8, i8* %0, i64 23
store i8 %90, i8* %91
%92 = tail call i32 (...) @sd_raw_rec_byte()
%93 = trunc i32 %92 to i8
%94 = getelementptr inbounds i8, i8* %0, i64 24
store i8 %93, i8* %94
%95 = tail call i32 (...) @sd_raw_rec_byte()
%96 = trunc i32 %95 to i8
%97 = getelementptr inbounds i8, i8* %0, i64 25
store i8 %96, i8* %97
%98 = tail call i32 (...) @sd_raw_rec_byte()
%99 = trunc i32 %98 to i8
%100 = getelementptr inbounds i8, i8* %0, i64 26
store i8 %99, i8* %100
%101 = tail call i32 (...) @sd_raw_rec_byte()
%102 = trunc i32 %101 to i8
%103 = getelementptr inbounds i8, i8* %0, i64 27
store i8 %102, i8* %103
%104 = tail call i32 (...) @sd_raw_rec_byte()
%105 = trunc i32 %104 to i8
%106 = getelementptr inbounds i8, i8* %0, i64 28
store i8 %105, i8* %106
%107 = tail call i32 (...) @sd_raw_rec_byte()
%108 = trunc i32 %107 to i8
%109 = getelementptr inbounds i8, i8* %0, i64 29
store i8 %108, i8* %109
%110 = tail call i32 (...) @sd_raw_rec_byte()
%111 = trunc i32 %110 to i8
%112 = getelementptr inbounds i8, i8* %0, i64 30
store i8 %111, i8* %112
%113 = tail call i32 (...) @sd_raw_rec_byte()
%114 = trunc i32 %113 to i8
%115 = getelementptr inbounds i8, i8* %0, i64 31
store i8 %114, i8* %115
%116 = tail call i32 (...) @sd_raw_rec_byte()
%117 = trunc i32 %116 to i8
%118 = getelementptr inbounds i8, i8* %0, i64 32
store i8 %117, i8* %118
%119 = tail call i32 (...) @sd_raw_rec_byte()
%120 = trunc i32 %119 to i8
%121 = getelementptr inbounds i8, i8* %0, i64 33
store i8 %120, i8* %121
%122 = tail call i32 (...) @sd_raw_rec_byte()
%123 = trunc i32 %122 to i8
%124 = getelementptr inbounds i8, i8* %0, i64 34
store i8 %123, i8* %124
%125 = tail call i32 (...) @sd_raw_rec_byte()
%126 = trunc i32 %125 to i8
%127 = getelementptr inbounds i8, i8* %0, i64 35
store i8 %126, i8* %127
br label %128
128: ; preds = %14, %6, %73
%129 = phi i32 [ 3, %73 ], [ 1, %6 ], [ 2, %14 ]
%130 = load volatile i64, i64* inttoptr (i64 3758260228 to i64*)
%131 = or i64 %130, 128
store volatile i64 %131, i64* inttoptr (i64 3758260228 to i64*)
br label %132
132: ; preds = %128, %1, %3
%133 = phi i32 [ 0, %3 ], [ 0, %1 ], [ %129, %128 ]
ret i32 %133
}