#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*/ ed(int);
int /*<<< orphan*/ holdit();
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ rm(char *);
int /*<<< orphan*/ sm(char *);
bug_f() {
  int i, row, col;
  sm("?5");
  sm("?3");
  println("Test VT100 'Toggle origin mode, forget rest' bug, part 1.");
  println("The screen should be in reverse, 132 column mode.");
  holdit();
  ed(2);
  rm("?6;5;3");
  println("Test VT100 'Toggle origin mode, forget rest' bug, part 2.\n");
  println("The screen should be in non-reverse, 80 column mode.");
  holdit();
}


x86 assembly (clang, -O0):
<bug_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1060 <sm@plt>
lea    0xe98(%rip),%rdi
call   1060 <sm@plt>
lea    0xe8f(%rip),%rdi
call   1040 <println@plt>
lea    0xebd(%rip),%rdi
call   1040 <println@plt>
mov    $0x0,%al
call   1070 <holdit@plt>
mov    $0x2,%edi
call   1050 <ed@plt>
lea    0xed2(%rip),%rdi
call   1030 <rm@plt>
lea    0xecd(%rip),%rdi
call   1040 <println@plt>
lea    0xefc(%rip),%rdi
call   1040 <println@plt>
mov    $0x0,%al
call   1070 <holdit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bug_f>:
push   %rax
lea    0xea8(%rip),%rdi
call   1060 <sm@plt>
lea    0xe9f(%rip),%rdi
call   1060 <sm@plt>
lea    0xe96(%rip),%rdi
call   1040 <println@plt>
lea    0xec4(%rip),%rdi
call   1040 <println@plt>
xor    %eax,%eax
call   1070 <holdit@plt>
mov    $0x2,%edi
call   1050 <ed@plt>
lea    0xed9(%rip),%rdi
call   1030 <rm@plt>
lea    0xed4(%rip),%rdi
call   1040 <println@plt>
lea    0xf03(%rip),%rdi
call   1040 <println@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <holdit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"?5\00"
@.str.1 = [3 x i8] c"?3\00"
@.str.2 = [58 x i8] c"Test VT100 'Toggle origin mode, forget rest' bug, part 1.\00"
@.str.3 = [50 x i8] c"The screen should be in reverse, 132 column mode.\00"
@.str.4 = [7 x i8] c"?6;5;3\00"
@.str.5 = [59 x i8] c"Test VT100 'Toggle origin mode, forget rest' bug, part 2.\0A\00"
@.str.6 = [53 x i8] c"The screen should be in non-reverse, 80 column mode.\00"
define i32 @bug_f() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @println(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @println(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (...) @holdit()
%10 = call i32 @ed(i32 2)
%11 = call i32 @rm(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @println(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @println(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 (...) @holdit()
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [3 x i8] c"?5\00"
@.str.1 = [3 x i8] c"?3\00"
@.str.2 = [58 x i8] c"Test VT100 'Toggle origin mode, forget rest' bug, part 1.\00"
@.str.3 = [50 x i8] c"The screen should be in reverse, 132 column mode.\00"
@.str.4 = [7 x i8] c"?6;5;3\00"
@.str.5 = [59 x i8] c"Test VT100 'Toggle origin mode, forget rest' bug, part 2.\0A\00"
@.str.6 = [53 x i8] c"The screen should be in non-reverse, 80 column mode.\00"
define i32 @bug_f() {
%1 = tail call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @println(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @println(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (...) @holdit()
%6 = tail call i32 @ed(i32 2)
%7 = tail call i32 @rm(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @println(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @println(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i32 (...) @holdit()
ret i32 undef
}