#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*/ I2C_SLAVE;
int /*<<< orphan*/ O_RDWR;
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int write(int, int *, int);
main() {
  int fh = open("/dev/i2c-3", O_RDWR);
  if (ioctl(fh, I2C_SLAVE, 0x0) < 0) {
    printf("ERROR in reset: ioctl\n");
  }
  int reset = 0x06;
  if (write(fh, &reset, 1) != 1) {
    printf("ERROR in reset: write\n");
  } else
    printf("Adafruit board reset. Thank you.\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1190 <main+0x50>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
movl   $0x6,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     11c2 <main+0x82>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
jmp    11ce <main+0x8e>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0xeab(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
test   %rax,%rax
jns    117f <main+0x3f>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x6,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
lea    0xe69(%rip),%rax
lea    0xe83(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-3\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
@.str.1 = [23 x i8] c"ERROR in reset: ioctl\0A\00"
@.str.2 = [23 x i8] c"ERROR in reset: write\0A\00"
@.str.3 = [34 x i8] c"Adafruit board reset. Thank you.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* @I2C_SLAVE
%8 = call i64 @ioctl(i32 %6, i32 %7, i32 0)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
store i32 6, i32* %3
%13 = load i32, i32* %2
%14 = call i32 @write(i32 %13, i32* %3, i32 1)
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-3\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
@str = [33 x i8] c"Adafruit board reset. Thank you.\00"
@str.4 = [22 x i8] c"ERROR in reset: write\00"
@str.5 = [22 x i8] c"ERROR in reset: ioctl\00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i32, i32* @I2C_SLAVE
%5 = tail call i64 @ioctl(i32 %3, i32 %4, i32 0)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = bitcast i32* %1 to i8*
store i32 6, i32* %1
%11 = call i32 @write(i32 %3, i32* %1, i32 1)
%12 = icmp eq i32 %11, 1
%13 = select i1 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
ret i32 0
}