#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 */
struct spi_ioc_transfer {
  unsigned long tx_buf;
  unsigned long rx_buf;
  int delay_usecs;
  int len;
  int /*<<< orphan*/ speed_hz;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
typedef int /*<<< orphan*/ __u8;

/* Variables and functions */
int MIN(int /*<<< orphan*/, int);
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SPI_IOC_MESSAGE(int);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt_long(int, char **, char *, struct option *, int *);
int ioctl(int, int /*<<< orphan*/, struct spi_ioc_transfer *);
#define no_argument 129
int open(char *, int /*<<< orphan*/);
char *optarg;
int /*<<< orphan*/ print_spi_transaction(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *, int);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
#define required_argument 128
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ string2hex(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  __u8 miso[64];
  __u8 mosi[64];
  struct spi_ioc_transfer tr = {
      .tx_buf = (unsigned long)mosi,
      .rx_buf = (unsigned long)miso,
      .delay_usecs = 1,
      .len = 1,
  };
  char *device_name = NULL;
  char *mosi_str = "FF";
  int opt_i = 0;
  int c;
  int fd;
  int ret;
  static struct option long_opts[] = {
      {"device", required_argument, 0, 'd'},
      {"length", required_argument, 0, 'l'},
      {"mosi", required_argument, 0, 'm'},
      {"speed", required_argument, 0, 's'},
      {"help", no_argument, 0, '?'},
      {0, 0, 0, 0},
  };
  while ((c = getopt_long(argc, argv, "d:l:m:s:?", long_opts, &opt_i)) != -1) {
    switch (c) {
    case 'd':
      device_name = optarg;
      break;
    case 'l':
      tr.len = MIN(atoi(optarg), 64);
      break;
    case 'm':
      mosi_str = optarg;
      break;
    case 's':
      tr.speed_hz = atoi(optarg);
      break;
    case '?':
      print_usage();
      return 0;
    }
  }
  if (!device_name) {
    fprintf(stderr, "Missing required device argument.\n");
    print_usage();
    return -1;
  }
  fd = open(device_name, O_RDWR);
  if (fd == -1) {
    fprintf(stderr, "main: opening device file: %s: %s\n", device_name,
            strerror(errno));
    return -1;
  }
  string2hex(mosi_str, mosi, tr.len);
  printf("Sending to %s at %ld Hz\n", device_name, tr.speed_hz);
  ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
  if (ret == -1)
    fprintf(stderr, "main: ioctl SPI_IOC_MESSAGE: %s: %s\n", device_name,
            strerror(errno));
  else
    print_spi_transaction(miso, mosi, tr.len);
  close(fd);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x230(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x228(%rbp)
movl   $0x1,-0x220(%rbp)
movl   $0x1,-0x21c(%rbp)
movl   $0x0,-0x218(%rbp)
movq   $0x0,-0x238(%rbp)
lea    0xdcb(%rip),%rax
mov    %rax,-0x240(%rbp)
movl   $0x0,-0x244(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdcd(%rip),%rdx
lea    0x2e35(%rip),%rcx
lea    -0x244(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x248(%rbp)
cmp    $0xffffffff,%eax
je     1364 <main+0x194>
mov    -0x248(%rbp),%eax
mov    %eax,-0x254(%rbp)
sub    $0x3f,%eax
je     134c <main+0x17c>
jmp    1290 <main+0xc0>
mov    -0x254(%rbp),%eax
sub    $0x64,%eax
je     12e0 <main+0x110>
jmp    12a4 <main+0xd4>
mov    -0x254(%rbp),%eax
sub    $0x6c,%eax
je     12f6 <main+0x126>
jmp    12b8 <main+0xe8>
mov    -0x254(%rbp),%eax
sub    $0x6d,%eax
je     131c <main+0x14c>
jmp    12cc <main+0xfc>
mov    -0x254(%rbp),%eax
sub    $0x73,%eax
je     1332 <main+0x162>
jmp    135f <main+0x18f>
mov    0x2d11(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x238(%rbp)
jmp    135f <main+0x18f>
mov    0x2cfb(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
mov    $0x40,%esi
call   1030 <MIN@plt>
mov    %eax,-0x21c(%rbp)
jmp    135f <main+0x18f>
mov    0x2cd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x240(%rbp)
jmp    135f <main+0x18f>
mov    0x2cbf(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x218(%rbp)
jmp    135f <main+0x18f>
mov    $0x0,%al
call   10e0 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1503 <main+0x333>
jmp    1246 <main+0x76>
cmpq   $0x0,-0x238(%rbp)
jne    139c <main+0x1cc>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xca9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   10e0 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1503 <main+0x333>
mov    -0x238(%rbp),%rdi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x24c(%rbp)
cmpl   $0xffffffff,-0x24c(%rbp)
jne    1419 <main+0x249>
mov    0x2c05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x264(%rbp)
mov    -0x238(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    0x2be0(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x264(%rbp),%edi
mov    -0x260(%rbp),%rdx
mov    %rax,%rcx
lea    0xc48(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1503 <main+0x333>
mov    -0x240(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    -0x21c(%rbp),%edx
call   10b0 <string2hex@plt>
mov    -0x238(%rbp),%rsi
mov    -0x218(%rbp),%edx
lea    0xc2b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24c(%rbp),%eax
mov    %eax,-0x268(%rbp)
mov    $0x1,%edi
call   1060 <SPI_IOC_MESSAGE@plt>
mov    -0x268(%rbp),%edi
mov    %eax,%esi
lea    -0x230(%rbp),%rdx
call   1070 <ioctl@plt>
mov    %eax,-0x250(%rbp)
cmpl   $0xffffffff,-0x250(%rbp)
jne    14d6 <main+0x306>
mov    0x2b41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x274(%rbp)
mov    -0x238(%rbp),%rax
mov    %rax,-0x270(%rbp)
mov    0x2b1c(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x274(%rbp),%edi
mov    -0x270(%rbp),%rdx
mov    %rax,%rcx
lea    0xbc0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    14ef <main+0x31f>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    -0x21c(%rbp),%edx
call   1090 <print_spi_transaction@plt>
mov    -0x24c(%rbp),%edi
call   1080 <close@plt>
mov    -0x250(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x248,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x40(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x140(%rsp),%rax
mov    %rax,0x28(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x30(%rsp)
movl   $0x0,0x38(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe1d(%rip),%rax
mov    %rax,0x8(%rsp)
movl   $0x1,(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    0xe24(%rip),%r15
lea    0x2e4c(%rip),%r14
lea    0x4(%rsp),%r12
lea    0xdb0(%rip),%r13
xor    %eax,%eax
mov    %rax,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12,%r8
call   1040 <getopt_long@plt>
lea    -0x64(%rax),%ecx
cmp    $0xf,%ecx
ja     12b0 <main+0xe0>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0x2d6c(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
mov    $0x40,%esi
call   1030 <MIN@plt>
mov    %eax,(%rsp)
mov    %eax,0x34(%rsp)
jmp    1260 <main+0x90>
nopl   0x0(%rax)
cmp    $0xffffffff,%eax
je     12ff <main+0x12f>
cmp    $0x3f,%eax
jne    1260 <main+0x90>
jmp    138f <main+0x1bf>
mov    0x2d32(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
jmp    1260 <main+0x90>
mov    0x2d21(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %rax,0x10(%rsp)
mov    %eax,0x38(%rsp)
jmp    1260 <main+0x90>
nopl   (%rax)
mov    0x2d01(%rip),%rax
mov    (%rax),%rax
jmp    1252 <main+0x82>
mov    0x18(%rsp),%rbx
test   %rbx,%rbx
je     139d <main+0x1cd>
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     13c2 <main+0x1f2>
mov    %eax,%r15d
lea    0x40(%rsp),%rsi
mov    0x8(%rsp),%rdi
mov    (%rsp),%edx
call   10b0 <string2hex@plt>
lea    0xd6e(%rip),%rdi
mov    %rbx,%rsi
mov    0x10(%rsp),%rdx
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <SPI_IOC_MESSAGE@plt>
lea    0x20(%rsp),%rdx
mov    %r15d,%edi
mov    %eax,%esi
call   1070 <ioctl@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     13f6 <main+0x226>
mov    0x34(%rsp),%edx
lea    0x140(%rsp),%rdi
lea    0x40(%rsp),%rsi
call   1090 <print_spi_transaction@plt>
jmp    1425 <main+0x255>
xor    %ebp,%ebp
xor    %eax,%eax
call   10e0 <print_usage@plt>
jmp    142d <main+0x25d>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xcbe(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   10e0 <print_usage@plt>
mov    $0xffffffff,%ebp
jmp    142d <main+0x25d>
mov    0x2c07(%rip),%rax
mov    (%rax),%ebp
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcae(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    142d <main+0x25d>
mov    0x2bd3(%rip),%rax
mov    (%rax),%r14d
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcb5(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r15d,%edi
call   1080 <close@plt>
mov    %ebp,%eax
add    $0x248,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.spi_ioc_transfer = type { i64, i64, i32, i32, i32 }
@.str = [3 x i8] c"FF\00"
@main.long_opts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 108 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8 -127, i32 0, i32 63 }, %struct.option zeroinitializer]
@.str.1 = [7 x i8] c"device\00"
@.str.2 = [7 x i8] c"length\00"
@.str.3 = [5 x i8] c"mosi\00"
@.str.4 = [6 x i8] c"speed\00"
@.str.5 = [5 x i8] c"help\00"
@.str.6 = [10 x i8] c"d:l:m:s:?\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.7 = [35 x i8] c"Missing required device argument.\0A\00"
@O_RDWR = global i32 0
@.str.8 = [35 x i8] c"main: opening device file: %s: %s\0A\00"
@errno = global i32 0
@.str.9 = [25 x i8] c"Sending to %s at %ld Hz\0A\00"
@.str.10 = [37 x i8] c"main: ioctl SPI_IOC_MESSAGE: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i32]
%7 = alloca [64 x i32]
%8 = alloca %struct.spi_ioc_transfer
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 0
%16 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%17 = ptrtoint i32* %16 to i64
store i64 %17, i64* %15
%18 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 1
%19 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%20 = ptrtoint i32* %19 to i64
store i64 %20, i64* %18
%21 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 2
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 3
store i32 1, i32* %22
%23 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 4
store i32 0, i32* %23
store i8* null, i8** %9
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %10
store i32 0, i32* %11
br label %24
24: ; preds = %46, %2
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
%27 = call i32 @getopt_long(i32 %25, i8** %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_opts, i64 0, i64 0), i32* %11)
store i32 %27, i32* %12
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %47
29: ; preds = %24
%30 = load i32, i32* %12
switch i32 %30, label %46 [
i32 100, label %31
i32 108, label %33
i32 109, label %38
i32 115, label %40
i32 63, label %44
]
31: ; preds = %29
%32 = load i8*, i8** @optarg
store i8* %32, i8** %9
br label %46
33: ; preds = %29
%34 = load i8*, i8** @optarg
%35 = call i32 @atoi(i8* %34)
%36 = call i32 @MIN(i32 %35, i32 64)
%37 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 3
store i32 %36, i32* %37
br label %46
38: ; preds = %29
%39 = load i8*, i8** @optarg
store i8* %39, i8** %10
br label %46
40: ; preds = %29
%41 = load i8*, i8** @optarg
%42 = call i32 @atoi(i8* %41)
%43 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 4
store i32 %42, i32* %43
br label %46
44: ; preds = %29
%45 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %97
46: ; preds = %29, %40, %38, %33, %31
br label %24
47: ; preds = %24
%48 = load i8*, i8** %9
%49 = icmp ne i8* %48, null
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 (...) @print_usage()
store i32 -1, i32* %3
br label %97
54: ; preds = %47
%55 = load i8*, i8** %9
%56 = load i32, i32* @O_RDWR
%57 = call i32 @open(i8* %55, i32 %56)
store i32 %57, i32* %13
%58 = load i32, i32* %13
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %66
60: ; preds = %54
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %9
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %62, i8* %64)
store i32 -1, i32* %3
br label %97
66: ; preds = %54
%67 = load i8*, i8** %10
%68 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%69 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 3
%70 = load i32, i32* %69
%71 = call i32 @string2hex(i8* %67, i32* %68, i32 %70)
%72 = load i8*, i8** %9
%73 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 4
%74 = load i32, i32* %73
%75 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %72, i32 %74)
%76 = load i32, i32* %13
%77 = call i32 @SPI_IOC_MESSAGE(i32 1)
%78 = call i32 @ioctl(i32 %76, i32 %77, %struct.spi_ioc_transfer* %8)
store i32 %78, i32* %14
%79 = load i32, i32* %14
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %87
81: ; preds = %66
%82 = load i32, i32* @stderr
%83 = load i8*, i8** %9
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %83, i8* %85)
br label %93
87: ; preds = %66
%88 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%89 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%90 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i32 0, i32 3
%91 = load i32, i32* %90
%92 = call i32 @print_spi_transaction(i32* %88, i32* %89, i32 %91)
br label %93
93: ; preds = %87, %81
%94 = load i32, i32* %13
%95 = call i32 @close(i32 %94)
%96 = load i32, i32* %14
store i32 %96, i32* %3
br label %97
97: ; preds = %93, %60, %50, %44
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.spi_ioc_transfer = type { i64, i64, i32, i32, i32 }
@.str = [3 x i8] c"FF\00"
@main.long_opts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 108 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8 -127, i32 0, i32 63 }, %struct.option zeroinitializer]
@.str.1 = [7 x i8] c"device\00"
@.str.2 = [7 x i8] c"length\00"
@.str.3 = [5 x i8] c"mosi\00"
@.str.4 = [6 x i8] c"speed\00"
@.str.5 = [5 x i8] c"help\00"
@.str.6 = [10 x i8] c"d:l:m:s:?\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.7 = [35 x i8] c"Missing required device argument.\0A\00"
@O_RDWR = global i32 0
@.str.8 = [35 x i8] c"main: opening device file: %s: %s\0A\00"
@errno = global i32 0
@.str.9 = [25 x i8] c"Sending to %s at %ld Hz\0A\00"
@.str.10 = [37 x i8] c"main: ioctl SPI_IOC_MESSAGE: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [64 x i32]
%4 = alloca [64 x i32]
%5 = alloca %struct.spi_ioc_transfer
%6 = alloca i32
%7 = bitcast [64 x i32]* %3 to i8*
%8 = bitcast [64 x i32]* %4 to i8*
%9 = bitcast %struct.spi_ioc_transfer* %5 to i8*
%10 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 0
%11 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%12 = ptrtoint [64 x i32]* %4 to i64
store i64 %12, i64* %10
%13 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 1
%14 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%15 = ptrtoint [64 x i32]* %3 to i64
store i64 %15, i64* %13
%16 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 2
store i32 1, i32* %16
%17 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 3
store i32 1, i32* %17
%18 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 4
store i32 0, i32* %18
%19 = bitcast i32* %6 to i8*
store i32 0, i32* %6
br label %20
20: ; preds = %44, %2
%21 = phi i32 [ %46, %44 ], [ 0, %2 ]
%22 = phi i32 [ %26, %44 ], [ 1, %2 ]
%23 = phi i8* [ %30, %44 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
%24 = phi i8* [ %33, %44 ], [ null, %2 ]
br label %25
25: ; preds = %20, %38
%26 = phi i32 [ %22, %20 ], [ %41, %38 ]
%27 = phi i8* [ %23, %20 ], [ %30, %38 ]
%28 = phi i8* [ %24, %20 ], [ %33, %38 ]
br label %29
29: ; preds = %25, %42
%30 = phi i8* [ %27, %25 ], [ %43, %42 ]
%31 = phi i8* [ %28, %25 ], [ %33, %42 ]
br label %32
32: ; preds = %29, %36
%33 = phi i8* [ %31, %29 ], [ %37, %36 ]
br label %34
34: ; preds = %32, %34
%35 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_opts, i64 0, i64 0), i32* %6)
switch i32 %35, label %34 [
i32 -1, label %49
i32 100, label %36
i32 108, label %38
i32 109, label %42
i32 115, label %44
i32 63, label %47
]
36: ; preds = %34
%37 = load i8*, i8** @optarg
br label %32
38: ; preds = %34
%39 = load i8*, i8** @optarg
%40 = call i32 @atoi(i8* %39)
%41 = call i32 @MIN(i32 %40, i32 64)
store i32 %41, i32* %17
br label %25
42: ; preds = %34
%43 = load i8*, i8** @optarg
br label %29
44: ; preds = %34
%45 = load i8*, i8** @optarg
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %18
br label %20
47: ; preds = %34
%48 = call i32 (...) @print_usage()
br label %80
49: ; preds = %34
%50 = icmp eq i8* %33, null
br i1 %50, label %51, label %55
51: ; preds = %49
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 (...) @print_usage()
br label %80
55: ; preds = %49
%56 = load i32, i32* @O_RDWR
%57 = call i32 @open(i8* %33, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %33, i8* %62)
br label %80
64: ; preds = %55
%65 = call i32 @string2hex(i8* %30, i32* %11, i32 %26)
%66 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %33, i32 %21)
%67 = call i32 @SPI_IOC_MESSAGE(i32 1)
%68 = call i32 @ioctl(i32 %57, i32 %67, %struct.spi_ioc_transfer* %5)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = load i32, i32* @stderr
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %33, i8* %73)
br label %78
75: ; preds = %64
%76 = load i32, i32* %17
%77 = call i32 @print_spi_transaction(i32* %14, i32* %11, i32 %76)
br label %78
78: ; preds = %75, %70
%79 = call i32 @close(i32 %57)
br label %80
80: ; preds = %78, %59, %51, %47
%81 = phi i32 [ 0, %47 ], [ -1, %59 ], [ %68, %78 ], [ -1, %51 ]
ret i32 %81
}