#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*/ cup(int, int);
int /*<<< orphan*/ decaln();
int /*<<< orphan*/ decdwl();
int /*<<< orphan*/ decstbm(int, int);
int /*<<< orphan*/ el(int /*<<< orphan*/);
int /*<<< orphan*/ holdit();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ ri();
bug_b() {
  char c;
  decaln();
  cup(1, 1);
  el(0);
  printf("Line 11 should be double-wide, line 12 should be cleared.");
  cup(2, 1);
  el(0);
  printf("Then, the letters A-P should be written at the beginning");
  cup(3, 1);
  el(0);
  printf("of lines 12-24, and the empty line and A-E are scrolled away.");
  cup(4, 1);
  el(0);
  printf("If the bug is present, some lines are confused, look at K-P.");
  cup(11, 1);
  decdwl();
  decstbm(12, 24);
  cup(12, 1);
  el(0);
  printf("Here we go... ");
  holdit();
  cup(12, 1);
  ri();
  for (c = 'A'; c <= 'P'; c++)
    printf("%c\n", c);
  holdit();
  decstbm(0, 0);
}


x86 assembly (clang, -O0):
<bug_b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <decaln@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1060 <decdwl@plt>
mov    $0xc,%edi
mov    $0x18,%esi
call   1090 <decstbm@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <holdit@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1030 <ri@plt>
movb   $0x41,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
jg     12b2 <bug_b+0x132>
movsbl -0x5(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    1286 <bug_b+0x106>
mov    $0x0,%al
call   10a0 <holdit@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <decstbm@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bug_b>:
push   %rbx
xor    %eax,%eax
call   1050 <decaln@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1060 <decdwl@plt>
mov    $0xc,%edi
mov    $0x18,%esi
call   1090 <decstbm@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %edi,%edi
call   1080 <el@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   10a0 <holdit@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1030 <ri@plt>
lea    0xe78(%rip),%rbx
mov    %rbx,%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x42,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x43,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x45,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x46,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x47,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x48,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x49,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4a,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4c,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4e,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4f,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   10a0 <holdit@plt>
xor    %edi,%edi
xor    %esi,%esi
pop    %rbx
jmp    1090 <decstbm@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"Line 11 should be double-wide, line 12 should be cleared.\00"
@.str.1 = [57 x i8] c"Then, the letters A-P should be written at the beginning\00"
@.str.2 = [62 x i8] c"of lines 12-24, and the empty line and A-E are scrolled away.\00"
@.str.3 = [61 x i8] c"If the bug is present, some lines are confused, look at K-P.\00"
@.str.4 = [15 x i8] c"Here we go... \00"
@.str.5 = [4 x i8] c"%c\0A\00"
define i32 @bug_b() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 (...) @decaln()
%4 = call i32 @cup(i32 1, i32 1)
%5 = call i32 @el(i32 0)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @cup(i32 2, i32 1)
%8 = call i32 @el(i32 0)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @cup(i32 3, i32 1)
%11 = call i32 @el(i32 0)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @cup(i32 4, i32 1)
%14 = call i32 @el(i32 0)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @cup(i32 11, i32 1)
%17 = call i32 (...) @decdwl()
%18 = call i32 @decstbm(i32 12, i32 24)
%19 = call i32 @cup(i32 12, i32 1)
%20 = call i32 @el(i32 0)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (...) @holdit()
%23 = call i32 @cup(i32 12, i32 1)
%24 = call i32 (...) @ri()
store i8 65, i8* %2
br label %25
25: ; preds = %33, %0
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 80
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29
%34 = load i8, i8* %2
%35 = add i8 %34, 1
store i8 %35, i8* %2
br label %25
36: ; preds = %25
%37 = call i32 (...) @holdit()
%38 = call i32 @decstbm(i32 0, i32 0)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [58 x i8] c"Line 11 should be double-wide, line 12 should be cleared.\00"
@.str.1 = [57 x i8] c"Then, the letters A-P should be written at the beginning\00"
@.str.2 = [62 x i8] c"of lines 12-24, and the empty line and A-E are scrolled away.\00"
@.str.3 = [61 x i8] c"If the bug is present, some lines are confused, look at K-P.\00"
@.str.4 = [15 x i8] c"Here we go... \00"
@.str.5 = [4 x i8] c"%c\0A\00"
define i32 @bug_b() {
%1 = tail call i32 (...) @decaln()
%2 = tail call i32 @cup(i32 1, i32 1)
%3 = tail call i32 @el(i32 0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @cup(i32 2, i32 1)
%6 = tail call i32 @el(i32 0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @cup(i32 3, i32 1)
%9 = tail call i32 @el(i32 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @cup(i32 4, i32 1)
%12 = tail call i32 @el(i32 0)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @cup(i32 11, i32 1)
%15 = tail call i32 (...) @decdwl()
%16 = tail call i32 @decstbm(i32 12, i32 24)
%17 = tail call i32 @cup(i32 12, i32 1)
%18 = tail call i32 @el(i32 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 (...) @holdit()
%21 = tail call i32 @cup(i32 12, i32 1)
%22 = tail call i32 (...) @ri()
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 65)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 66)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 67)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 68)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 69)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 70)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 71)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 72)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 73)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 74)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 75)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 76)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 77)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 78)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 79)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 80)
%39 = tail call i32 (...) @holdit()
%40 = tail call i32 @decstbm(i32 0, i32 0)
ret i32 undef
}