#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*/ spi_incr_cspeed();
int spi_sendpack(int, int);
int /*<<< orphan*/ spi_sendpackcrc(int, int, int);
int /*<<< orphan*/ spi_tx(int);
int init_sdcard(void) {
  int i, ret;
  for (i = 0; i < 200; ++i) {
    spi_tx(0xff);
  }
  spi_sendpackcrc(0x40 + 0, 0x00000000, 0x95);
  spi_sendpackcrc(0x40 + 8, 0x000001aa, 0x87);
  spi_sendpack(0x40 + 55, 0x00000000);
  ret = spi_sendpack(0x40 + 41, 0x40000000);
  while (ret != 0x00) {
    spi_sendpack(0x40 + 55, 0x00000000);
    ret = spi_sendpack(0x40 + 41, 0x40000000);
  }
  spi_incr_cspeed();
  return 0;
}


x86 assembly (clang, -O0):
<init_sdcard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0xc8,-0x4(%rbp)
jge    1174 <init_sdcard+0x34>
mov    $0xff,%edi
call   1040 <spi_tx@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <init_sdcard+0xf>
mov    $0x40,%edi
xor    %esi,%esi
mov    $0x95,%edx
call   1060 <spi_sendpackcrc@plt>
mov    $0x48,%edi
mov    $0x1aa,%esi
mov    $0x87,%edx
call   1060 <spi_sendpackcrc@plt>
mov    $0x77,%edi
xor    %esi,%esi
call   1050 <spi_sendpack@plt>
mov    $0x69,%edi
mov    $0x40000000,%esi
call   1050 <spi_sendpack@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11e4 <init_sdcard+0xa4>
mov    $0x77,%edi
xor    %esi,%esi
call   1050 <spi_sendpack@plt>
mov    $0x69,%edi
mov    $0x40000000,%esi
call   1050 <spi_sendpack@plt>
mov    %eax,-0x8(%rbp)
jmp    11b7 <init_sdcard+0x77>
mov    $0x0,%al
call   1030 <spi_incr_cspeed@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_sdcard>:
push   %rbx
mov    $0xc8,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0xff,%edi
call   1040 <spi_tx@plt>
add    $0xffffffff,%ebx
jne    1150 <init_sdcard+0x10>
mov    $0x40,%edi
xor    %esi,%esi
mov    $0x95,%edx
call   1060 <spi_sendpackcrc@plt>
mov    $0x48,%edi
mov    $0x1aa,%esi
mov    $0x87,%edx
call   1060 <spi_sendpackcrc@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x77,%edi
xor    %esi,%esi
call   1050 <spi_sendpack@plt>
mov    $0x69,%edi
mov    $0x40000000,%esi
call   1050 <spi_sendpack@plt>
test   %eax,%eax
jne    1190 <init_sdcard+0x50>
xor    %eax,%eax
call   1030 <spi_incr_cspeed@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @init_sdcard() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %8, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 200
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = call i32 @spi_tx(i32 255)
br label %8
8: ; preds = %6
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
store i32 %10, i32* %1
br label %3
11: ; preds = %3
%12 = call i32 @spi_sendpackcrc(i32 64, i32 0, i32 149)
%13 = call i32 @spi_sendpackcrc(i32 72, i32 426, i32 135)
%14 = call i32 @spi_sendpack(i32 119, i32 0)
%15 = call i32 @spi_sendpack(i32 105, i32 1073741824)
store i32 %15, i32* %2
br label %16
16: ; preds = %19, %11
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @spi_sendpack(i32 119, i32 0)
%21 = call i32 @spi_sendpack(i32 105, i32 1073741824)
store i32 %21, i32* %2
br label %16
22: ; preds = %16
%23 = call i32 (...) @spi_incr_cspeed()
ret i32 0
}

LLVM IR (-O2):
define i32 @init_sdcard() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %4, %1 ]
%3 = tail call i32 @spi_tx(i32 255)
%4 = add nuw nsw i32 %2, 1
%5 = icmp eq i32 %4, 200
br i1 %5, label %6, label %1
6: ; preds = %1
%7 = tail call i32 @spi_sendpackcrc(i32 64, i32 0, i32 149)
%8 = tail call i32 @spi_sendpackcrc(i32 72, i32 426, i32 135)
%9 = tail call i32 @spi_sendpack(i32 119, i32 0)
%10 = tail call i32 @spi_sendpack(i32 105, i32 1073741824)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %6, %12
%13 = tail call i32 @spi_sendpack(i32 119, i32 0)
%14 = tail call i32 @spi_sendpack(i32 105, i32 1073741824)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %12
16: ; preds = %12, %6
%17 = tail call i32 (...) @spi_incr_cspeed()
ret i32 0
}