#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*/ O_RDWR;
int /*<<< orphan*/ _direction(int, char *);
int /*<<< orphan*/ _export(int);
int _open_value(int, int /*<<< orphan*/);
int /*<<< orphan*/ _unexport(int);
int /*<<< orphan*/ _write_value(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ usleep(int);
void gpio_pin_pulse(int pin, int msec, int active_value) {
  int fd;
  _export(pin);
  _direction(pin, "out");
  fd = _open_value(pin, O_RDWR);
  _write_value(fd, active_value);
  usleep(msec * 1000);
  _write_value(fd, !active_value);
  close(fd);
  _unexport(pin);
}


x86 assembly (clang, -O0):
<gpio_pin_pulse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <_export@plt>
mov    -0x4(%rbp),%edi
lea    0xe6d(%rip),%rsi
call   1080 <_direction@plt>
mov    -0x4(%rbp),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
call   1070 <_open_value@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <_write_value@plt>
imul   $0x3e8,-0x8(%rbp),%edi
call   1090 <usleep@plt>
mov    -0x10(%rbp),%edi
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1060 <_write_value@plt>
mov    -0x10(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%edi
call   1030 <_unexport@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_pin_pulse>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebx
call   1050 <_export@plt>
lea    0xe75(%rip),%rsi
mov    %ebx,%edi
call   1080 <_direction@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1070 <_open_value@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15d,%esi
call   1060 <_write_value@plt>
imul   $0x3e8,%r14d,%edi
call   1090 <usleep@plt>
xor    %esi,%esi
test   %r15d,%r15d
sete   %sil
mov    %ebp,%edi
call   1060 <_write_value@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_unexport@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"out\00"
@O_RDWR = global i32 0
define void @gpio_pin_pulse(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = call i32 @_export(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @_direction(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = load i32, i32* @O_RDWR
%14 = call i32 @_open_value(i32 %12, i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = call i32 @_write_value(i32 %15, i32 %16)
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 1000
%20 = call i32 @usleep(i32 %19)
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
%26 = call i32 @_write_value(i32 %21, i32 %25)
%27 = load i32, i32* %7
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %4
%30 = call i32 @_unexport(i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"out\00"
@O_RDWR = global i32 0
define void @gpio_pin_pulse(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @_export(i32 %0)
%5 = tail call i32 @_direction(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @O_RDWR
%7 = tail call i32 @_open_value(i32 %0, i32 %6)
%8 = tail call i32 @_write_value(i32 %7, i32 %2)
%9 = mul nsw i32 %1, 1000
%10 = tail call i32 @usleep(i32 %9)
%11 = icmp eq i32 %2, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @_write_value(i32 %7, i32 %12)
%14 = tail call i32 @close(i32 %7)
%15 = tail call i32 @_unexport(i32 %0)
ret void
}