#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 */
scalar_t__ change_velocity(int, int, int);
int /*<<< orphan*/ draw_x(int);
int /*<<< orphan*/ draw_y(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int x_axis = 1;
  int y_axis = 10;
  int left = 0;
  int right = 20;
  int top = 0;
  int bottom = 20;
  int velocity_x = 1;
  int velocity_y = 1;
  while (1) {
    x_axis += velocity_x;
    y_axis += velocity_y;
    system("clear");
    draw_x(x_axis);
    draw_y(y_axis);
    printf("o");
    printf("\n");
    sleep(1);
    if (change_velocity(x_axis, left, right))
      velocity_x = -velocity_x;
    if (change_velocity(y_axis, top, bottom))
      velocity_y = -velocity_y;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x14,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x14,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xe39(%rip),%rdi
call   1030 <system@plt>
mov    -0x14(%rbp),%edi
call   1060 <draw_x@plt>
mov    -0x18(%rbp),%edi
call   1080 <draw_y@plt>
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <change_velocity@plt>
cmp    $0x0,%rax
je     121e <main+0xbe>
xor    %eax,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <change_velocity@plt>
cmp    $0x0,%rax
je     123e <main+0xde>
xor    %eax,%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    11ae <main+0x4e>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%ebx
mov    $0xa,%ebp
lea    0xe87(%rip),%r14
mov    $0x1,%r15d
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
add    %r15d,%ebx
add    %r12d,%ebp
mov    %r14,%rdi
call   1040 <system@plt>
mov    %ebx,%edi
call   1060 <draw_x@plt>
mov    %ebp,%edi
call   1080 <draw_y@plt>
mov    $0x6f,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <change_velocity@plt>
test   %rax,%rax
je     11e0 <main+0x80>
neg    %r15d
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <change_velocity@plt>
test   %rax,%rax
je     1190 <main+0x30>
neg    %r12d
jmp    1190 <main+0x30>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [2 x i8] c"o\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 10, i32* %7
store i32 0, i32* %8
store i32 20, i32* %9
store i32 0, i32* %10
store i32 20, i32* %11
store i32 1, i32* %12
store i32 1, i32* %13
br label %14
14: ; preds = %2, %46
%15 = load i32, i32* %12
%16 = load i32, i32* %6
%17 = add nsw i32 %16, %15
store i32 %17, i32* %6
%18 = load i32, i32* %13
%19 = load i32, i32* %7
%20 = add nsw i32 %19, %18
store i32 %20, i32* %7
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = call i32 @draw_x(i32 %22)
%24 = load i32, i32* %7
%25 = call i32 @draw_y(i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @sleep(i32 1)
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = call i64 @change_velocity(i32 %29, i32 %30, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %14
%35 = load i32, i32* %12
%36 = sub nsw i32 0, %35
store i32 %36, i32* %12
br label %37
37: ; preds = %34, %14
%38 = load i32, i32* %7
%39 = load i32, i32* %10
%40 = load i32, i32* %11
%41 = call i64 @change_velocity(i32 %38, i32 %39, i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i32, i32* %13
%45 = sub nsw i32 0, %44
store i32 %45, i32* %13
br label %46
46: ; preds = %43, %37
br label %14
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 10, %2 ], [ %9, %3 ]
%5 = phi i32 [ 1, %2 ], [ %8, %3 ]
%6 = phi i32 [ 1, %2 ], [ %19, %3 ]
%7 = phi i32 [ 1, %2 ], [ %23, %3 ]
%8 = add nsw i32 %6, %5
%9 = add nsw i32 %7, %4
%10 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @draw_x(i32 %8)
%12 = tail call i32 @draw_y(i32 %9)
%13 = tail call i32 @putchar(i32 111)
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 @sleep(i32 1)
%16 = tail call i64 @change_velocity(i32 %8, i32 0, i32 20)
%17 = icmp eq i64 %16, 0
%18 = sub nsw i32 0, %6
%19 = select i1 %17, i32 %6, i32 %18
%20 = tail call i64 @change_velocity(i32 %9, i32 0, i32 20)
%21 = icmp eq i64 %20, 0
%22 = sub nsw i32 0, %7
%23 = select i1 %21, i32 %7, i32 %22
br label %3
}