#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*/ delay_ms(int);
int /*<<< orphan*/ gpio_export(int);
int /*<<< orphan*/ gpio_set_dir(int, int);
int /*<<< orphan*/ gpio_set_value(int, int);
int /*<<< orphan*/ gpio_unexport(int);
int bsllib_seq_do_gpio(int rts, int dtr, const char *seq) {
  gpio_export(rts);
  gpio_set_dir(rts, 1);
  gpio_export(dtr);
  gpio_set_dir(dtr, 1);
  while (*seq && *seq != ':') {
    const char c = *(seq++);
    switch (c) {
    case 'R':
      gpio_set_value(rts, 0);
      break;
    case 'r':
      gpio_set_value(rts, 1);
      break;
    case 'D':
      gpio_set_value(dtr, 0);
      break;
    case 'd':
      gpio_set_value(dtr, 1);
      break;
    case ',':
      delay_ms(50);
      break;
    }
  }
  gpio_unexport(rts);
  gpio_unexport(dtr);
  delay_ms(50);
  return 0;
}


x86 assembly (clang, -O0):
<bsllib_seq_do_gpio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <gpio_export@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <gpio_set_dir@plt>
mov    -0x8(%rbp),%edi
call   1040 <gpio_export@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <gpio_set_dir@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     11b1 <bsllib_seq_do_gpio+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11c1 <bsllib_seq_do_gpio+0x71>
jmp    127f <bsllib_seq_do_gpio+0x12f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2c,%eax
je     1270 <bsllib_seq_do_gpio+0x120>
jmp    11ea <bsllib_seq_do_gpio+0x9a>
mov    -0x18(%rbp),%eax
sub    $0x44,%eax
je     124f <bsllib_seq_do_gpio+0xff>
jmp    11fb <bsllib_seq_do_gpio+0xab>
mov    -0x18(%rbp),%eax
sub    $0x52,%eax
je     122e <bsllib_seq_do_gpio+0xde>
jmp    120c <bsllib_seq_do_gpio+0xbc>
mov    -0x18(%rbp),%eax
sub    $0x64,%eax
je     125e <bsllib_seq_do_gpio+0x10e>
jmp    121d <bsllib_seq_do_gpio+0xcd>
mov    -0x18(%rbp),%eax
sub    $0x72,%eax
je     123d <bsllib_seq_do_gpio+0xed>
jmp    127a <bsllib_seq_do_gpio+0x12a>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
jmp    127a <bsllib_seq_do_gpio+0x12a>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
jmp    127a <bsllib_seq_do_gpio+0x12a>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
jmp    127a <bsllib_seq_do_gpio+0x12a>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
jmp    127a <bsllib_seq_do_gpio+0x12a>
mov    $0x32,%edi
call   1070 <delay_ms@plt>
jmp    118c <bsllib_seq_do_gpio+0x3c>
mov    -0x4(%rbp),%edi
call   1050 <gpio_unexport@plt>
mov    -0x8(%rbp),%edi
call   1050 <gpio_unexport@plt>
mov    $0x32,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bsllib_seq_do_gpio>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
call   1040 <gpio_export@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <gpio_set_dir@plt>
mov    %r14d,%edi
call   1040 <gpio_export@plt>
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <gpio_set_dir@plt>
jmp    1190 <bsllib_seq_do_gpio+0x40>
mov    %ebp,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
movsbl (%rbx),%eax
test   %eax,%eax
je     11e7 <bsllib_seq_do_gpio+0x97>
cmp    $0x3a,%al
je     11e7 <bsllib_seq_do_gpio+0x97>
add    $0x1,%rbx
cmp    $0x51,%eax
jle    11c0 <bsllib_seq_do_gpio+0x70>
cmp    $0x72,%eax
je     1184 <bsllib_seq_do_gpio+0x34>
cmp    $0x64,%eax
je     11d6 <bsllib_seq_do_gpio+0x86>
cmp    $0x52,%eax
jne    1190 <bsllib_seq_do_gpio+0x40>
mov    %ebp,%edi
jmp    11cd <bsllib_seq_do_gpio+0x7d>
nopw   0x0(%rax,%rax,1)
cmp    $0x2c,%eax
je     11db <bsllib_seq_do_gpio+0x8b>
cmp    $0x44,%eax
jne    1190 <bsllib_seq_do_gpio+0x40>
mov    %r14d,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
jmp    1190 <bsllib_seq_do_gpio+0x40>
mov    %r14d,%edi
jmp    1186 <bsllib_seq_do_gpio+0x36>
mov    $0x32,%edi
call   1070 <delay_ms@plt>
jmp    1190 <bsllib_seq_do_gpio+0x40>
mov    %ebp,%edi
call   1050 <gpio_unexport@plt>
mov    %r14d,%edi
call   1050 <gpio_unexport@plt>
mov    $0x32,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @bsllib_seq_do_gpio(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = call i32 @gpio_export(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @gpio_set_dir(i32 %10, i32 1)
%12 = load i32, i32* %5
%13 = call i32 @gpio_export(i32 %12)
%14 = load i32, i32* %5
%15 = call i32 @gpio_set_dir(i32 %14, i32 1)
br label %16
16: ; preds = %48, %3
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 58
br label %26
26: ; preds = %21, %16
%27 = phi i1 [ false, %16 ], [ %25, %21 ]
br i1 %27, label %28, label %49
28: ; preds = %26
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
%31 = load i8, i8* %29
store i8 %31, i8* %7
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
switch i32 %33, label %48 [
i32 82, label %34
i32 114, label %37
i32 68, label %40
i32 100, label %43
i32 44, label %46
]
34: ; preds = %28
%35 = load i32, i32* %4
%36 = call i32 @gpio_set_value(i32 %35, i32 0)
br label %48
37: ; preds = %28
%38 = load i32, i32* %4
%39 = call i32 @gpio_set_value(i32 %38, i32 1)
br label %48
40: ; preds = %28
%41 = load i32, i32* %5
%42 = call i32 @gpio_set_value(i32 %41, i32 0)
br label %48
43: ; preds = %28
%44 = load i32, i32* %5
%45 = call i32 @gpio_set_value(i32 %44, i32 1)
br label %48
46: ; preds = %28
%47 = call i32 @delay_ms(i32 50)
br label %48
48: ; preds = %28, %46, %43, %40, %37, %34
br label %16
49: ; preds = %26
%50 = load i32, i32* %4
%51 = call i32 @gpio_unexport(i32 %50)
%52 = load i32, i32* %5
%53 = call i32 @gpio_unexport(i32 %52)
%54 = call i32 @delay_ms(i32 50)
ret i32 0
}

LLVM IR (-O2):
define i32 @bsllib_seq_do_gpio(i32 %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32 @gpio_export(i32 %0)
%5 = tail call i32 @gpio_set_dir(i32 %0, i32 1)
%6 = tail call i32 @gpio_export(i32 %1)
%7 = tail call i32 @gpio_set_dir(i32 %1, i32 1)
br label %8
8: ; preds = %14, %3
%9 = phi i8* [ %2, %3 ], [ %13, %14 ]
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 0, label %25
i8 58, label %25
]
11: ; preds = %8
%12 = sext i8 %10 to i32
%13 = getelementptr inbounds i8, i8* %9, i64 1
switch i32 %12, label %14 [
i32 82, label %15
i32 114, label %17
i32 68, label %19
i32 100, label %21
i32 44, label %23
]
14: ; preds = %11, %23, %21, %19, %17, %15
br label %8
15: ; preds = %11
%16 = tail call i32 @gpio_set_value(i32 %0, i32 0)
br label %14
17: ; preds = %11
%18 = tail call i32 @gpio_set_value(i32 %0, i32 1)
br label %14
19: ; preds = %11
%20 = tail call i32 @gpio_set_value(i32 %1, i32 0)
br label %14
21: ; preds = %11
%22 = tail call i32 @gpio_set_value(i32 %1, i32 1)
br label %14
23: ; preds = %11
%24 = tail call i32 @delay_ms(i32 50)
br label %14
25: ; preds = %8, %8
%26 = tail call i32 @gpio_unexport(i32 %0)
%27 = tail call i32 @gpio_unexport(i32 %1)
%28 = tail call i32 @delay_ms(i32 50)
ret i32 0
}