#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 led_clear();
int led_op(int, int);
int spi_open();
int led_init() {
  int status;
  status = spi_open();
  if (status < 0)
    return -1;
  status = led_op(15, 0);
  if (status < 0)
    return -1;
  status = led_op(11, 7);
  if (status < 0)
    return -1;
  status = led_op(10, 31 / 4);
  if (status < 0)
    return -1;
  status = led_op(9, 0);
  if (status < 0)
    return -1;
  status = led_clear();
  if (status < 0)
    return -1;
  status = led_op(12, 1);
  if (status < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<led_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <spi_open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1158 <led_init+0x28>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0xf,%edi
xor    %esi,%esi
call   1030 <led_op@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    117d <led_init+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0xb,%edi
mov    $0x7,%esi
call   1030 <led_op@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11a5 <led_init+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0xa,%edi
mov    $0x7,%esi
call   1030 <led_op@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11cd <led_init+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <led_op@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11f2 <led_init+0xc2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0x0,%al
call   1040 <led_clear@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1212 <led_init+0xe2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
mov    $0xc,%edi
mov    $0x1,%esi
call   1030 <led_op@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    123a <led_init+0x10a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <led_init+0x111>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_init>:
push   %rbx
xor    %eax,%eax
call   1050 <spi_open@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
js     11a6 <led_init+0x76>
mov    $0xf,%edi
xor    %esi,%esi
call   1030 <led_op@plt>
test   %eax,%eax
js     11a6 <led_init+0x76>
mov    $0xb,%edi
mov    $0x7,%esi
call   1030 <led_op@plt>
test   %eax,%eax
js     11a6 <led_init+0x76>
mov    $0xa,%edi
mov    $0x7,%esi
call   1030 <led_op@plt>
test   %eax,%eax
js     11a6 <led_init+0x76>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <led_op@plt>
test   %eax,%eax
js     11a6 <led_init+0x76>
xor    %eax,%eax
call   1040 <led_clear@plt>
test   %eax,%eax
js     11a6 <led_init+0x76>
mov    $0xc,%edi
mov    $0x1,%esi
call   1030 <led_op@plt>
mov    %eax,%ebx
sar    $0x1f,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @led_init() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @spi_open()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 -1, i32* %1
br label %38
7: ; preds = %0
%8 = call i32 @led_op(i32 15, i32 0)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 -1, i32* %1
br label %38
12: ; preds = %7
%13 = call i32 @led_op(i32 11, i32 7)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %1
br label %38
17: ; preds = %12
%18 = call i32 @led_op(i32 10, i32 7)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 -1, i32* %1
br label %38
22: ; preds = %17
%23 = call i32 @led_op(i32 9, i32 0)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 -1, i32* %1
br label %38
27: ; preds = %22
%28 = call i32 (...) @led_clear()
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %1
br label %38
32: ; preds = %27
%33 = call i32 @led_op(i32 12, i32 1)
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 -1, i32* %1
br label %38
37: ; preds = %32
store i32 0, i32* %1
br label %38
38: ; preds = %37, %36, %31, %26, %21, %16, %11, %6
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
define i32 @led_init() {
%1 = tail call i32 (...) @spi_open()
%2 = icmp slt i32 %1, 0
br i1 %2, label %21, label %3
3: ; preds = %0
%4 = tail call i32 @led_op(i32 15, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i32 @led_op(i32 11, i32 7)
%8 = icmp slt i32 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6
%10 = tail call i32 @led_op(i32 10, i32 7)
%11 = icmp slt i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %9
%13 = tail call i32 @led_op(i32 9, i32 0)
%14 = icmp slt i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = tail call i32 (...) @led_clear()
%17 = icmp slt i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = tail call i32 @led_op(i32 12, i32 1)
%20 = ashr i32 %19, 31
br label %21
21: ; preds = %18, %15, %12, %9, %6, %3, %0
%22 = phi i32 [ -1, %0 ], [ -1, %3 ], [ -1, %6 ], [ -1, %9 ], [ -1, %12 ], [ -1, %15 ], [ %20, %18 ]
ret i32 %22
}