#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*/ create_drive_direct(int, int);
scalar_t__ digital(int);
int /*<<< orphan*/ msleep(int);
void create_drive_touch(int rspeed, int lspeed, int rport, int lport) {
  create_drive_direct(rspeed, lspeed);
  while (!digital(rport) || !digital(lport)) {
    if (digital(rport)) {
      create_drive_direct(rspeed / 10, lspeed);
      msleep(10);
    }
    if (digital(lport)) {
      create_drive_direct(rspeed, lspeed / 10);
      msleep(10);
    }
  }
}


x86 assembly (clang, -O0):
<create_drive_touch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <create_drive_direct@plt>
mov    -0xc(%rbp),%edi
call   1040 <digital@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     117d <create_drive_touch+0x4d>
mov    -0x10(%rbp),%edi
call   1040 <digital@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118d <create_drive_touch+0x5d>
jmp    11f4 <create_drive_touch+0xc4>
mov    -0xc(%rbp),%edi
call   1040 <digital@plt>
cmp    $0x0,%rax
je     11be <create_drive_touch+0x8e>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1050 <create_drive_direct@plt>
mov    $0xa,%edi
call   1030 <msleep@plt>
mov    -0x10(%rbp),%edi
call   1040 <digital@plt>
cmp    $0x0,%rax
je     11ef <create_drive_touch+0xbf>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1050 <create_drive_direct@plt>
mov    $0xa,%edi
call   1030 <msleep@plt>
jmp    114f <create_drive_touch+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_drive_touch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
call   1050 <create_drive_direct@plt>
movslq %r15d,%rax
imul   $0x66666667,%rax,%r12
mov    %r12,%rax
shr    $0x3f,%rax
sar    $0x22,%r12
add    %eax,%r12d
movslq %r14d,%rax
imul   $0x66666667,%rax,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x22,%r13
add    %eax,%r13d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <digital@plt>
test   %rax,%rax
je     1198 <create_drive_touch+0x68>
mov    %ebx,%edi
call   1040 <digital@plt>
test   %rax,%rax
jne    11dc <create_drive_touch+0xac>
mov    %ebp,%edi
call   1040 <digital@plt>
test   %rax,%rax
je     11b9 <create_drive_touch+0x89>
mov    %r12d,%edi
mov    %r14d,%esi
call   1050 <create_drive_direct@plt>
mov    $0xa,%edi
call   1030 <msleep@plt>
mov    %ebx,%edi
call   1040 <digital@plt>
test   %rax,%rax
je     1180 <create_drive_touch+0x50>
mov    %r15d,%edi
mov    %r13d,%esi
call   1050 <create_drive_direct@plt>
mov    $0xa,%edi
call   1030 <msleep@plt>
jmp    1180 <create_drive_touch+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @create_drive_touch(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @create_drive_direct(i32 %9, i32 %10)
br label %12
12: ; preds = %43, %4
%13 = load i32, i32* %7
%14 = call i64 @digital(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* %8
%18 = call i64 @digital(i32 %17)
%19 = icmp ne i64 %18, 0
%20 = xor i1 %19, true
br label %21
21: ; preds = %16, %12
%22 = phi i1 [ true, %12 ], [ %20, %16 ]
br i1 %22, label %23, label %44
23: ; preds = %21
%24 = load i32, i32* %7
%25 = call i64 @digital(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i32, i32* %5
%29 = sdiv i32 %28, 10
%30 = load i32, i32* %6
%31 = call i32 @create_drive_direct(i32 %29, i32 %30)
%32 = call i32 @msleep(i32 10)
br label %33
33: ; preds = %27, %23
%34 = load i32, i32* %8
%35 = call i64 @digital(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = sdiv i32 %39, 10
%41 = call i32 @create_drive_direct(i32 %38, i32 %40)
%42 = call i32 @msleep(i32 10)
br label %43
43: ; preds = %37, %33
br label %12
44: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @create_drive_touch(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @create_drive_direct(i32 %0, i32 %1)
%6 = sdiv i32 %0, 10
%7 = sdiv i32 %1, 10
br label %8
8: ; preds = %26, %4
%9 = tail call i64 @digital(i32 %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i64 @digital(i32 %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %8, %11
%15 = tail call i64 @digital(i32 %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i32 @create_drive_direct(i32 %6, i32 %1)
%19 = tail call i32 @msleep(i32 10)
br label %20
20: ; preds = %17, %14
%21 = tail call i64 @digital(i32 %3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 @create_drive_direct(i32 %0, i32 %7)
%25 = tail call i32 @msleep(i32 10)
br label %26
26: ; preds = %23, %20
br label %8
27: ; preds = %11
ret void
}