#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*/ M_DrawCharacter(int, int, int);
void M_DrawTextBox(int x, int y, int width, int lines) {
  int cx, cy;
  int n;
  cx = x;
  cy = y;
  M_DrawCharacter(cx, cy, 1);
  for (n = 0; n < lines; n++) {
    cy += 8;
    M_DrawCharacter(cx, cy, 4);
  }
  M_DrawCharacter(cx, cy + 8, 7);
  cx += 8;
  while (width > 0) {
    cy = y;
    M_DrawCharacter(cx, cy, 2);
    for (n = 0; n < lines; n++) {
      cy += 8;
      M_DrawCharacter(cx, cy, 5);
    }
    M_DrawCharacter(cx, cy + 8, 8);
    width -= 1;
    cx += 8;
  }
  cy = y;
  M_DrawCharacter(cx, cy, 3);
  for (n = 0; n < lines; n++) {
    cy += 8;
    M_DrawCharacter(cx, cy, 6);
  }
  M_DrawCharacter(cx, cy + 8, 9);
}


x86 assembly (clang, -O0):
<M_DrawTextBox>:
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    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1030 <M_DrawCharacter@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    117a <M_DrawTextBox+0x6a>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x4,%edx
call   1030 <M_DrawCharacter@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <M_DrawTextBox+0x37>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x8,%esi
mov    $0x7,%edx
call   1030 <M_DrawCharacter@plt>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    121a <M_DrawTextBox+0x10a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1030 <M_DrawCharacter@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f0 <M_DrawTextBox+0xe0>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x5,%edx
call   1030 <M_DrawCharacter@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bd <M_DrawTextBox+0xad>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x8,%esi
mov    $0x8,%edx
call   1030 <M_DrawCharacter@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <M_DrawTextBox+0x86>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x3,%edx
call   1030 <M_DrawCharacter@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    126a <M_DrawTextBox+0x15a>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x6,%edx
call   1030 <M_DrawCharacter@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1237 <M_DrawTextBox+0x127>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x8,%esi
mov    $0x9,%edx
call   1030 <M_DrawCharacter@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<M_DrawTextBox>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r15d
mov    $0x1,%edx
call   1030 <M_DrawCharacter@plt>
mov    %r12d,%r13d
test   %r14d,%r14d
jle    1159 <M_DrawTextBox+0x49>
mov    %r14d,%ebx
mov    %r12d,%r13d
xchg   %ax,%ax
add    $0x8,%r13d
mov    %r15d,%edi
mov    %r13d,%esi
mov    $0x4,%edx
call   1030 <M_DrawCharacter@plt>
add    $0xffffffff,%ebx
jne    1140 <M_DrawTextBox+0x30>
add    $0x8,%r13d
mov    %r15d,%edi
mov    %r13d,%esi
mov    $0x7,%edx
call   1030 <M_DrawCharacter@plt>
add    $0x8,%r15d
mov    %rbp,%r13
test   %r13d,%r13d
jg     11f3 <M_DrawTextBox+0xe3>
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0x3,%edx
call   1030 <M_DrawCharacter@plt>
test   %r14d,%r14d
jle    11aa <M_DrawTextBox+0x9a>
xchg   %ax,%ax
add    $0x8,%r12d
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0x6,%edx
call   1030 <M_DrawCharacter@plt>
add    $0xffffffff,%r14d
jne    1190 <M_DrawTextBox+0x80>
add    $0x8,%r12d
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0x9,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <M_DrawCharacter@plt>
nopl   0x0(%rax)
add    $0x8,%ebx
mov    %r15d,%edi
mov    %ebx,%esi
mov    $0x8,%edx
call   1030 <M_DrawCharacter@plt>
lea    -0x1(%r13),%eax
add    $0x8,%r15d
cmp    $0x1,%r13d
mov    %eax,%r13d
jle    1179 <M_DrawTextBox+0x69>
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0x2,%edx
call   1030 <M_DrawCharacter@plt>
mov    %r12d,%ebx
test   %r14d,%r14d
jle    11d0 <M_DrawTextBox+0xc0>
mov    %r14d,%ebp
mov    %r12d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x8,%ebx
mov    %r15d,%edi
mov    %ebx,%esi
mov    $0x5,%edx
call   1030 <M_DrawCharacter@plt>
add    $0xffffffff,%ebp
jne    1220 <M_DrawTextBox+0x110>
jmp    11d0 <M_DrawTextBox+0xc0>

