#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int tgetent(char *, char *);
scalar_t__ tgetflag(char *);
int tgetnum(char *);
char *tgetstr(char *, char *);
char *tgoto(char *, int, int);
int /*<<< orphan*/ tputs(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char termbuf[1024];
  char string[256], *pstr;
  char *term;
  int i;
  int excode = 0;
  if ((term = getenv("TERM")) == 0) {
    fprintf(stderr, "tget: $TERM is not set\n");
    exit(-1);
  }
  if (tgetent(termbuf, term) != 1) {
    fprintf(stderr, "tget: no termcap entry for '%s'\n", term);
    exit(-1);
  }
  for (i = 1; i < argc; i++) {
    char *option = argv[i];
    char *id;
    if (option[0] != '-') {
      fputs(option, stdout);
      continue;
    }
    if (++i == argc)
      usage();
    id = argv[i];
    if (strcmp(option, "-flag") == 0) {
      excode = tgetflag(id) ? 0 : 1;
    } else if (strcmp(option, "-num") == 0) {
      int num;
      if ((num = tgetnum(id)) == -1) {
        excode = 1;
      } else {
        excode = 0;
        printf("%d", num);
      }
    } else if (strcmp(option, "-str") == 0) {
      char *str;
      if ((str = tgetstr(id, (pstr = string, &pstr))) == 0) {
        excode = 1;
      } else {
        excode = 0;
        tputs(str, 0, putchar);
      }
    } else if (strcmp(option, "-goto") == 0) {
      char *cm;
      int col, line;
      col = atoi(id);
      if (++i == argc)
        usage();
      line = atoi(argv[i]);
      if ((cm = tgetstr("cm", (pstr = string, &pstr))) == 0) {
        excode = 1;
      } else {
        excode = 0;
        tputs(tgoto(cm, col, line), 0, putchar);
      }
    } else if (strcmp(option, "-echo") == 0) {
      fputs(id, stdout);
    } else {
      usage();
    }
  }
  exit(excode);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x560,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x528(%rbp)
lea    0xdf6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x520(%rbp)
cmp    $0x0,%rax
jne    1241 <main+0x61>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    -0x410(%rbp),%rdi
mov    -0x520(%rbp),%rsi
call   1090 <tgetent@plt>
cmp    $0x1,%eax
je     1285 <main+0xa5>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    -0x520(%rbp),%rdx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
movl   $0x1,-0x524(%rbp)
mov    -0x524(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1595 <main+0x3b5>
mov    -0x10(%rbp),%rax
movslq -0x524(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x530(%rbp)
mov    -0x530(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     12e1 <main+0x101>
mov    -0x530(%rbp),%rdi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs@plt>
jmp    1581 <main+0x3a1>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
cmp    -0x8(%rbp),%eax
jne    1300 <main+0x120>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
movslq -0x524(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x538(%rbp)
mov    -0x530(%rbp),%rdi
lea    0xd1a(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    135b <main+0x17b>
mov    -0x538(%rbp),%rdi
call   1080 <tgetflag@plt>
mov    %rax,%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x528(%rbp)
jmp    157c <main+0x39c>
mov    -0x530(%rbp),%rdi
lea    0xcdb(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    13c3 <main+0x1e3>
mov    -0x538(%rbp),%rdi
call   10a0 <tgetnum@plt>
mov    %eax,-0x53c(%rbp)
cmp    $0xffffffff,%eax
jne    13a2 <main+0x1c2>
movl   $0x1,-0x528(%rbp)
jmp    13be <main+0x1de>
movl   $0x0,-0x528(%rbp)
mov    -0x53c(%rbp),%esi
lea    0xc90(%rip),%rdi
call   1060 <printf@plt>
jmp    1577 <main+0x397>
mov    -0x530(%rbp),%rdi
lea    0xc7b(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1447 <main+0x267>
mov    -0x538(%rbp),%rdi
lea    -0x510(%rbp),%rax
mov    %rax,-0x518(%rbp)
lea    -0x518(%rbp),%rsi
call   10e0 <tgetstr@plt>
mov    %rax,-0x548(%rbp)
cmp    $0x0,%rax
jne    1421 <main+0x241>
movl   $0x1,-0x528(%rbp)
jmp    1442 <main+0x262>
movl   $0x0,-0x528(%rbp)
mov    -0x548(%rbp),%rdi
mov    0x2b9f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <tputs@plt>
jmp    1572 <main+0x392>
mov    -0x530(%rbp),%rdi
lea    0xbfc(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    152a <main+0x34a>
mov    -0x538(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x554(%rbp)
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
cmp    -0x8(%rbp),%eax
jne    1495 <main+0x2b5>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
movslq -0x524(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x558(%rbp)
lea    -0x510(%rbp),%rax
mov    %rax,-0x518(%rbp)
lea    -0x518(%rbp),%rsi
lea    0xb8c(%rip),%rdi
call   10e0 <tgetstr@plt>
mov    %rax,-0x550(%rbp)
cmp    $0x0,%rax
jne    14f0 <main+0x310>
movl   $0x1,-0x528(%rbp)
jmp    1525 <main+0x345>
movl   $0x0,-0x528(%rbp)
mov    -0x550(%rbp),%rdi
mov    -0x554(%rbp),%esi
mov    -0x558(%rbp),%edx
call   1050 <tgoto@plt>
mov    %rax,%rdi
mov    0x2abc(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <tputs@plt>
jmp    156d <main+0x38d>
mov    -0x530(%rbp),%rdi
lea    0xb22(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1561 <main+0x381>
mov    -0x538(%rbp),%rdi
mov    0x2a7b(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs@plt>
jmp    1568 <main+0x388>
mov    $0x0,%al
call   10d0 <usage@plt>
jmp    156d <main+0x38d>
jmp    1572 <main+0x392>
jmp    1577 <main+0x397>
jmp    157c <main+0x39c>
jmp    1581 <main+0x3a1>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    128f <main+0xaf>
mov    -0x528(%rbp),%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x518,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe03(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1228 <main+0x48>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    %rax,%r14
lea    0x110(%rsp),%rdi
mov    %rax,%rsi
call   1090 <tgetent@plt>
cmp    $0x1,%eax
jne    1455 <main+0x275>
movl   $0x0,0x4(%rsp)
cmp    $0x2,%ebp
jl     1479 <main+0x299>
mov    $0x1,%r14d
movl   $0x0,0x4(%rsp)
jmp    128e <main+0xae>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1070 <fputs@plt>
add    $0x1,%r14d
cmp    %ebp,%r14d
jge    1479 <main+0x299>
movslq %r14d,%rax
mov    (%rbx,%rax,8),%r13
cmpb   $0x2d,0x0(%r13)
jne    1270 <main+0x90>
lea    0x1(%r14),%r12d
cmp    %ebp,%r12d
jne    12ac <main+0xcc>
xor    %eax,%eax
call   10d0 <usage@plt>
movslq %r12d,%rax
mov    (%rbx,%rax,8),%r15
mov    %r13,%rdi
lea    0xd81(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     132b <main+0x14b>
mov    %r13,%rdi
lea    0xd73(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1344 <main+0x164>
mov    %r13,%rdi
lea    0xd67(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     136c <main+0x18c>
mov    %r13,%rdi
lea    0xd58(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     13b5 <main+0x1d5>
mov    %r13,%rdi
lea    0xd49(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     142d <main+0x24d>
xor    %eax,%eax
call   10d0 <usage@plt>
jmp    1440 <main+0x260>
mov    %r15,%rdi
call   1080 <tgetflag@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,0x4(%rsp)
jmp    1440 <main+0x260>
mov    %r15,%rdi
call   10a0 <tgetnum@plt>
cmp    $0xffffffff,%eax
je     13a8 <main+0x1c8>
lea    0xcf1(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
movl   $0x0,0x4(%rsp)
jmp    1440 <main+0x260>
lea    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   10e0 <tgetstr@plt>
test   %rax,%rax
je     13a8 <main+0x1c8>
mov    0x2c49(%rip),%rcx
mov    (%rcx),%edx
movl   $0x0,0x4(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <tputs@plt>
jmp    1440 <main+0x260>
movl   $0x1,0x4(%rsp)
jmp    1440 <main+0x260>
mov    %r15,%rdi
call   10f0 <atoi@plt>
mov    %eax,%r15d
add    $0x2,%r14d
cmp    %ebp,%r14d
jne    13d0 <main+0x1f0>
xor    %eax,%eax
call   10d0 <usage@plt>
movslq %r14d,%rax
mov    (%rbx,%rax,8),%rdi
call   10f0 <atoi@plt>
mov    %eax,%r12d
lea    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0xc67(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10e0 <tgetstr@plt>
test   %rax,%rax
je     1448 <main+0x268>
mov    %rax,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
call   1050 <tgoto@plt>
mov    0x2bc4(%rip),%rcx
mov    (%rcx),%edx
movl   $0x0,0x4(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <tputs@plt>
jmp    1281 <main+0xa1>
mov    0x2b9c(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1070 <fputs@plt>
xchg   %ax,%ax
mov    %r12d,%r14d
jmp    1281 <main+0xa1>
movl   $0x1,0x4(%rsp)
jmp    1281 <main+0xa1>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
lea    0xbb8(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    0x4(%rsp),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"TERM\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"tget: $TERM is not set\0A\00"
@.str.2 = [33 x i8] c"tget: no termcap entry for '%s'\0A\00"
@stdout = global i32 0
@.str.3 = [6 x i8] c"-flag\00"
@.str.4 = [5 x i8] c"-num\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [5 x i8] c"-str\00"
@putchar = global i32 0
@.str.7 = [6 x i8] c"-goto\00"
@.str.8 = [3 x i8] c"cm\00"
@.str.9 = [6 x i8] c"-echo\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
%19 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %9
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %2
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = load i8*, i8** %9
%28 = call i32 @tgetent(i8* %26, i8* %27)
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %9
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %25
store i32 1, i32* %10
br label %36
36: ; preds = %154, %35
%37 = load i32, i32* %10
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %157
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
store i8* %45, i8** %12
%46 = load i8*, i8** %12
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 45
br i1 %50, label %51, label %55
51: ; preds = %40
%52 = load i8*, i8** %12
%53 = load i32, i32* @stdout
%54 = call i32 @fputs(i8* %52, i32 %53)
br label %154
55: ; preds = %40
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
%58 = load i32, i32* %4
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 (...) @usage()
br label %62
62: ; preds = %60, %55
%63 = load i8**, i8*** %5
%64 = load i32, i32* %10
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
store i8* %67, i8** %13
%68 = load i8*, i8** %12
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %62
%72 = load i8*, i8** %13
%73 = call i64 @tgetflag(i8* %72)
%74 = icmp ne i64 %73, 0
%75 = zext i1 %74 to i64
%76 = select i1 %74, i32 0, i32 1
store i32 %76, i32* %11
br label %153
77: ; preds = %62
%78 = load i8*, i8** %12
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %90
81: ; preds = %77
%82 = load i8*, i8** %13
%83 = call i32 @tgetnum(i8* %82)
store i32 %83, i32* %14
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %86
85: ; preds = %81
store i32 1, i32* %11
br label %89
86: ; preds = %81
store i32 0, i32* %11
%87 = load i32, i32* %14
%88 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %87)
br label %89
89: ; preds = %86, %85
br label %152
90: ; preds = %77
%91 = load i8*, i8** %12
%92 = call i64 @strcmp(i8* %91, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %106
94: ; preds = %90
%95 = load i8*, i8** %13
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8* %96, i8** %8
%97 = bitcast i8** %8 to i8*
%98 = call i8* @tgetstr(i8* %95, i8* %97)
store i8* %98, i8** %15
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %101
100: ; preds = %94
store i32 1, i32* %11
br label %105
101: ; preds = %94
store i32 0, i32* %11
%102 = load i8*, i8** %15
%103 = load i32, i32* @putchar
%104 = call i32 @tputs(i8* %102, i32 0, i32 %103)
br label %105
105: ; preds = %101, %100
br label %151
106: ; preds = %90
%107 = load i8*, i8** %12
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %139
110: ; preds = %106
%111 = load i8*, i8** %13
%112 = call i32 @atoi(i8* %111)
store i32 %112, i32* %17
%113 = load i32, i32* %10
%114 = add nsw i32 %113, 1
store i32 %114, i32* %10
%115 = load i32, i32* %4
%116 = icmp eq i32 %114, %115
br i1 %116, label %117, label %119
117: ; preds = %110
%118 = call i32 (...) @usage()
br label %119
119: ; preds = %117, %110
%120 = load i8**, i8*** %5
%121 = load i32, i32* %10
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8*, i8** %120, i64 %122
%124 = load i8*, i8** %123
%125 = call i32 @atoi(i8* %124)
store i32 %125, i32* %18
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8* %126, i8** %8
%127 = bitcast i8** %8 to i8*
%128 = call i8* @tgetstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %127)
store i8* %128, i8** %16
%129 = icmp eq i8* %128, null
br i1 %129, label %130, label %131
130: ; preds = %119
store i32 1, i32* %11
br label %138
131: ; preds = %119
store i32 0, i32* %11
%132 = load i8*, i8** %16
%133 = load i32, i32* %17
%134 = load i32, i32* %18
%135 = call i8* @tgoto(i8* %132, i32 %133, i32 %134)
%136 = load i32, i32* @putchar
%137 = call i32 @tputs(i8* %135, i32 0, i32 %136)
br label %138
138: ; preds = %131, %130
br label %150
139: ; preds = %106
%140 = load i8*, i8** %12
%141 = call i64 @strcmp(i8* %140, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%142 = icmp eq i64 %141, 0
br i1 %142, label %143, label %147
143: ; preds = %139
%144 = load i8*, i8** %13
%145 = load i32, i32* @stdout
%146 = call i32 @fputs(i8* %144, i32 %145)
br label %149
147: ; preds = %139
%148 = call i32 (...) @usage()
br label %149
149: ; preds = %147, %143
br label %150
150: ; preds = %149, %138
br label %151
151: ; preds = %150, %105
br label %152
152: ; preds = %151, %89
br label %153
153: ; preds = %152, %71
br label %154
154: ; preds = %153, %51
%155 = load i32, i32* %10
%156 = add nsw i32 %155, 1
store i32 %156, i32* %10
br label %36
157: ; preds = %36
%158 = load i32, i32* %11
%159 = call i32 @exit(i32 %158)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"TERM\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"tget: $TERM is not set\0A\00"
@.str.2 = [33 x i8] c"tget: no termcap entry for '%s'\0A\00"
@stdout = global i32 0
@.str.3 = [6 x i8] c"-flag\00"
@.str.4 = [5 x i8] c"-num\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [5 x i8] c"-str\00"
@putchar = global i32 0
@.str.7 = [6 x i8] c"-goto\00"
@.str.8 = [3 x i8] c"cm\00"
@.str.9 = [6 x i8] c"-echo\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [256 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = bitcast i8** %5 to i8*
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = call i32 @tgetent(i8* %6, i8* %9)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = icmp sgt i32 %0, 1
br i1 %19, label %24, label %100
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %18, %95
%25 = phi i32 [ %98, %95 ], [ 1, %18 ]
%26 = phi i32 [ %96, %95 ], [ 0, %18 ]
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 45
br i1 %31, label %35, label %32
32: ; preds = %24
%33 = load i32, i32* @stdout
%34 = call i32 @fputs(i8* %29, i32 %33)
br label %95
35: ; preds = %24
%36 = add nsw i32 %25, 1
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %38, %35
%41 = sext i32 %36 to i64
%42 = getelementptr inbounds i8*, i8** %1, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %40
%47 = call i64 @tgetflag(i8* %43)
%48 = icmp eq i64 %47, 0
%49 = zext i1 %48 to i32
br label %95
50: ; preds = %40
%51 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = call i32 @tgetnum(i8* %43)
%55 = icmp eq i32 %54, -1
br i1 %55, label %95, label %56
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %54)
br label %95
58: ; preds = %50
%59 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %67
61: ; preds = %58
store i8* %7, i8** %5
%62 = call i8* @tgetstr(i8* %43, i8* %8)
%63 = icmp eq i8* %62, null
br i1 %63, label %95, label %64
64: ; preds = %61
%65 = load i32, i32* @putchar
%66 = call i32 @tputs(i8* %62, i32 0, i32 %65)
br label %95
67: ; preds = %58
%68 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %87
70: ; preds = %67
%71 = call i32 @atoi(i8* %43)
%72 = add nsw i32 %25, 2
%73 = icmp eq i32 %72, %0
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 (...) @usage()
br label %76
76: ; preds = %74, %70
%77 = sext i32 %72 to i64
%78 = getelementptr inbounds i8*, i8** %1, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 @atoi(i8* %79)
store i8* %7, i8** %5
%81 = call i8* @tgetstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%82 = icmp eq i8* %81, null
br i1 %82, label %95, label %83
83: ; preds = %76
%84 = call i8* @tgoto(i8* %81, i32 %71, i32 %80)
%85 = load i32, i32* @putchar
%86 = call i32 @tputs(i8* %84, i32 0, i32 %85)
br label %95
87: ; preds = %67
%88 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i32, i32* @stdout
%92 = call i32 @fputs(i8* %43, i32 %91)
br label %95
93: ; preds = %87
%94 = call i32 (...) @usage()
br label %95
95: ; preds = %46, %90, %93, %53, %56, %61, %64, %76, %83, %32
%96 = phi i32 [ %26, %32 ], [ %49, %46 ], [ %26, %90 ], [ %26, %93 ], [ 0, %56 ], [ 1, %53 ], [ 0, %64 ], [ 1, %61 ], [ 0, %83 ], [ 1, %76 ]
%97 = phi i32 [ %25, %32 ], [ %36, %46 ], [ %36, %90 ], [ %36, %93 ], [ %36, %56 ], [ %36, %53 ], [ %36, %64 ], [ %36, %61 ], [ %72, %83 ], [ %72, %76 ]
%98 = add nsw i32 %97, 1
%99 = icmp slt i32 %98, %0
br i1 %99, label %24, label %100
100: ; preds = %95, %18
%101 = phi i32 [ 0, %18 ], [ %96, %95 ]
%102 = call i32 @exit(i32 %101)
unreachable
}