char *tgoto(cm, destcol, destrow)
char *cm;
int destcol;
int destrow;
{
  static char buf[30];
  if (cm[1] == 'Y' || cm[1] == '=')
    sprintf(buf, "\033%c%c%c", cm[1], ' ' + destrow, ' ' + destcol);
  else
    sprintf(buf, "\033[%d;%dH", destrow + 1, destcol + 1);
  return buf;
}


x86 assembly (clang, -O0):
<tgoto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x59,%eax
je     1144 <tgoto+0x34>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3d,%eax
jne    1174 <tgoto+0x64>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edx
mov    -0x10(%rbp),%ecx
add    $0x20,%ecx
mov    -0xc(%rbp),%r8d
add    $0x20,%r8d
lea    0x2edf(%rip),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1195 <tgoto+0x85>
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
lea    0x2eb9(%rip),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2ea4(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgoto>:
push   %rax
mov    %edx,%ecx
mov    %esi,%r8d
movzbl 0x1(%rdi),%edx
cmp    $0x59,%edx
je     1124 <tgoto+0x14>
cmp    $0x3d,%dl
jne    1142 <tgoto+0x32>
add    $0x20,%ecx
add    $0x20,%r8d
lea    0x2f0e(%rip),%rdi
lea    0xec7(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1163 <tgoto+0x53>
add    $0x1,%ecx
add    $0x1,%r8d
lea    0x2ef0(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    %ecx,%edx
mov    %r8d,%ecx
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2ed6(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@tgoto.buf = internal global [30 x i8] zeroinitializer
@.str = [8 x i8] c"\1B%c%c%c\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
define i8* @tgoto(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 89
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 61
br i1 %17, label %18, label %28
18: ; preds = %12, %3
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i32, i32* %6
%24 = add nsw i32 32, %23
%25 = load i32, i32* %5
%26 = add nsw i32 32, %25
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %24, i32 %26)
br label %34
28: ; preds = %12
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %32)
br label %34
34: ; preds = %28, %18
ret i8* getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@tgoto.buf = internal global [30 x i8] zeroinitializer
@.str = [8 x i8] c"\1B%c%c%c\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
define i8* @tgoto(i8* nocapture %0, i32 %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
switch i8 %5, label %11 [
i8 89, label %6
i8 61, label %6
]
6: ; preds = %3, %3
%7 = zext i8 %5 to i32
%8 = add nsw i32 %2, 32
%9 = add nsw i32 %1, 32
%10 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
br label %15
11: ; preds = %3
%12 = add nsw i32 %2, 1
%13 = add nsw i32 %1, 1
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
br label %15
15: ; preds = %11, %6
ret i8* getelementptr inbounds ([30 x i8], [30 x i8]* @tgoto.buf, i64 0, i64 0)
}