#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_Write(int, int);
int /*<<< orphan*/ delay_ms(int);
void W5100_Init(void) {
  unsigned char mac_addr[] = {0x00, 0x16, 0x36, 0xDE, 0x58, 0xF6};
  unsigned char ip_addr[] = {192, 168, 2, 10};
  unsigned char sub_mask[] = {255, 255, 255, 0};
  unsigned char gtw_addr[] = {192, 168, 2, 1};
  SPI_Write(0x0000, 0x80);
  delay_ms(1);
  SPI_Write(0x0001 + 0, gtw_addr[0]);
  SPI_Write(0x0001 + 1, gtw_addr[1]);
  SPI_Write(0x0001 + 2, gtw_addr[2]);
  SPI_Write(0x0001 + 3, gtw_addr[3]);
  delay_ms(1);
  SPI_Write(0x0009 + 0, mac_addr[0]);
  SPI_Write(0x0009 + 1, mac_addr[1]);
  SPI_Write(0x0009 + 2, mac_addr[2]);
  SPI_Write(0x0009 + 3, mac_addr[3]);
  SPI_Write(0x0009 + 4, mac_addr[4]);
  SPI_Write(0x0009 + 5, mac_addr[5]);
  delay_ms(1);
  SPI_Write(0x0005 + 0, sub_mask[0]);
  SPI_Write(0x0005 + 1, sub_mask[1]);
  SPI_Write(0x0005 + 2, sub_mask[2]);
  SPI_Write(0x0005 + 3, sub_mask[3]);
  delay_ms(1);
  SPI_Write(0x000F + 0, ip_addr[0]);
  SPI_Write(0x000F + 1, ip_addr[1]);
  SPI_Write(0x000F + 2, ip_addr[2]);
  SPI_Write(0x000F + 3, ip_addr[3]);
  delay_ms(1);
  SPI_Write(0x001A, 0x55);
  SPI_Write(0x001B, 0x55);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xecc(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x12(%rbp)
xor    %edi,%edi
mov    $0x80,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
movzbl -0x12(%rbp),%esi
mov    $0x1,%edi
call   1040 <SPI_Write@plt>
movzbl -0x11(%rbp),%esi
mov    $0x2,%edi
call   1040 <SPI_Write@plt>
movzbl -0x10(%rbp),%esi
mov    $0x3,%edi
call   1040 <SPI_Write@plt>
movzbl -0xf(%rbp),%esi
mov    $0x4,%edi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
movzbl -0x6(%rbp),%esi
mov    $0x9,%edi
call   1040 <SPI_Write@plt>
movzbl -0x5(%rbp),%esi
mov    $0xa,%edi
call   1040 <SPI_Write@plt>
movzbl -0x4(%rbp),%esi
mov    $0xb,%edi
call   1040 <SPI_Write@plt>
movzbl -0x3(%rbp),%esi
mov    $0xc,%edi
call   1040 <SPI_Write@plt>
movzbl -0x2(%rbp),%esi
mov    $0xd,%edi
call   1040 <SPI_Write@plt>
movzbl -0x1(%rbp),%esi
mov    $0xe,%edi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
movzbl -0xe(%rbp),%esi
mov    $0x5,%edi
call   1040 <SPI_Write@plt>
movzbl -0xd(%rbp),%esi
mov    $0x6,%edi
call   1040 <SPI_Write@plt>
movzbl -0xc(%rbp),%esi
mov    $0x7,%edi
call   1040 <SPI_Write@plt>
movzbl -0xb(%rbp),%esi
mov    $0x8,%edi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
movzbl -0xa(%rbp),%esi
mov    $0xf,%edi
call   1040 <SPI_Write@plt>
movzbl -0x9(%rbp),%esi
mov    $0x10,%edi
call   1040 <SPI_Write@plt>
movzbl -0x8(%rbp),%esi
mov    $0x11,%edi
call   1040 <SPI_Write@plt>
movzbl -0x7(%rbp),%esi
mov    $0x12,%edi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0x1a,%edi
mov    $0x55,%esi
call   1040 <SPI_Write@plt>
mov    $0x1b,%edi
mov    $0x55,%esi
call   1040 <SPI_Write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rax
xor    %edi,%edi
mov    $0x80,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0x1,%edi
mov    $0xc0,%esi
call   1040 <SPI_Write@plt>
mov    $0x2,%edi
mov    $0xa8,%esi
call   1040 <SPI_Write@plt>
mov    $0x3,%edi
mov    $0x2,%esi
call   1040 <SPI_Write@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1040 <SPI_Write@plt>
mov    $0xa,%edi
mov    $0x16,%esi
call   1040 <SPI_Write@plt>
mov    $0xb,%edi
mov    $0x36,%esi
call   1040 <SPI_Write@plt>
mov    $0xc,%edi
mov    $0xde,%esi
call   1040 <SPI_Write@plt>
mov    $0xd,%edi
mov    $0x58,%esi
call   1040 <SPI_Write@plt>
mov    $0xe,%edi
mov    $0xf6,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0x5,%edi
mov    $0xff,%esi
call   1040 <SPI_Write@plt>
mov    $0x6,%edi
mov    $0xff,%esi
call   1040 <SPI_Write@plt>
mov    $0x7,%edi
mov    $0xff,%esi
call   1040 <SPI_Write@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0xf,%edi
mov    $0xc0,%esi
call   1040 <SPI_Write@plt>
mov    $0x10,%edi
mov    $0xa8,%esi
call   1040 <SPI_Write@plt>
mov    $0x11,%edi
mov    $0x2,%esi
call   1040 <SPI_Write@plt>
mov    $0x12,%edi
mov    $0xa,%esi
call   1040 <SPI_Write@plt>
mov    $0x1,%edi
call   1030 <delay_ms@plt>
mov    $0x1a,%edi
mov    $0x55,%esi
call   1040 <SPI_Write@plt>
mov    $0x1b,%edi
mov    $0x55,%esi
pop    %rax
jmp    1040 <SPI_Write@plt>

LLVM IR (-O0):
@__const.W5100_Init.mac_addr = [6 x i8] c"\00\166\DEX\F6"
@__const.W5100_Init.ip_addr = [4 x i8] c"\C0\A8\02\0A"
@__const.W5100_Init.sub_mask = [4 x i8] c"\FF\FF\FF\00"
@__const.W5100_Init.gtw_addr = [4 x i8] c"\C0\A8\02\01"
define void @W5100_Init() {
%1 = alloca [6 x i8]
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = bitcast [6 x i8]* %1 to i8*
%6 = bitcast [4 x i8]* %2 to i8*
%7 = bitcast [4 x i8]* %3 to i8*
%8 = bitcast [4 x i8]* %4 to i8*
%9 = call i32 @SPI_Write(i32 0, i32 128)
%10 = call i32 @delay_ms(i32 1)
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = call i32 @SPI_Write(i32 1, i32 %13)
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = call i32 @SPI_Write(i32 2, i32 %17)
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 @SPI_Write(i32 3, i32 %21)
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 @SPI_Write(i32 4, i32 %25)
%27 = call i32 @delay_ms(i32 1)
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = call i32 @SPI_Write(i32 9, i32 %30)
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 1
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 @SPI_Write(i32 10, i32 %34)
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 2
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 @SPI_Write(i32 11, i32 %38)
%40 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 3
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = call i32 @SPI_Write(i32 12, i32 %42)
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 4
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = call i32 @SPI_Write(i32 13, i32 %46)
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 5
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 @SPI_Write(i32 14, i32 %50)
%52 = call i32 @delay_ms(i32 1)
%53 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = call i32 @SPI_Write(i32 5, i32 %55)
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = call i32 @SPI_Write(i32 6, i32 %59)
%61 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = call i32 @SPI_Write(i32 7, i32 %63)
%65 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = call i32 @SPI_Write(i32 8, i32 %67)
%69 = call i32 @delay_ms(i32 1)
%70 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = call i32 @SPI_Write(i32 15, i32 %72)
%74 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = call i32 @SPI_Write(i32 16, i32 %76)
%78 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = call i32 @SPI_Write(i32 17, i32 %80)
%82 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = call i32 @SPI_Write(i32 18, i32 %84)
%86 = call i32 @delay_ms(i32 1)
%87 = call i32 @SPI_Write(i32 26, i32 85)
%88 = call i32 @SPI_Write(i32 27, i32 85)
ret void
}

LLVM IR (-O2):
define void @W5100_Init() {
%1 = tail call i32 @SPI_Write(i32 0, i32 128)
%2 = tail call i32 @delay_ms(i32 1)
%3 = tail call i32 @SPI_Write(i32 1, i32 192)
%4 = tail call i32 @SPI_Write(i32 2, i32 168)
%5 = tail call i32 @SPI_Write(i32 3, i32 2)
%6 = tail call i32 @SPI_Write(i32 4, i32 1)
%7 = tail call i32 @delay_ms(i32 1)
%8 = tail call i32 @SPI_Write(i32 9, i32 0)
%9 = tail call i32 @SPI_Write(i32 10, i32 22)
%10 = tail call i32 @SPI_Write(i32 11, i32 54)
%11 = tail call i32 @SPI_Write(i32 12, i32 222)
%12 = tail call i32 @SPI_Write(i32 13, i32 88)
%13 = tail call i32 @SPI_Write(i32 14, i32 246)
%14 = tail call i32 @delay_ms(i32 1)
%15 = tail call i32 @SPI_Write(i32 5, i32 255)
%16 = tail call i32 @SPI_Write(i32 6, i32 255)
%17 = tail call i32 @SPI_Write(i32 7, i32 255)
%18 = tail call i32 @SPI_Write(i32 8, i32 0)
%19 = tail call i32 @delay_ms(i32 1)
%20 = tail call i32 @SPI_Write(i32 15, i32 192)
%21 = tail call i32 @SPI_Write(i32 16, i32 168)
%22 = tail call i32 @SPI_Write(i32 17, i32 2)
%23 = tail call i32 @SPI_Write(i32 18, i32 10)
%24 = tail call i32 @delay_ms(i32 1)
%25 = tail call i32 @SPI_Write(i32 26, i32 85)
%26 = tail call i32 @SPI_Write(i32 27, i32 85)
ret void
}