#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 */
typedef scalar_t__ uint32_t;
typedef int int32_t;

/* Variables and functions */
char get_screen_cache(scalar_t__, scalar_t__);
int /*<<< orphan*/ set_screen_cache(scalar_t__, scalar_t__, char);
void draw_moving_wall() {
  typedef struct {
    uint32_t x;
    uint32_t y;
    int32_t vx;
    char str[4];
  } x_move_wall_t;
  static x_move_wall_t s_x_wall = {4, 3, 1, "---"};
  s_x_wall.x += s_x_wall.vx;
  if (s_x_wall.vx > 0) {
    if (get_screen_cache(s_x_wall.x + s_x_wall.vx + 2, s_x_wall.y) == '+')
      s_x_wall.vx *= -1;
  } else {
    if (get_screen_cache(s_x_wall.x + s_x_wall.vx, s_x_wall.y) == '+')
      s_x_wall.vx *= -1;
  }
  set_screen_cache(s_x_wall.x, s_x_wall.y, s_x_wall.str[0]);
  set_screen_cache(s_x_wall.x + 1, s_x_wall.y, s_x_wall.str[1]);
  set_screen_cache(s_x_wall.x + 2, s_x_wall.y, s_x_wall.str[2]);
}


x86 assembly (clang, -O0):
<draw_moving_wall>:
push   %rbp
mov    %rsp,%rbp
movslq 0x2f15(%rip),%rax
add    0x2efe(%rip),%rax
mov    %rax,0x2ef7(%rip)
cmpl   $0x0,0x2f00(%rip)
jle    1185 <draw_moving_wall+0x65>
mov    0x2ee3(%rip),%rdi
movslq 0x2eec(%rip),%rax
add    %rax,%rdi
add    $0x2,%rdi
mov    0x2ed6(%rip),%rsi
call   1040 <get_screen_cache@plt>
movsbl %al,%eax
cmp    $0x2b,%eax
jne    1180 <draw_moving_wall+0x60>
imul   $0xffffffff,0x2ec6(%rip),%eax
mov    %eax,0x2ec0(%rip)
jmp    11c0 <draw_moving_wall+0xa0>
mov    0x2ea4(%rip),%rdi
movslq 0x2ead(%rip),%rax
add    %rax,%rdi
mov    0x2e9b(%rip),%rsi
call   1040 <get_screen_cache@plt>
movsbl %al,%eax
cmp    $0x2b,%eax
jne    11bb <draw_moving_wall+0x9b>
imul   $0xffffffff,0x2e8b(%rip),%eax
mov    %eax,0x2e85(%rip)
jmp    11c0 <draw_moving_wall+0xa0>
mov    0x2e69(%rip),%rdi
mov    0x2e6a(%rip),%rsi
movsbl 0x2e6f(%rip),%edx
call   1030 <set_screen_cache@plt>
mov    0x2e4f(%rip),%rdi
add    $0x1,%rdi
mov    0x2e4c(%rip),%rsi
movsbl 0x2e52(%rip),%edx
call   1030 <set_screen_cache@plt>
mov    0x2e31(%rip),%rdi
add    $0x2,%rdi
mov    0x2e2e(%rip),%rsi
movsbl 0x2e35(%rip),%edx
call   1030 <set_screen_cache@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_moving_wall>:
push   %rax
movslq 0x2f10(%rip),%rax
mov    0x2f01(%rip),%rcx
add    %rax,%rcx
lea    (%rcx,%rax,1),%rdi
mov    %rcx,0x2ef3(%rip)
test   %rax,%rax
jle    1146 <draw_moving_wall+0x26>
add    $0x2,%rdi
mov    $0x3,%esi
call   1040 <get_screen_cache@plt>
cmp    $0x2b,%al
jne    115a <draw_moving_wall+0x3a>
negl   0x2ede(%rip)
mov    0x2ecf(%rip),%rdi
mov    $0x3,%esi
mov    $0x2d,%edx
call   1030 <set_screen_cache@plt>
mov    0x2eb9(%rip),%rdi
add    $0x1,%rdi
mov    $0x3,%esi
mov    $0x2d,%edx
call   1030 <set_screen_cache@plt>
mov    0x2e9f(%rip),%rdi
add    $0x2,%rdi
mov    $0x3,%esi
mov    $0x2d,%edx
pop    %rax
jmp    1030 <set_screen_cache@plt>

