#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 */
typedef int /*<<< orphan*/ str_gpio;

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int snprintf(char *, int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int mcp23s17_disable_interrupts() {
  int fd, len;
  char str_gpio[3];
  if ((fd = open("/sys/class/gpio/unexport", O_WRONLY)) < 0)
    return -1;
  len = snprintf(str_gpio, sizeof(str_gpio), "%d", 25);
  write(fd, str_gpio, len);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<mcp23s17_disable_interrupts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1175 <mcp23s17_disable_interrupts+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <mcp23s17_disable_interrupts+0x70>
lea    -0xf(%rbp),%rdi
mov    $0x3,%esi
lea    0xe94(%rip),%rdx
mov    $0x19,%ecx
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xf(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcp23s17_disable_interrupts>:
push   %r14
push   %rbx
push   %rax
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     1194 <mcp23s17_disable_interrupts+0x54>
mov    %eax,%ebx
lea    0xeb3(%rip),%rdx
lea    0x5(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x19,%ecx
call   1040 <snprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
jmp    1199 <mcp23s17_disable_interrupts+0x59>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/sys/class/gpio/unexport\00"
@O_WRONLY = global i32 0
@.str.1 = [3 x i8] c"%d\00"
define i32 @mcp23s17_disable_interrupts() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = load i32, i32* @O_WRONLY
%6 = call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %18
9: ; preds = %0
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = call i32 @snprintf(i8* %10, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 25)
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 @write(i32 %12, i8* %13, i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @close(i32 %16)
store i32 0, i32* %1
br label %18
18: ; preds = %9, %8
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [25 x i8] c"/sys/class/gpio/unexport\00"
@O_WRONLY = global i32 0
@.str.1 = [3 x i8] c"%d\00"
define i32 @mcp23s17_disable_interrupts() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = call i32 @snprintf(i8* %2, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 25)
%8 = call i32 @write(i32 %4, i8* %2, i32 %7)
%9 = call i32 @close(i32 %4)
br label %10
10: ; preds = %0, %6
%11 = phi i32 [ 0, %6 ], [ -1, %0 ]
ret i32 %11
}