#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int i2c_open_slave(int);
scalar_t__ i2c_smbus_write_byte_data(int, scalar_t__, scalar_t__);
int /*<<< orphan*/ printf(char *);
void ledc_led_setpwm(int slaveaddr, uint8_t lednumber, uint8_t value) {
  int i2c_fd;
  i2c_fd = i2c_open_slave(slaveaddr);
  if (i2c_smbus_write_byte_data(i2c_fd, 0x02 + lednumber - 1, value) < 0) {
    printf("Error: ledc_led_setpwm failed!\n");
  }
  close(i2c_fd);
}


x86 assembly (clang, -O0):
<ledc_led_setpwm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <i2c_open_slave@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
sub    $0x1,%rsi
mov    -0x18(%rbp),%rdx
call   1050 <i2c_smbus_write_byte_data@plt>
cmp    $0x0,%rax
jge    118c <ledc_led_setpwm+0x4c>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ledc_led_setpwm>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
call   1060 <i2c_open_slave@plt>
mov    %eax,%ebp
add    $0x1,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <i2c_smbus_write_byte_data@plt>
test   %rax,%rax
jns    1173 <ledc_led_setpwm+0x33>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <close@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Error: ledc_led_setpwm failed!\0A\00"
define void @ledc_led_setpwm(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = call i32 @i2c_open_slave(i32 %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = load i64, i64* %5
%12 = add nsw i64 2, %11
%13 = sub nsw i64 %12, 1
%14 = load i64, i64* %6
%15 = call i64 @i2c_smbus_write_byte_data(i32 %10, i64 %13, i64 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %3
%20 = load i32, i32* %7
%21 = call i32 @close(i32 %20)
ret void
}

LLVM IR (-O2):
@str = [31 x i8] c"Error: ledc_led_setpwm failed!\00"
define void @ledc_led_setpwm(i32 %0, i64 %1, i64 %2) {
%4 = tail call i32 @i2c_open_slave(i32 %0)
%5 = add nsw i64 %1, 1
%6 = tail call i64 @i2c_smbus_write_byte_data(i32 %4, i64 %5, i64 %2)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
%11 = tail call i32 @close(i32 %4)
ret void
}