LLVM IR (-O0):
%struct.x_move_wall_t = type { i64, i64, i32, [4 x i8] }
@draw_moving_wall.s_x_wall = internal global %struct.x_move_wall_t { i64 4, i64 3, i32 1, [4 x i8] c"---\00" }
define void @draw_moving_wall() {
%1 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%2 = sext i32 %1 to i64
%3 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%4 = add nsw i64 %3, %2
store i64 %4, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%5 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %0
%8 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%9 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%10 = sext i32 %9 to i64
%11 = add nsw i64 %8, %10
%12 = add nsw i64 %11, 2
%13 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 1)
%14 = call signext i8 @get_screen_cache(i64 %12, i64 %13)
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 43
br i1 %16, label %17, label %20
17: ; preds = %7
%18 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%19 = mul nsw i32 %18, -1
store i32 %19, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
br label %20
20: ; preds = %17, %7
br label %34
21: ; preds = %0
%22 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%23 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%24 = sext i32 %23 to i64
%25 = add nsw i64 %22, %24
%26 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 1)
%27 = call signext i8 @get_screen_cache(i64 %25, i64 %26)
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 43
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = load i32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
%32 = mul nsw i32 %31, -1
store i32 %32, i32* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 2)
br label %33
33: ; preds = %30, %21
br label %34
34: ; preds = %33, %20
%35 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%36 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 1)
%37 = load i8, i8* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 3, i64 0)
%38 = call i32 @set_screen_cache(i64 %35, i64 %36, i8 signext %37)
%39 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%40 = add nsw i64 %39, 1
%41 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 1)
%42 = load i8, i8* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 3, i64 1)
%43 = call i32 @set_screen_cache(i64 %40, i64 %41, i8 signext %42)
%44 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 0)
%45 = add nsw i64 %44, 2
%46 = load i64, i64* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 1)
%47 = load i8, i8* getelementptr inbounds (%struct.x_move_wall_t, %struct.x_move_wall_t* @draw_moving_wall.s_x_wall, i32 0, i32 3, i64 2)
%48 = call i32 @set_screen_cache(i64 %45, i64 %46, i8 signext %47)
ret void
}

LLVM IR (-O2):
@draw_moving_wall.s_x_wall.0 = internal unnamed_addr global i64 4
@draw_moving_wall.s_x_wall.2 = internal unnamed_addr global i32 1
define void @draw_moving_wall() {
%1 = load i32, i32* @draw_moving_wall.s_x_wall.2
%2 = sext i32 %1 to i64
%3 = load i64, i64* @draw_moving_wall.s_x_wall.0
%4 = add nsw i64 %3, %2
store i64 %4, i64* @draw_moving_wall.s_x_wall.0
%5 = icmp sgt i32 %1, 0
%6 = add nsw i64 %4, %2
br i1 %5, label %7, label %11
7: ; preds = %0
%8 = add nsw i64 %6, 2
%9 = tail call signext i8 @get_screen_cache(i64 %8, i64 3)
%10 = icmp eq i8 %9, 43
br i1 %10, label %14, label %17
11: ; preds = %0
%12 = tail call signext i8 @get_screen_cache(i64 %6, i64 3)
%13 = icmp eq i8 %12, 43
br i1 %13, label %14, label %17
14: ; preds = %11, %7
%15 = load i32, i32* @draw_moving_wall.s_x_wall.2
%16 = sub nsw i32 0, %15
store i32 %16, i32* @draw_moving_wall.s_x_wall.2
br label %17
17: ; preds = %14, %11, %7
%18 = load i64, i64* @draw_moving_wall.s_x_wall.0
%19 = tail call i32 @set_screen_cache(i64 %18, i64 3, i8 signext 45)
%20 = load i64, i64* @draw_moving_wall.s_x_wall.0
%21 = add nsw i64 %20, 1
%22 = tail call i32 @set_screen_cache(i64 %21, i64 3, i8 signext 45)
%23 = load i64, i64* @draw_moving_wall.s_x_wall.0
%24 = add nsw i64 %23, 2
%25 = tail call i32 @set_screen_cache(i64 %24, i64 3, i8 signext 45)
ret void
}