#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 *);
char *getenv(char *);
scalar_t__ gettermsize_unix();
int /*<<< orphan*/ settermheight(int);
int /*<<< orphan*/ settermwidth(int);
void gettermsize() {
  char *s;
  int w = 80;
  int h = 25;
  if (gettermsize_unix())
    return;
  if (s = getenv("COLUMNS"))
    w = atoi(s);
  if (s = getenv("LINES"))
    h = atoi(s);
  settermwidth(w);
  settermheight(h);
}


x86 assembly (clang, -O0):
<gettermsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x50,-0xc(%rbp)
movl   $0x19,-0x10(%rbp)
mov    $0x0,%al
call   1070 <gettermsize_unix@plt>
cmp    $0x0,%rax
je     117c <gettermsize+0x2c>
jmp    11d8 <gettermsize+0x88>
lea    0xe7d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11a2 <gettermsize+0x52>
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
lea    0xe5f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11c8 <gettermsize+0x78>
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <settermwidth@plt>
mov    -0x10(%rbp),%edi
call   1040 <settermheight@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettermsize>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <gettermsize_unix@plt>
test   %rax,%rax
je     1166 <gettermsize+0x16>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe93(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1183 <gettermsize+0x33>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
jmp    1188 <gettermsize+0x38>
mov    $0x50,%ebx
lea    0xe79(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11a5 <gettermsize+0x55>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
jmp    11aa <gettermsize+0x5a>
mov    $0x19,%ebp
mov    %ebx,%edi
call   1060 <settermwidth@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <settermheight@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"COLUMNS\00"
@.str.1 = [6 x i8] c"LINES\00"
define void @gettermsize() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
store i32 80, i32* %2
store i32 25, i32* %3
%4 = call i64 (...) @gettermsize_unix()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
br label %24
7: ; preds = %0
%8 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %1
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i8*, i8** %1
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %2
br label %13
13: ; preds = %10, %7
%14 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %1
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i8*, i8** %1
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %2
%21 = call i32 @settermwidth(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @settermheight(i32 %22)
br label %24
24: ; preds = %19, %6
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"COLUMNS\00"
@.str.1 = [6 x i8] c"LINES\00"
define void @gettermsize() {
%1 = tail call i64 (...) @gettermsize_unix()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %18
3: ; preds = %0
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @atoi(i8* %4)
br label %8
8: ; preds = %6, %3
%9 = phi i32 [ %7, %6 ], [ 80, %3 ]
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @atoi(i8* %10)
br label %14
14: ; preds = %12, %8
%15 = phi i32 [ %13, %12 ], [ 25, %8 ]
%16 = tail call i32 @settermwidth(i32 %9)
%17 = tail call i32 @settermheight(i32 %15)
br label %18
18: ; preds = %0, %14
ret void
}