LLVM IR (-O0):
define void @M_DrawTextBox(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %5
store i32 %12, i32* %9
%13 = load i32, i32* %6
store i32 %13, i32* %10
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = call i32 @M_DrawCharacter(i32 %14, i32 %15, i32 1)
store i32 0, i32* %11
br label %17
17: ; preds = %27, %4
%18 = load i32, i32* %11
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 8
store i32 %23, i32* %10
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = call i32 @M_DrawCharacter(i32 %24, i32 %25, i32 4)
br label %27
27: ; preds = %21
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %17
30: ; preds = %17
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 8
%34 = call i32 @M_DrawCharacter(i32 %31, i32 %33, i32 7)
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 8
store i32 %36, i32* %9
br label %37
37: ; preds = %58, %30
%38 = load i32, i32* %7
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %67
40: ; preds = %37
%41 = load i32, i32* %6
store i32 %41, i32* %10
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = call i32 @M_DrawCharacter(i32 %42, i32 %43, i32 2)
store i32 0, i32* %11
br label %45
45: ; preds = %55, %40
%46 = load i32, i32* %11
%47 = load i32, i32* %8
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 8
store i32 %51, i32* %10
%52 = load i32, i32* %9
%53 = load i32, i32* %10
%54 = call i32 @M_DrawCharacter(i32 %52, i32 %53, i32 5)
br label %55
55: ; preds = %49
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %45
58: ; preds = %45
%59 = load i32, i32* %9
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 8
%62 = call i32 @M_DrawCharacter(i32 %59, i32 %61, i32 8)
%63 = load i32, i32* %7
%64 = sub nsw i32 %63, 1
store i32 %64, i32* %7
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 8
store i32 %66, i32* %9
br label %37
67: ; preds = %37
%68 = load i32, i32* %6
store i32 %68, i32* %10
%69 = load i32, i32* %9
%70 = load i32, i32* %10
%71 = call i32 @M_DrawCharacter(i32 %69, i32 %70, i32 3)
store i32 0, i32* %11
br label %72
72: ; preds = %82, %67
%73 = load i32, i32* %11
%74 = load i32, i32* %8
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %85
76: ; preds = %72
%77 = load i32, i32* %10
%78 = add nsw i32 %77, 8
store i32 %78, i32* %10
%79 = load i32, i32* %9
%80 = load i32, i32* %10
%81 = call i32 @M_DrawCharacter(i32 %79, i32 %80, i32 6)
br label %82
82: ; preds = %76
%83 = load i32, i32* %11
%84 = add nsw i32 %83, 1
store i32 %84, i32* %11
br label %72
85: ; preds = %72
%86 = load i32, i32* %9
%87 = load i32, i32* %10
%88 = add nsw i32 %87, 8
%89 = call i32 @M_DrawCharacter(i32 %86, i32 %88, i32 9)
ret void
}

LLVM IR (-O2):
define void @M_DrawTextBox(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @M_DrawCharacter(i32 %0, i32 %1, i32 1)
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %14
7: ; preds = %4, %7
%8 = phi i32 [ %12, %7 ], [ 0, %4 ]
%9 = phi i32 [ %10, %7 ], [ %1, %4 ]
%10 = add nsw i32 %9, 8
%11 = tail call i32 @M_DrawCharacter(i32 %0, i32 %10, i32 4)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, %3
br i1 %13, label %14, label %7
14: ; preds = %7, %4
%15 = phi i32 [ %1, %4 ], [ %10, %7 ]
%16 = add nsw i32 %15, 8
%17 = tail call i32 @M_DrawCharacter(i32 %0, i32 %16, i32 7)
%18 = add nsw i32 %0, 8
%19 = icmp sgt i32 %2, 0
br i1 %19, label %20, label %38
20: ; preds = %14, %31
%21 = phi i32 [ %36, %31 ], [ %18, %14 ]
%22 = phi i32 [ %35, %31 ], [ %2, %14 ]
%23 = tail call i32 @M_DrawCharacter(i32 %21, i32 %1, i32 2)
br i1 %6, label %24, label %31
24: ; preds = %20, %24
%25 = phi i32 [ %29, %24 ], [ 0, %20 ]
%26 = phi i32 [ %27, %24 ], [ %1, %20 ]
%27 = add nsw i32 %26, 8
%28 = tail call i32 @M_DrawCharacter(i32 %21, i32 %27, i32 5)
%29 = add nuw nsw i32 %25, 1
%30 = icmp eq i32 %29, %3
br i1 %30, label %31, label %24
31: ; preds = %24, %20
%32 = phi i32 [ %1, %20 ], [ %27, %24 ]
%33 = add nsw i32 %32, 8
%34 = tail call i32 @M_DrawCharacter(i32 %21, i32 %33, i32 8)
%35 = add nsw i32 %22, -1
%36 = add nsw i32 %21, 8
%37 = icmp sgt i32 %22, 1
br i1 %37, label %20, label %38
38: ; preds = %31, %14
%39 = phi i32 [ %18, %14 ], [ %36, %31 ]
%40 = tail call i32 @M_DrawCharacter(i32 %39, i32 %1, i32 3)
br i1 %6, label %41, label %48
41: ; preds = %38, %41
%42 = phi i32 [ %46, %41 ], [ 0, %38 ]
%43 = phi i32 [ %44, %41 ], [ %1, %38 ]
%44 = add nsw i32 %43, 8
%45 = tail call i32 @M_DrawCharacter(i32 %39, i32 %44, i32 6)
%46 = add nuw nsw i32 %42, 1
%47 = icmp eq i32 %46, %3
br i1 %47, label %48, label %41
48: ; preds = %41, %38
%49 = phi i32 [ %1, %38 ], [ %44, %41 ]
%50 = add nsw i32 %49, 8
%51 = tail call i32 @M_DrawCharacter(i32 %39, i32 %50, i32 9)
ret void
}