#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*/ delay_ms(int);
int /*<<< orphan*/ fill(int);
int /*<<< orphan*/ setplane(unsigned char, int, int);
void flyplane(unsigned char plane, unsigned char direction, int delay) {
  int i, ii;
  fill(0x00);
  for (i = 0; i < 4; i++) {
    if (direction != 0) {
      ii = 3 - i;
    } else {
      ii = i;
    }
    setplane(plane, ii, 1);
    delay_ms(delay);
    setplane(plane, ii, 0);
  }
  for (i = 2; i >= 0; i--) {
    if (direction != 0) {
      ii = 3 - i;
    } else {
      ii = i;
    }
    setplane(plane, ii, 1);
    delay_ms(delay);
    setplane(plane, ii, 0);
  }
}


x86 assembly (clang, -O0):
<flyplane>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    %edx,-0x8(%rbp)
xor    %edi,%edi
call   1030 <fill@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11bb <flyplane+0x8b>
movzbl -0x2(%rbp),%eax
cmp    $0x0,%eax
je     117c <flyplane+0x4c>
mov    $0x3,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1182 <flyplane+0x52>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%esi
mov    $0x1,%edx
movzbl %al,%edi
call   1040 <setplane@plt>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%esi
xor    %edx,%edx
movzbl %al,%edi
call   1040 <setplane@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1155 <flyplane+0x25>
movl   $0x2,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1228 <flyplane+0xf8>
movzbl -0x2(%rbp),%eax
cmp    $0x0,%eax
je     11e9 <flyplane+0xb9>
mov    $0x3,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ef <flyplane+0xbf>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%esi
mov    $0x1,%edx
movzbl %al,%edi
call   1040 <setplane@plt>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%esi
xor    %edx,%edx
movzbl %al,%edi
call   1040 <setplane@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11c2 <flyplane+0x92>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flyplane>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
call   1030 <fill@plt>
xor    %r14d,%r14d
xor    %eax,%eax
test   %ebp,%ebp
sete   %r14b
setne  %al
lea    (%rax,%rax,2),%ebp
mov    %ebp,0x4(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
mov    $0x2,%r12d
sub    %r14d,%r12d
mov    %ebx,%edi
mov    %r12d,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %r12d,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
lea    0x1(%r14),%r13d
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %r13d,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
lea    (%r14,%r14,2),%ebp
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %r13d,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %r12d,%esi
xor    %edx,%edx
call   1040 <setplane@plt>
mov    %ebx,%edi
mov    0x4(%rsp),%ebp
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <setplane@plt>
mov    %r15d,%edi
call   1050 <delay_ms@plt>
mov    %ebx,%edi
mov    %ebp,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <setplane@plt>

LLVM IR (-O0):
define void @flyplane(i8 zeroext %0, i8 zeroext %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8 %0, i8* %4
store i8 %1, i8* %5
store i32 %2, i32* %6
%9 = call i32 @fill(i32 0)
store i32 0, i32* %7
br label %10
10: ; preds = %31, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = load i8, i8* %5
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %7
%19 = sub nsw i32 3, %18
store i32 %19, i32* %8
br label %22
20: ; preds = %13
%21 = load i32, i32* %7
store i32 %21, i32* %8
br label %22
22: ; preds = %20, %17
%23 = load i8, i8* %4
%24 = load i32, i32* %8
%25 = call i32 @setplane(i8 zeroext %23, i32 %24, i32 1)
%26 = load i32, i32* %6
%27 = call i32 @delay_ms(i32 %26)
%28 = load i8, i8* %4
%29 = load i32, i32* %8
%30 = call i32 @setplane(i8 zeroext %28, i32 %29, i32 0)
br label %31
31: ; preds = %22
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %10
34: ; preds = %10
store i32 2, i32* %7
br label %35
35: ; preds = %56, %34
%36 = load i32, i32* %7
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %59
38: ; preds = %35
%39 = load i8, i8* %5
%40 = zext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %7
%44 = sub nsw i32 3, %43
store i32 %44, i32* %8
br label %47
45: ; preds = %38
%46 = load i32, i32* %7
store i32 %46, i32* %8
br label %47
47: ; preds = %45, %42
%48 = load i8, i8* %4
%49 = load i32, i32* %8
%50 = call i32 @setplane(i8 zeroext %48, i32 %49, i32 1)
%51 = load i32, i32* %6
%52 = call i32 @delay_ms(i32 %51)
%53 = load i8, i8* %4
%54 = load i32, i32* %8
%55 = call i32 @setplane(i8 zeroext %53, i32 %54, i32 0)
br label %56
56: ; preds = %47
%57 = load i32, i32* %7
%58 = add nsw i32 %57, -1
store i32 %58, i32* %7
br label %35
59: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @flyplane(i8 zeroext %0, i8 zeroext %1, i32 %2) {
%4 = tail call i32 @fill(i32 0)
%5 = icmp eq i8 %1, 0
%6 = select i1 %5, i32 0, i32 3
%7 = tail call i32 @setplane(i8 zeroext %0, i32 %6, i32 1)
%8 = tail call i32 @delay_ms(i32 %2)
%9 = tail call i32 @setplane(i8 zeroext %0, i32 %6, i32 0)
%10 = select i1 %5, i32 1, i32 2
%11 = tail call i32 @setplane(i8 zeroext %0, i32 %10, i32 1)
%12 = tail call i32 @delay_ms(i32 %2)
%13 = tail call i32 @setplane(i8 zeroext %0, i32 %10, i32 0)
%14 = select i1 %5, i32 2, i32 1
%15 = tail call i32 @setplane(i8 zeroext %0, i32 %14, i32 1)
%16 = tail call i32 @delay_ms(i32 %2)
%17 = tail call i32 @setplane(i8 zeroext %0, i32 %14, i32 0)
%18 = select i1 %5, i32 3, i32 0
%19 = tail call i32 @setplane(i8 zeroext %0, i32 %18, i32 1)
%20 = tail call i32 @delay_ms(i32 %2)
%21 = tail call i32 @setplane(i8 zeroext %0, i32 %18, i32 0)
%22 = tail call i32 @setplane(i8 zeroext %0, i32 %14, i32 1)
%23 = tail call i32 @delay_ms(i32 %2)
%24 = tail call i32 @setplane(i8 zeroext %0, i32 %14, i32 0)
%25 = tail call i32 @setplane(i8 zeroext %0, i32 %10, i32 1)
%26 = tail call i32 @delay_ms(i32 %2)
%27 = tail call i32 @setplane(i8 zeroext %0, i32 %10, i32 0)
%28 = tail call i32 @setplane(i8 zeroext %0, i32 %6, i32 1)
%29 = tail call i32 @delay_ms(i32 %2)
%30 = tail call i32 @setplane(i8 zeroext %0, i32 %6, i32 0)
ret void
}