#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*/ printf(char *);
int readInt();
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ writeCommand(char *);
int /*<<< orphan*/ writeCommand2parm(char *, unsigned int, unsigned int);
void turnRightC(unsigned int speed, unsigned int distance) {
  int value = 0;
  writeCommand2parm("TRC", distance, speed);
  while (value != 3) {
    usleep(10);
    writeCommand("TGS,2");
    value = readInt();
    if (value == 4) {
      printf("error : speed to hight\n");
      value = 3;
    }
  }
}


x86 assembly (clang, -O0):
<turnRightC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe8e(%rip),%rdi
call   1030 <writeCommand2parm@plt>
cmpl   $0x3,-0xc(%rbp)
je     11c3 <turnRightC+0x73>
mov    $0xa,%edi
call   1070 <usleep@plt>
lea    0xe72(%rip),%rdi
call   1060 <writeCommand@plt>
mov    $0x0,%al
call   1050 <readInt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jne    11be <turnRightC+0x6e>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
movl   $0x3,-0xc(%rbp)
jmp    1177 <turnRightC+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turnRightC>:
push   %rbx
mov    %edi,%edx
lea    0xea6(%rip),%rdi
call   1040 <writeCommand2parm@plt>
lea    0xe9e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1060 <writeCommand@plt>
xor    %eax,%eax
call   1050 <readInt@plt>
cmp    $0x3,%eax
je     11a0 <turnRightC+0x50>
cmp    $0x4,%eax
jne    1170 <turnRightC+0x20>
lea    0xe70(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"TRC\00"
@.str.1 = [6 x i8] c"TGS,2\00"
@.str.2 = [24 x i8] c"error : speed to hight\0A\00"
define void @turnRightC(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @writeCommand2parm(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = call i32 @usleep(i32 10)
%14 = call i32 @writeCommand(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @readInt()
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 3, i32* %5
br label %20
20: ; preds = %18, %12
br label %9
21: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"TRC\00"
@.str.1 = [6 x i8] c"TGS,2\00"
@str = [23 x i8] c"error : speed to hight\00"
define void @turnRightC(i32 %0, i32 %1) {
%3 = tail call i32 @writeCommand2parm(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0)
br label %4
4: ; preds = %4, %2
%5 = tail call i32 @usleep(i32 10)
%6 = tail call i32 @writeCommand(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @readInt()
switch i32 %7, label %4 [
i32 4, label %8
i32 3, label %10
]
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %4, %8
ret void
}