#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*/ decdwl();
int /*<<< orphan*/ decswl();
int /*<<< orphan*/ ed(int);
int /*<<< orphan*/ holdit();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ rm(char *);
int /*<<< orphan*/ sm(char *);
bug_l() {
  cup(15, 1);
  printf("This-is-a-long-line-This-is-a-long-line-");
  printf("This-is-a-long-line-This-is-a-long-line-");
  cup(1, 1);
  printf("This is a test of what happens to the right half of double-width");
  println(" lines.");
  printf("A common misfeature is that the right half does not come back");
  println(" when a long");
  printf("single-width line is set to double-width and then reset to");
  println(" single-width.");
  cup(5, 1);
  println("Now the line below should contain 80 characters in single width.");
  holdit();
  cup(15, 1);
  decdwl();
  cup(8, 1);
  println("Now the line below should contain 40 characters in double width.");
  holdit();
  cup(15, 1);
  decswl();
  cup(11, 1);
  println("Now the line below should contain 80 characters in single width.");
  holdit();
  sm("?3");
  ed(2);
  cup(15, 1);
  printf("This-is-a-long-line-This-is-a-long-line-");
  printf("This-is-a-long-line-This-is-a-long-line-");
  printf("This-is-a-long-line-This-is-a-long-line-");
  printf("ending-here-");
  cup(1, 1);
  printf("This is the same test in 132 column mode.");
  cup(5, 1);
  println("Now the line below should contain 132 characters in single width.");
  holdit();
  cup(15, 1);
  decdwl();
  cup(8, 1);
  println("Now the line below should contain 66 characters in double width.");
  holdit();
  cup(15, 1);
  decswl();
  cup(11, 1);
  println("Now the line below should contain 132 characters in single width.");
  holdit();
  rm("?3");
}


