#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*/ cmdAdd(int);
int /*<<< orphan*/ cmdLoopBegin();
int /*<<< orphan*/ cmdLoopEnd();
int /*<<< orphan*/ cmdMoveLeft(int);
int /*<<< orphan*/ cmdMoveRight(int);
int /*<<< orphan*/ cmdSet(int /*<<< orphan*/);
int /*<<< orphan*/ cmdSubtract(int);
void cmdCopyRight(int iCount) {
  int iPos;
  for (iPos = 0; iPos < iCount; iPos++) {
    cmdMoveRight(1);
    cmdSet(0);
  }
  for (iPos = 0; iPos < iCount; iPos++)
    cmdMoveLeft(1);
  cmdLoopBegin();
  for (iPos = 0; iPos < iCount; iPos++) {
    cmdMoveRight(1);
    cmdAdd(1);
  }
  for (iPos = 0; iPos < iCount; iPos++)
    cmdMoveLeft(1);
  cmdSubtract(1);
  cmdLoopEnd();
}


x86 assembly (clang, -O0):
<cmdCopyRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ad <cmdCopyRight+0x3d>
mov    $0x1,%edi
call   1040 <cmdMoveRight@plt>
xor    %edi,%edi
call   1030 <cmdSet@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1182 <cmdCopyRight+0x12>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d8 <cmdCopyRight+0x68>
mov    $0x1,%edi
call   1090 <cmdMoveLeft@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <cmdCopyRight+0x44>
mov    $0x0,%al
call   1060 <cmdLoopBegin@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1214 <cmdCopyRight+0xa4>
mov    $0x1,%edi
call   1040 <cmdMoveRight@plt>
mov    $0x1,%edi
call   1080 <cmdAdd@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e6 <cmdCopyRight+0x76>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    123f <cmdCopyRight+0xcf>
mov    $0x1,%edi
call   1090 <cmdMoveLeft@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    121b <cmdCopyRight+0xab>
mov    $0x1,%edi
call   1050 <cmdSubtract@plt>
mov    $0x0,%al
call   1070 <cmdLoopEnd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdCopyRight>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jle    11f1 <cmdCopyRight+0x81>
mov    %edi,%ebx
mov    %edi,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <cmdMoveRight@plt>
xor    %edi,%edi
call   1030 <cmdSet@plt>
add    $0xffffffff,%ebp
jne    1180 <cmdCopyRight+0x10>
test   %ebx,%ebx
jle    11f1 <cmdCopyRight+0x81>
mov    %ebx,%ebp
nopl   0x0(%rax)
mov    $0x1,%edi
call   1090 <cmdMoveLeft@plt>
add    $0xffffffff,%ebp
jne    11a0 <cmdCopyRight+0x30>
xor    %eax,%eax
call   1060 <cmdLoopBegin@plt>
test   %ebx,%ebx
jle    11f8 <cmdCopyRight+0x88>
mov    %ebx,%ebp
nopl   0x0(%rax)
mov    $0x1,%edi
call   1040 <cmdMoveRight@plt>
mov    $0x1,%edi
call   1080 <cmdAdd@plt>
add    $0xffffffff,%ebp
jne    11c0 <cmdCopyRight+0x50>
test   %ebx,%ebx
jle    11f8 <cmdCopyRight+0x88>
nopl   (%rax)
mov    $0x1,%edi
call   1090 <cmdMoveLeft@plt>
add    $0xffffffff,%ebx
jne    11e0 <cmdCopyRight+0x70>
jmp    11f8 <cmdCopyRight+0x88>
xor    %eax,%eax
call   1060 <cmdLoopBegin@plt>
mov    $0x1,%edi
call   1050 <cmdSubtract@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <cmdLoopEnd@plt>

LLVM IR (-O0):
define void @cmdCopyRight(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %11, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = call i32 @cmdMoveRight(i32 1)
%10 = call i32 @cmdSet(i32 0)
br label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %4
14: ; preds = %4
store i32 0, i32* %3
br label %15
15: ; preds = %21, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = call i32 @cmdMoveLeft(i32 1)
br label %21
21: ; preds = %19
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %15
24: ; preds = %15
%25 = call i32 (...) @cmdLoopBegin()
store i32 0, i32* %3
br label %26
26: ; preds = %33, %24
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = call i32 @cmdMoveRight(i32 1)
%32 = call i32 @cmdAdd(i32 1)
br label %33
33: ; preds = %30
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %26
36: ; preds = %26
store i32 0, i32* %3
br label %37
37: ; preds = %43, %36
%38 = load i32, i32* %3
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = call i32 @cmdMoveLeft(i32 1)
br label %43
43: ; preds = %41
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %37
46: ; preds = %37
%47 = call i32 @cmdSubtract(i32 1)
%48 = call i32 (...) @cmdLoopEnd()
ret void
}

LLVM IR (-O2):
define void @cmdCopyRight(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %4, label %15
3: ; preds = %4
br i1 %2, label %10, label %15
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ 0, %1 ]
%6 = tail call i32 @cmdMoveRight(i32 1)
%7 = tail call i32 @cmdSet(i32 0)
%8 = add nuw nsw i32 %5, 1
%9 = icmp eq i32 %8, %0
br i1 %9, label %3, label %4
10: ; preds = %3, %10
%11 = phi i32 [ %13, %10 ], [ 0, %3 ]
%12 = tail call i32 @cmdMoveLeft(i32 1)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %0
br i1 %14, label %17, label %10
15: ; preds = %3, %1
%16 = tail call i32 (...) @cmdLoopBegin()
br label %31
17: ; preds = %10
%18 = tail call i32 (...) @cmdLoopBegin()
br i1 %2, label %20, label %31
19: ; preds = %20
br i1 %2, label %26, label %31
20: ; preds = %17, %20
%21 = phi i32 [ %24, %20 ], [ 0, %17 ]
%22 = tail call i32 @cmdMoveRight(i32 1)
%23 = tail call i32 @cmdAdd(i32 1)
%24 = add nuw nsw i32 %21, 1
%25 = icmp eq i32 %24, %0
br i1 %25, label %19, label %20
26: ; preds = %19, %26
%27 = phi i32 [ %29, %26 ], [ 0, %19 ]
%28 = tail call i32 @cmdMoveLeft(i32 1)
%29 = add nuw nsw i32 %27, 1
%30 = icmp eq i32 %29, %0
br i1 %30, label %31, label %26
31: ; preds = %26, %17, %15, %19
%32 = tail call i32 @cmdSubtract(i32 1)
%33 = tail call i32 (...) @cmdLoopEnd()
ret void
}