#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_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int motoren = open("/dev/rtmotoren0", O_WRONLY);
  int motor_l = open("/dev/rtmotor_raw_l0", O_WRONLY);
  int motor_r = open("/dev/rtmotor_raw_r0", O_WRONLY);
  int motor = open("/dev/rtmotor0", O_WRONLY);
  printf("Motor On\n");
  write(motoren, "1", 1);
  usleep(500 * 1000);
  printf("Rotate counter-clockwise\n");
  write(motor_l, "-400", 5);
  write(motor_r, "400", 5);
  usleep(500 * 1000);
  write(motor_l, "0", 5);
  write(motor_r, "0", 5);
  usleep(500 * 1000);
  printf("Rotate clockwise\n");
  write(motor_l, "400", 5);
  write(motor_r, "-400", 5);
  usleep(500 * 1000);
  write(motor_l, "0", 5);
  write(motor_r, "0", 5);
  usleep(500 * 1000);
  printf("Rotate clockwise\n");
  write(motor, "400 -400 500", 15);
  usleep(500 * 1000);
  printf("Rotate counter-clockwise\n");
  write(motor, "-400 400 500", 15);
  printf("Motor Off\n");
  write(motoren, "0", 1);
  close(motoren);
  close(motor_l);
  close(motor_r);
  close(motor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    0xe7b(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
lea    0xe6d(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xe5a(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    -0xc(%rbp),%edi
lea    0xe3e(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xe2a(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
lea    0xdfe(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xde9(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    -0xc(%rbp),%edi
lea    0xdce(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xdba(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    0xda4(%rip),%rsi
mov    $0xf,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xd58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    0xd87(%rip),%rsi
mov    $0xf,%edx
call   1030 <write@plt>
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    0xd46(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e76(%rip),%rbx
mov    (%rbx),%esi
lea    0xe95(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
mov    %eax,(%rsp)
mov    (%rbx),%esi
lea    0xe92(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%r15d
mov    (%rbx),%esi
lea    0xe95(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%r12d
mov    (%rbx),%esi
lea    0xe98(%rip),%rdi
call   1060 <open@plt>
mov    %eax,0x4(%rsp)
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8a(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe63(%rip),%rbp
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
lea    0xe4d(%rip),%r14
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xe2e(%rip),%r13
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xe22(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xd94(%rip),%rsi
mov    0x4(%rsp),%ebx
mov    %ebx,%edi
mov    $0xf,%edx
call   1040 <write@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xda7(%rip),%rdi
call   1030 <puts@plt>
lea    0xd74(%rip),%rsi
mov    %ebx,%edi
mov    $0xf,%edx
call   1040 <write@plt>
lea    0xda1(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%ebp
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %r15d,%edi
call   1050 <close@plt>
mov    %r12d,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"/dev/rtmotoren0\00"
@O_WRONLY = global i32 0
@.str.1 = [20 x i8] c"/dev/rtmotor_raw_l0\00"
@.str.2 = [20 x i8] c"/dev/rtmotor_raw_r0\00"
@.str.3 = [14 x i8] c"/dev/rtmotor0\00"
@.str.4 = [10 x i8] c"Motor On\0A\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [26 x i8] c"Rotate counter-clockwise\0A\00"
@.str.7 = [5 x i8] c"-400\00"
@.str.8 = [4 x i8] c"400\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [18 x i8] c"Rotate clockwise\0A\00"
@.str.11 = [13 x i8] c"400 -400 500\00"
@.str.12 = [13 x i8] c"-400 400 500\00"
@.str.13 = [11 x i8] c"Motor Off\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @O_WRONLY
%7 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* @O_WRONLY
%9 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* @O_WRONLY
%11 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* @O_WRONLY
%13 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %12)
store i32 %13, i32* %5
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%17 = call i32 @usleep(i32 500000)
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 5)
%21 = load i32, i32* %4
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 5)
%23 = call i32 @usleep(i32 500000)
%24 = load i32, i32* %3
%25 = call i32 @write(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%26 = load i32, i32* %4
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%28 = call i32 @usleep(i32 500000)
%29 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%30 = load i32, i32* %3
%31 = call i32 @write(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 5)
%32 = load i32, i32* %4
%33 = call i32 @write(i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 5)
%34 = call i32 @usleep(i32 500000)
%35 = load i32, i32* %3
%36 = call i32 @write(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%37 = load i32, i32* %4
%38 = call i32 @write(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%39 = call i32 @usleep(i32 500000)
%40 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%41 = load i32, i32* %5
%42 = call i32 @write(i32 %41, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 15)
%43 = call i32 @usleep(i32 500000)
%44 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%45 = load i32, i32* %5
%46 = call i32 @write(i32 %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 15)
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%48 = load i32, i32* %2
%49 = call i32 @write(i32 %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%50 = load i32, i32* %2
%51 = call i32 @close(i32 %50)
%52 = load i32, i32* %3
%53 = call i32 @close(i32 %52)
%54 = load i32, i32* %4
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* %5
%57 = call i32 @close(i32 %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"/dev/rtmotoren0\00"
@O_WRONLY = global i32 0
@.str.1 = [20 x i8] c"/dev/rtmotor_raw_l0\00"
@.str.2 = [20 x i8] c"/dev/rtmotor_raw_r0\00"
@.str.3 = [14 x i8] c"/dev/rtmotor0\00"
@.str.5 = [2 x i8] c"1\00"
@.str.7 = [5 x i8] c"-400\00"
@.str.8 = [4 x i8] c"400\00"
@.str.9 = [2 x i8] c"0\00"
@.str.11 = [13 x i8] c"400 -400 500\00"
@.str.12 = [13 x i8] c"-400 400 500\00"
@str = [9 x i8] c"Motor On\00"
@str.16 = [17 x i8] c"Rotate clockwise\00"
@str.17 = [25 x i8] c"Rotate counter-clockwise\00"
@str.18 = [10 x i8] c"Motor Off\00"
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @O_WRONLY
%8 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%11 = tail call i32 @usleep(i32 500000)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
%13 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 5)
%14 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 5)
%15 = tail call i32 @usleep(i32 500000)
%16 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%17 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%18 = tail call i32 @usleep(i32 500000)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%20 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 5)
%21 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 5)
%22 = tail call i32 @usleep(i32 500000)
%23 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%24 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 5)
%25 = tail call i32 @usleep(i32 500000)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%27 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 15)
%28 = tail call i32 @usleep(i32 500000)
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
%30 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 15)
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.18, i64 0, i64 0))
%32 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%33 = tail call i32 @close(i32 %2)
%34 = tail call i32 @close(i32 %4)
%35 = tail call i32 @close(i32 %6)
%36 = tail call i32 @close(i32 %8)
ret i32 0
}