#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 timespec {
  unsigned int member_1;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int lspcon_i2c_spi_write_register(int, int, int);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int lspcon_i2c_clt2_spi_reset(int fd) {
  int ret = 0;
  ret |= lspcon_i2c_spi_write_register(fd, 0x82, 0x20);
  struct timespec wait_100ms = {0, (unsigned)1e8};
  nanosleep(&wait_100ms, NULL);
  ret |= lspcon_i2c_spi_write_register(fd, 0x82, 0x00);
  return ret;
}


x86 assembly (clang, -O0):
<lspcon_i2c_clt2_spi_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x82,%esi
mov    $0x20,%edx
call   1040 <lspcon_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <nanosleep@plt>
mov    -0x4(%rbp),%edi
mov    $0x82,%esi
xor    %edx,%edx
call   1040 <lspcon_i2c_spi_write_register@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lspcon_i2c_clt2_spi_reset>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x82,%esi
mov    $0x20,%edx
call   1040 <lspcon_i2c_spi_write_register@plt>
mov    %eax,%ebp
movabs $0x5f5e10000000000,%rax
e1 f5 05
mov    %rax,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <nanosleep@plt>
mov    %ebx,%edi
mov    $0x82,%esi
xor    %edx,%edx
call   1040 <lspcon_i2c_spi_write_register@plt>
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@__const.lspcon_i2c_clt2_spi_reset.wait_100ms = %struct.timespec { i32 0, i32 100000000 }
define i32 @lspcon_i2c_clt2_spi_reset(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.timespec
store i32 %0, i32* %2
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = call i32 @lspcon_i2c_spi_write_register(i32 %5, i32 130, i32 32)
%7 = load i32, i32* %3
%8 = or i32 %7, %6
store i32 %8, i32* %3
%9 = bitcast %struct.timespec* %4 to i8*
%10 = call i32 @nanosleep(%struct.timespec* %4, i32* null)
%11 = load i32, i32* %2
%12 = call i32 @lspcon_i2c_spi_write_register(i32 %11, i32 130, i32 0)
%13 = load i32, i32* %3
%14 = or i32 %13, %12
store i32 %14, i32* %3
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define i32 @lspcon_i2c_clt2_spi_reset(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to %struct.timespec*
%4 = tail call i32 @lspcon_i2c_spi_write_register(i32 %0, i32 130, i32 32)
%5 = bitcast i64* %2 to i8*
store i64 429496729600000000, i64* %2
%6 = call i32 @nanosleep(%struct.timespec* %3, i32* null)
%7 = call i32 @lspcon_i2c_spi_write_register(i32 %0, i32 130, i32 0)
%8 = or i32 %7, %4
ret i32 %8
}