#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*/ 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();
  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    115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1181 <main+0x51>
mov    $0x0,%al
call   1050 <setTerm@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe74(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <main+0x76>
mov    $0x0,%al
call   1040 <restoreTerm@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     117c <main+0x4c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    115c <main+0x2c>
xor    %eax,%eax
call   1050 <setTerm@plt>
mov    0x8(%rbx),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    117c <main+0x4c>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <restoreTerm@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"set\00"
@.str.1 = [8 x i8] c"restore\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 %26
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 ([4 x i8], [4 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 ([8 x i8], [8 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
store i32 0, i32* %3
br label %26
26: ; preds = %25, %8
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [4 x i8] c"set\00"
@.str.1 = [8 x i8] c"restore\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %17, 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 ([4 x i8], [4 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 ([8 x i8], [8 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 = %11, %15, %2
%18 = phi i32 [ -1, %2 ], [ 0, %15 ], [ 0, %11 ]
ret i32 %18
}