#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 *, char *);
int /*<<< orphan*/ setupterm(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *);
char *str(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ tigetstr(char *);
int main() {
  system("echo \"TERM  = $TERM\"");
  setupterm(NULL, 1, NULL);
  printf("cup   = %s\n", str(tigetstr("cup")));
  printf("smcup = %s\n", str(tigetstr("smcup")));
  printf("rmcup = %s\n", str(tigetstr("rmcup")));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
mov    %eax,%edx
mov    $0x1,%esi
mov    %rdx,%rdi
call   1030 <setupterm@plt>
lea    0xebe(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
mov    %rax,%rsi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
mov    %rax,%rsi
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
mov    %rax,%rsi
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1040 <system@plt>
xor    %edi,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <setupterm@plt>
lea    0xecf(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
lea    0xe90(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
lea    0xe7a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe89(%rip),%rdi
call   1070 <tigetstr@plt>
mov    %eax,%edi
call   1060 <str@plt>
lea    0xe6a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"echo \22TERM = $TERM\22\00"
@.str.1 = [12 x i8] c"cup = %s\0A\00"
@.str.2 = [4 x i8] c"cup\00"
@.str.3 = [12 x i8] c"smcup = %s\0A\00"
@.str.4 = [6 x i8] c"smcup\00"
@.str.5 = [12 x i8] c"rmcup = %s\0A\00"
@.str.6 = [6 x i8] c"rmcup\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @setupterm(i32* null, i32 1, i32* null)
%4 = call i32 @tigetstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = call i8* @str(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%8 = call i8* @str(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%11 = call i8* @str(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"echo \22TERM = $TERM\22\00"
@.str.1 = [12 x i8] c"cup = %s\0A\00"
@.str.2 = [4 x i8] c"cup\00"
@.str.3 = [12 x i8] c"smcup = %s\0A\00"
@.str.4 = [6 x i8] c"smcup\00"
@.str.5 = [12 x i8] c"rmcup = %s\0A\00"
@.str.6 = [6 x i8] c"rmcup\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @setupterm(i32* null, i32 1, i32* null)
%3 = tail call i32 @tigetstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i8* @str(i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = tail call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i8* @str(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = tail call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i8* @str(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %10)
ret i32 0
}