#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*/ printf(char *);
int /*<<< orphan*/ setupterm(int /*<<< orphan*/ *, int, int *);
char *tigetstr(char *);
char *tparm(char *, int, int);
int /*<<< orphan*/ tputs(char *, int, int /*<<< orphan*/ *);
int main() {
  setupterm(NULL, 1, (int *)0);
  printf("begin");
  char *cursor;
  char *esc_sequence;
  cursor = tigetstr("cup");
  esc_sequence = tparm(cursor, 5, 30);
  tputs(esc_sequence, 1, NULL);
  printf("done");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edx
mov    $0x1,%esi
mov    %rdx,%rdi
call   1030 <setupterm@plt>
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
mov    $0x1e,%edx
call   1060 <tparm@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <tputs@plt>
lea    0xe55(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <setupterm@plt>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %rax,%rdi
mov    $0x5,%esi
mov    $0x1e,%edx
call   1060 <tparm@plt>
mov    %rax,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <tputs@plt>
lea    0xe6b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"begin\00"
@.str.1 = [4 x i8] c"cup\00"
@.str.2 = [5 x i8] c"done\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i32 @setupterm(i32* null, i32 1, i32* null)
%4 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i8* @tigetstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = call i8* @tparm(i8* %6, i32 5, i32 30)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @tputs(i8* %8, i32 1, i32* null)
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"begin\00"
@.str.1 = [4 x i8] c"cup\00"
@.str.2 = [5 x i8] c"done\00"
define i32 @main() {
%1 = tail call i32 @setupterm(i32* null, i32 1, i32* null)
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @tigetstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @tparm(i8* %3, i32 5, i32 30)
%5 = tail call i32 @tputs(i8* %4, i32 1, i32* null)
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}