#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*/ restoreTerm();
int /*<<< orphan*/ setTerm();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2)
    return -1;
  if (strcmp(argv[1], "--set") == 0)
    setTerm();
  if (strcmp(argv[1], "--restore") == 0)
    restoreTerm();
  if (strcmp(argv[1], "--help") == 0) {
    printf("terminal tweaks\n");
    printf("--set       set non-buffered keyboard input\n");
    printf("--restore   revert to default settings\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1191 <main+0x51>
mov    $0x0,%al
call   1060 <setTerm@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b6 <main+0x76>
mov    $0x0,%al
call   1050 <restoreTerm@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xb8>
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
cmp    $0x2,%edi
jl     11c3 <main+0x83>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    116c <main+0x2c>
xor    %eax,%eax
call   1060 <setTerm@plt>
mov    0x8(%rbx),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1188 <main+0x48>
xor    %eax,%eax
call   1050 <restoreTerm@plt>
mov    0x8(%rbx),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11c3 <main+0x83>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"--set\00"
@.str.1 = [10 x i8] c"--restore\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [17 x i8] c"terminal tweaks\0A\00"
@.str.4 = [45 x i8] c"--set set non-buffered keyboard input\0A\00"
@.str.5 = [40 x i8] c"--restore revert to default settings\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %36
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (...) @setTerm()
br label %17
17: ; preds = %15, %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 (...) @restoreTerm()
br label %25
25: ; preds = %23, %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %31, %25
store i32 0, i32* %3
br label %36
36: ; preds = %35, %8
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"--set\00"
@.str.1 = [10 x i8] c"--restore\00"
@.str.2 = [7 x i8] c"--help\00"
@str = [16 x i8] c"terminal tweaks\00"
@str.6 = [44 x i8] c"--set set non-buffered keyboard input\00"
@str.7 = [39 x i8] c"--restore revert to default settings\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 (...) @setTerm()
br label %11
11: ; preds = %9, %4
%12 = load i8*, i8** %5
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 (...) @restoreTerm()
br label %17
17: ; preds = %15, %11
%18 = load i8*, i8** %5
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
br label %25
25: ; preds = %17, %21, %2
%26 = phi i32 [ -1, %2 ], [ 0, %21 ], [ 0, %17 ]
ret i32 %26
}