#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*/ holdit();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ rm(char *);
int /*<<< orphan*/ sm(char *);
bug_e() {
  int i;
  static char *rend[2] = {"\033[m", "\033[7m"};
  sm("?3");
  cup(1, 1);
  decdwl();
  println("This test should put an 'X' at line 3 column 100.");
  for (i = 1; i <= 12; i++)
    printf("1234567890%s", rend[i & 1]);
  cup(1, 1);
  cup(3, 100);
  printf("X");
  cup(4, 66);
  printf("!                                 !");
  cup(5, 1);
  printf("--------------------------- The 'X' should NOT be above here -");
  printf("---+------------ but above here -----+");
  cup(10, 1);
  decdwl();
  holdit();
  rm("?3");
}


x86 assembly (clang, -O0):
<bug_e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe8a(%rip),%rdi
call   1080 <sm@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <cup@plt>
mov    $0x0,%al
call   1050 <decdwl@plt>
lea    0xe6e(%rip),%rdi
call   1060 <println@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jg     11e4 <bug_e+0x74>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
movslq %eax,%rcx
lea    0x2e9c(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11aa <bug_e+0x3a>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <cup@plt>
mov    $0x3,%edi
mov    $0x64,%esi
call   1070 <cup@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x42,%esi
call   1070 <cup@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1070 <cup@plt>
mov    $0x0,%al
call   1050 <decdwl@plt>
mov    $0x0,%al
call   1090 <holdit@plt>
lea    0xd90(%rip),%rdi
call   1030 <rm@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bug_e>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe7a(%rip),%r14
mov    %r14,%rdi
call   1090 <sm@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1080 <cup@plt>
xor    %eax,%eax
call   1060 <decdwl@plt>
lea    0xe58(%rip),%rdi
call   1070 <println@plt>
lea    0xe7e(%rip),%rbx
lea    0xe3d(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe25(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1080 <cup@plt>
mov    $0x3,%edi
mov    $0x64,%esi
call   1080 <cup@plt>
mov    $0x58,%edi
call   1030 <putchar@plt>
mov    $0x4,%edi
mov    $0x42,%esi
call   1080 <cup@plt>
lea    0xda3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1080 <cup@plt>
lea    0xdaa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1080 <cup@plt>
xor    %eax,%eax
call   1060 <decdwl@plt>
xor    %eax,%eax
call   10a0 <holdit@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <rm@plt>

LLVM IR (-O0):
@bug_e.rend = internal global [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0)]
@.str = [4 x i8] c"\1B[m\00"
@.str.1 = [5 x i8] c"\1B[7m\00"
@.str.2 = [3 x i8] c"?3\00"
@.str.3 = [50 x i8] c"This test should put an 'X' at line 3 column 100.\00"
@.str.4 = [13 x i8] c"1234567890%s\00"
@.str.5 = [2 x i8] c"X\00"
@.str.6 = [36 x i8] c"! !\00"
@.str.7 = [63 x i8] c"--------------------------- The 'X' should NOT be above here -\00"
@.str.8 = [39 x i8] c"---+------------ but above here -----+\00"
define i32 @bug_e() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @cup(i32 1, i32 1)
%5 = call i32 (...) @decdwl()
%6 = call i32 @println(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 12
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %2
%12 = and i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [2 x i8*], [2 x i8*]* @bug_e.rend, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %7
20: ; preds = %7
%21 = call i32 @cup(i32 1, i32 1)
%22 = call i32 @cup(i32 3, i32 100)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @cup(i32 4, i32 66)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @cup(i32 5, i32 1)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%29 = call i32 @cup(i32 10, i32 1)
%30 = call i32 (...) @decdwl()
%31 = call i32 (...) @holdit()
%32 = call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"\1B[m\00"
@.str.1 = [5 x i8] c"\1B[7m\00"
@.str.2 = [3 x i8] c"?3\00"
@.str.3 = [50 x i8] c"This test should put an 'X' at line 3 column 100.\00"
@.str.4 = [13 x i8] c"1234567890%s\00"
@.str.6 = [36 x i8] c"! !\00"
@.str.7 = [63 x i8] c"--------------------------- The 'X' should NOT be above here -\00"
@.str.8 = [39 x i8] c"---+------------ but above here -----+\00"
define i32 @bug_e() {
%1 = tail call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @cup(i32 1, i32 1)
%3 = tail call i32 (...) @decdwl()
%4 = tail call i32 @println(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @cup(i32 1, i32 1)
%18 = tail call i32 @cup(i32 3, i32 100)
%19 = tail call i32 @putchar(i32 88)
%20 = tail call i32 @cup(i32 4, i32 66)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%22 = tail call i32 @cup(i32 5, i32 1)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%25 = tail call i32 @cup(i32 10, i32 1)
%26 = tail call i32 (...) @decdwl()
%27 = tail call i32 (...) @holdit()
%28 = tail call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i32 undef
}