#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*/ rcs_destroy(void *);
int /*<<< orphan*/ rcs_enable_transmit(void *, int /*<<< orphan*/);
void *rcs_init_a(char *, char *);
int /*<<< orphan*/ rcs_switch_off(void *);
int /*<<< orphan*/ rcs_switch_on(void *);
int /*<<< orphan*/ sleep(int);
int main() {
  void *s = rcs_init_a("11001", "01010");
  rcs_enable_transmit(s, 0);
  int i;
  for (i = 0; i < 4; i++) {
    if (i % 2 == 0) {
      rcs_switch_on(s);
    } else {
      rcs_switch_off(s);
    }
    sleep(2);
  }
  rcs_destroy(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1030 <rcs_init_a@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1060 <rcs_enable_transmit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11e5 <main+0x85>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c4 <main+0x64>
mov    -0x10(%rbp),%rdi
call   1040 <rcs_switch_on@plt>
jmp    11cd <main+0x6d>
mov    -0x10(%rbp),%rdi
call   1070 <rcs_switch_off@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1198 <main+0x38>
mov    -0x10(%rbp),%rdi
call   1050 <rcs_destroy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1030 <rcs_init_a@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1060 <rcs_enable_transmit@plt>
mov    %rbx,%rdi
call   1040 <rcs_switch_on@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
call   1070 <rcs_switch_off@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
call   1040 <rcs_switch_on@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
call   1070 <rcs_switch_off@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
call   1050 <rcs_destroy@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"11001\00"
@.str.1 = [6 x i8] c"01010\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @rcs_init_a(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @rcs_enable_transmit(i8* %5, i32 0)
store i32 0, i32* %3
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %3
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i32 @rcs_switch_on(i8* %15)
br label %20
17: ; preds = %10
%18 = load i8*, i8** %2
%19 = call i32 @rcs_switch_off(i8* %18)
br label %20
20: ; preds = %17, %14
%21 = call i32 @sleep(i32 2)
br label %22
22: ; preds = %20
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %7
%26 = load i8*, i8** %2
%27 = call i32 @rcs_destroy(i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"11001\00"
@.str.1 = [6 x i8] c"01010\00"
define i32 @main() {
%1 = tail call i8* @rcs_init_a(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @rcs_enable_transmit(i8* %1, i32 0)
%3 = tail call i32 @rcs_switch_on(i8* %1)
%4 = tail call i32 @sleep(i32 2)
%5 = tail call i32 @rcs_switch_off(i8* %1)
%6 = tail call i32 @sleep(i32 2)
%7 = tail call i32 @rcs_switch_on(i8* %1)
%8 = tail call i32 @sleep(i32 2)
%9 = tail call i32 @rcs_switch_off(i8* %1)
%10 = tail call i32 @sleep(i32 2)
%11 = tail call i32 @rcs_destroy(i8* %1)
ret i32 0
}