#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_c(char, int, int);
int /*<<< orphan*/ rcs_switch_off(void *);
int /*<<< orphan*/ rcs_switch_on(void *);
int /*<<< orphan*/ sleep(int);
int main() {
  void *s = rcs_init_c('b', 3, 2);
  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)
mov    $0x62,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <rcs_init_c@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    11e6 <main+0x86>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c5 <main+0x65>
mov    -0x10(%rbp),%rdi
call   1040 <rcs_switch_on@plt>
jmp    11ce <main+0x6e>
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    1199 <main+0x39>
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
mov    $0x62,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <rcs_init_c@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):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @rcs_init_c(i8 signext 98, i32 3, i32 2)
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):
define i32 @main() {
%1 = tail call i8* @rcs_init_c(i8 signext 98, i32 3, i32 2)
%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
}