#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 uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ I2C_SLAVE;
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int write(int, int *, int);
void pwmPulse(int fh, uint8_t num, uint16_t on, uint16_t off) {
  uint8_t pulseData[5];
  pulseData[0] = 0x6 + 4 * num;
  pulseData[1] = on;
  pulseData[2] = on >> 8;
  pulseData[3] = off;
  pulseData[4] = off >> 8;
  if (ioctl(fh, I2C_SLAVE, 0x40) < 0)
    printf("ERROR in pwmPulse: ioctl\n");
  if (write(fh, pulseData, 5) != 5)
    printf("ERROR in pwmPulse: write\n");
}


x86 assembly (clang, -O0):
<pwmPulse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
add    $0x6,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    119a <pwmPulse+0x6a>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
cmp    $0x5,%eax
je     11c0 <pwmPulse+0x90>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwmPulse>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
lea    0x6(,%rsi,4),%eax
mov    %eax,(%rsp)
mov    %edx,0x4(%rsp)
sar    $0x8,%edx
mov    %edx,0x8(%rsp)
mov    %ecx,0xc(%rsp)
sar    $0x8,%ecx
mov    %ecx,0x10(%rsp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edx
call   1050 <ioctl@plt>
test   %rax,%rax
jns    117b <pwmPulse+0x4b>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x5,%edx
call   1040 <write@plt>
cmp    $0x5,%eax
jne    1195 <pwmPulse+0x65>
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe64(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@I2C_SLAVE = global i32 0
@.str = [26 x i8] c"ERROR in pwmPulse: ioctl\0A\00"
@.str.1 = [26 x i8] c"ERROR in pwmPulse: write\0A\00"
define void @pwmPulse(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [5 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = mul nsw i32 4, %10
%12 = add nsw i32 6, %11
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
store i32 %12, i32* %13
%14 = load i32, i32* %7
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 1
store i32 %14, i32* %15
%16 = load i32, i32* %7
%17 = ashr i32 %16, 8
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 2
store i32 %17, i32* %18
%19 = load i32, i32* %8
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 3
store i32 %19, i32* %20
%21 = load i32, i32* %8
%22 = ashr i32 %21, 8
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 4
store i32 %22, i32* %23
%24 = load i32, i32* %5
%25 = load i32, i32* @I2C_SLAVE
%26 = call i64 @ioctl(i32 %24, i32 %25, i32 64)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %4
%29 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %4
%31 = load i32, i32* %5
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
%33 = call i32 @write(i32 %31, i32* %32, i32 5)
%34 = icmp ne i32 %33, 5
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
ret void
}

LLVM IR (-O2):
@I2C_SLAVE = global i32 0
@str = [25 x i8] c"ERROR in pwmPulse: write\00"
@str.2 = [25 x i8] c"ERROR in pwmPulse: ioctl\00"
define void @pwmPulse(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [5 x i32]
%6 = bitcast [5 x i32]* %5 to i8*
%7 = shl nsw i32 %1, 2
%8 = add nsw i32 %7, 6
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
store i32 %8, i32* %9
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
store i32 %2, i32* %10
%11 = ashr i32 %2, 8
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
store i32 %11, i32* %12
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
store i32 %3, i32* %13
%14 = ashr i32 %3, 8
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 4
store i32 %14, i32* %15
%16 = load i32, i32* @I2C_SLAVE
%17 = tail call i64 @ioctl(i32 %0, i32 %16, i32 64)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = call i32 @write(i32 %0, i32* %9, i32 5)
%23 = icmp eq i32 %22, 5
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
ret void
}