x86 assembly (clang, -O0):
<bug_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <cup@plt>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1060 <println@plt>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
call   1060 <println@plt>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
call   1060 <println@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xede(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1050 <decdwl@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xee7(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1080 <decswl@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe6e(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
lea    0xedd(%rip),%rdi
call   10a0 <sm@plt>
mov    $0x2,%edi
call   1090 <ed@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xd2f(%rip),%rdi
call   1040 <printf@plt>
lea    0xd23(%rip),%rdi
call   1040 <printf@plt>
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <cup@plt>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe9b(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1050 <decdwl@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xea5(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1080 <decswl@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe2b(%rip),%rdi
call   1060 <println@plt>
mov    $0x0,%al
call   10b0 <holdit@plt>
lea    0xdde(%rip),%rdi
call   1030 <rm@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bug_l>:
push   %r15
push   %r14
push   %rbx
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe55(%rip),%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1060 <println@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
call   1060 <println@plt>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
call   1060 <println@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xedf(%rip),%rbx
mov    %rbx,%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1050 <decdwl@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xee5(%rip),%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1080 <decswl@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    %rbx,%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
lea    0xedf(%rip),%r14
mov    %r14,%rdi
call   10a0 <sm@plt>
mov    $0x2,%edi
call   1090 <ed@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1050 <decdwl@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xeaa(%rip),%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
xor    %eax,%eax
call   1080 <decswl@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    %rbx,%rdi
call   1060 <println@plt>
xor    %eax,%eax
call   10b0 <holdit@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <rm@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"This-is-a-long-line-This-is-a-long-line-\00"
@.str.1 = [65 x i8] c"This is a test of what happens to the right half of double-width\00"
@.str.2 = [8 x i8] c" lines.\00"
@.str.3 = [62 x i8] c"A common misfeature is that the right half does not come back\00"
@.str.4 = [13 x i8] c" when a long\00"
@.str.5 = [59 x i8] c"single-width line is set to double-width and then reset to\00"
@.str.6 = [15 x i8] c" single-width.\00"
@.str.7 = [65 x i8] c"Now the line below should contain 80 characters in single width.\00"
@.str.8 = [65 x i8] c"Now the line below should contain 40 characters in double width.\00"
@.str.9 = [3 x i8] c"?3\00"
@.str.10 = [13 x i8] c"ending-here-\00"
@.str.11 = [42 x i8] c"This is the same test in 132 column mode.\00"
@.str.12 = [66 x i8] c"Now the line below should contain 132 characters in single width.\00"
@.str.13 = [65 x i8] c"Now the line below should contain 66 characters in double width.\00"
define i32 @bug_l() {
%1 = alloca i32
%2 = call i32 @cup(i32 15, i32 1)
%3 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @cup(i32 1, i32 1)
%6 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @println(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @println(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @cup(i32 5, i32 1)
%13 = call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (...) @holdit()
%15 = call i32 @cup(i32 15, i32 1)
%16 = call i32 (...) @decdwl()
%17 = call i32 @cup(i32 8, i32 1)
%18 = call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 (...) @holdit()
%20 = call i32 @cup(i32 15, i32 1)
%21 = call i32 (...) @decswl()
%22 = call i32 @cup(i32 11, i32 1)
%23 = call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 (...) @holdit()
%25 = call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 @ed(i32 2)
%27 = call i32 @cup(i32 15, i32 1)
%28 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%32 = call i32 @cup(i32 1, i32 1)
%33 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%34 = call i32 @cup(i32 5, i32 1)
%35 = call i32 @println(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.12, i64 0, i64 0))
%36 = call i32 (...) @holdit()
%37 = call i32 @cup(i32 15, i32 1)
%38 = call i32 (...) @decdwl()
%39 = call i32 @cup(i32 8, i32 1)
%40 = call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0))
%41 = call i32 (...) @holdit()
%42 = call i32 @cup(i32 15, i32 1)
%43 = call i32 (...) @decswl()
%44 = call i32 @cup(i32 11, i32 1)
%45 = call i32 @println(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.12, i64 0, i64 0))
%46 = call i32 (...) @holdit()
%47 = call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [41 x i8] c"This-is-a-long-line-This-is-a-long-line-\00"
@.str.1 = [65 x i8] c"This is a test of what happens to the right half of double-width\00"
@.str.2 = [8 x i8] c" lines.\00"
@.str.3 = [62 x i8] c"A common misfeature is that the right half does not come back\00"
@.str.4 = [13 x i8] c" when a long\00"
@.str.5 = [59 x i8] c"single-width line is set to double-width and then reset to\00"
@.str.6 = [15 x i8] c" single-width.\00"
@.str.7 = [65 x i8] c"Now the line below should contain 80 characters in single width.\00"
@.str.8 = [65 x i8] c"Now the line below should contain 40 characters in double width.\00"
@.str.9 = [3 x i8] c"?3\00"
@.str.10 = [13 x i8] c"ending-here-\00"
@.str.11 = [42 x i8] c"This is the same test in 132 column mode.\00"
@.str.12 = [66 x i8] c"Now the line below should contain 132 characters in single width.\00"
@.str.13 = [65 x i8] c"Now the line below should contain 66 characters in double width.\00"
define i32 @bug_l() {
%1 = tail call i32 @cup(i32 15, i32 1)
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @cup(i32 1, i32 1)
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @println(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @println(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%11 = tail call i32 @cup(i32 5, i32 1)
%12 = tail call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
%13 = tail call i32 (...) @holdit()
%14 = tail call i32 @cup(i32 15, i32 1)
%15 = tail call i32 (...) @decdwl()
%16 = tail call i32 @cup(i32 8, i32 1)
%17 = tail call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
%18 = tail call i32 (...) @holdit()
%19 = tail call i32 @cup(i32 15, i32 1)
%20 = tail call i32 (...) @decswl()
%21 = tail call i32 @cup(i32 11, i32 1)
%22 = tail call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
%23 = tail call i32 (...) @holdit()
%24 = tail call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%25 = tail call i32 @ed(i32 2)
%26 = tail call i32 @cup(i32 15, i32 1)
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%30 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%31 = tail call i32 @cup(i32 1, i32 1)
%32 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%33 = tail call i32 @cup(i32 5, i32 1)
%34 = tail call i32 @println(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.12, i64 0, i64 0))
%35 = tail call i32 (...) @holdit()
%36 = tail call i32 @cup(i32 15, i32 1)
%37 = tail call i32 (...) @decdwl()
%38 = tail call i32 @cup(i32 8, i32 1)
%39 = tail call i32 @println(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0))
%40 = tail call i32 (...) @holdit()
%41 = tail call i32 @cup(i32 15, i32 1)
%42 = tail call i32 (...) @decswl()
%43 = tail call i32 @cup(i32 11, i32 1)
%44 = tail call i32 @println(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.12, i64 0, i64 0))
%45 = tail call i32 (...) @holdit()
%46 = tail call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
ret i32 undef
}