#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*/ poke(int, unsigned int, unsigned int);
void linev(unsigned x, unsigned y, unsigned h, unsigned chr, unsigned color) {
  unsigned ofs = (y * 40 + x) * 2;
  unsigned v = (color << 8) | chr;
  while (h--) {
    poke(0xB800, ofs, v);
    ofs += 40 * 2;
  }
}


x86 assembly (clang, -O0):
<linev>:
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    %r8d,-0x14(%rbp)
imul   $0x28,-0x8(%rbp),%eax
add    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1173 <linev+0x63>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    $0xb800,%edi
call   1030 <poke@plt>
mov    -0x18(%rbp),%eax
add    $0x50,%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <linev+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linev>:
push   %rbp
push   %r14
push   %rbx
test   %edx,%edx
je     1147 <linev+0x37>
mov    %r8d,%r14d
mov    %edx,%ebp
shl    $0x8,%r14d
or     %ecx,%r14d
lea    (%rsi,%rsi,4),%eax
lea    (%rdi,%rax,8),%ebx
add    %ebx,%ebx
nopl   0x0(%rax)
mov    $0xb800,%edi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <poke@plt>
add    $0x50,%ebx
add    $0xffffffff,%ebp
jne    1130 <linev+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @linev(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %7
%14 = mul i32 %13, 40
%15 = load i32, i32* %6
%16 = add i32 %14, %15
%17 = mul i32 %16, 2
store i32 %17, i32* %11
%18 = load i32, i32* %10
%19 = shl i32 %18, 8
%20 = load i32, i32* %9
%21 = or i32 %19, %20
store i32 %21, i32* %12
br label %22
22: ; preds = %26, %5
%23 = load i32, i32* %8
%24 = add i32 %23, -1
store i32 %24, i32* %8
%25 = icmp ne i32 %23, 0
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = call i32 @poke(i32 47104, i32 %27, i32 %28)
%30 = load i32, i32* %11
%31 = add i32 %30, 80
store i32 %31, i32* %11
br label %22
32: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @linev(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = shl i32 %4, 8
%7 = or i32 %6, %3
%8 = icmp eq i32 %2, 0
br i1 %8, label %20, label %9
9: ; preds = %5
%10 = mul i32 %1, 40
%11 = add i32 %10, %0
%12 = shl i32 %11, 1
br label %13
13: ; preds = %9, %13
%14 = phi i32 [ %16, %13 ], [ %2, %9 ]
%15 = phi i32 [ %18, %13 ], [ %12, %9 ]
%16 = add i32 %14, -1
%17 = tail call i32 @poke(i32 47104, i32 %15, i32 %7)
%18 = add i32 %15, 80
%19 = icmp eq i32 %16, 0
br i1 %19, label %20, label %13
20: ; preds = %13, %5
ret void
}