#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ system(char *);
int term(int t) {
  switch (t) {
  case 1:
    system("/bin/stty cooked");
    system("/bin/stty echo");
    printf("\f\nnormal termination\n\n");
    exit(1);
    break;
  case 2:
    system("/bin/stty cooked");
    system("/bin/stty echo");
    printf("\f\nescape termination\n\n");
    exit(1);
    break;
  default:
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     1160 <term+0x30>
jmp    114f <term+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     118e <term+0x5e>
jmp    11bc <term+0x8c>
lea    0xe99(%rip),%rdi
call   1030 <system@plt>
lea    0xe9e(%rip),%rdi
call   1030 <system@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe6b(%rip),%rdi
call   1030 <system@plt>
lea    0xe70(%rip),%rdi
call   1030 <system@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11c1 <term+0x91>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term>:
push   %rax
cmp    $0x2,%edi
je     1142 <term+0x12>
cmp    $0x1,%edi
je     1163 <term+0x33>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xeb7(%rip),%rdi
call   1040 <system@plt>
lea    0xebc(%rip),%rdi
call   1040 <system@plt>
lea    0xebf(%rip),%rdi
jmp    1182 <term+0x52>
lea    0xe96(%rip),%rdi
call   1040 <system@plt>
lea    0xe9b(%rip),%rdi
call   1040 <system@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/bin/stty cooked\00"
@.str.1 = [15 x i8] c"/bin/stty echo\00"
@.str.2 = [23 x i8] c"\0C\0Anormal termination\0A\0A\00"
@.str.3 = [23 x i8] c"\0C\0Aescape termination\0A\0A\00"
define i32 @term(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %14 [
i32 1, label %4
i32 2, label %9
]
4: ; preds = %1
%5 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
br label %15
15: ; preds = %14
ret i32 1
}

LLVM IR (-O2):
@.str = [17 x i8] c"/bin/stty cooked\00"
@.str.1 = [15 x i8] c"/bin/stty echo\00"
@str = [22 x i8] c"\0C\0Aescape termination\0A\00"
@str.4 = [22 x i8] c"\0C\0Anormal termination\0A\00"
define i32 @term(i32 %0) {
switch i32 %0, label %12 [
i32 1, label %2
i32 2, label %7
]
2: ; preds = %1
%3 = tail call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1
ret i32 1
}