#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 */
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ help();
int /*<<< orphan*/ list();
int /*<<< orphan*/ note();
int /*<<< orphan*/ punish();
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void interact() {
  char cmd[8] = {0};
  write(1, "> ", 2);
  read(0, cmd, sizeof(cmd) - 1);
  if (!strncmp(cmd, "help", 4)) {
    help();
  } else if (!strncmp(cmd, "list", 4)) {
    list();
  } else if (!strncmp(cmd, "note", 4)) {
    note();
  } else if (!strncmp(cmd, "punish", 6)) {
    punish();
  } else if (!strncmp(cmd, "\n", 1)) {
  } else if (!strncmp(cmd, "exit", 4)) {
    exit(0);
  }
}


x86 assembly (clang, -O0):
<interact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    $0x1,%edi
lea    0xe4c(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    -0x8(%rbp),%rsi
xor    %edi,%edi
mov    $0x7,%edx
call   1060 <read@plt>
lea    -0x8(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11f8 <interact+0x68>
mov    $0x0,%al
call   10a0 <help@plt>
jmp    12d7 <interact+0x147>
lea    -0x8(%rbp),%rdi
lea    0xe05(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1222 <interact+0x92>
mov    $0x0,%al
call   1080 <list@plt>
jmp    12d2 <interact+0x142>
lea    -0x8(%rbp),%rdi
lea    0xde0(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    124c <interact+0xbc>
mov    $0x0,%al
call   1090 <note@plt>
jmp    12cd <interact+0x13d>
lea    -0x8(%rbp),%rdi
lea    0xdbb(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1276 <interact+0xe6>
mov    $0x0,%al
call   1070 <punish@plt>
jmp    12c8 <interact+0x138>
lea    -0x8(%rbp),%rdi
lea    0xd98(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1299 <interact+0x109>
jmp    12c3 <interact+0x133>
lea    -0x8(%rbp),%rdi
lea    0xd77(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12be <interact+0x12e>
xor    %edi,%edi
call   10b0 <exit@plt>
jmp    12c3 <interact+0x133>
jmp    12c8 <interact+0x138>
jmp    12cd <interact+0x13d>
jmp    12d2 <interact+0x142>
jmp    12d7 <interact+0x147>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interact>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe6b(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0x8(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1050 <read@plt>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     125d <interact+0xdd>
lea    0xe2d(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1266 <interact+0xe6>
lea    0xe18(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     126f <interact+0xef>
lea    0xe03(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1278 <interact+0xf8>
lea    0xdf0(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     127f <interact+0xff>
lea    0xdd8(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    127f <interact+0xff>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
call   1090 <help@plt>
jmp    127f <interact+0xff>
xor    %eax,%eax
call   1070 <list@plt>
jmp    127f <interact+0xff>
xor    %eax,%eax
call   1080 <note@plt>
jmp    127f <interact+0xff>
xor    %eax,%eax
call   1060 <punish@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [5 x i8] c"note\00"
@.str.4 = [7 x i8] c"punish\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [5 x i8] c"exit\00"
define void @interact() {
%1 = alloca [8 x i8]
%2 = bitcast [8 x i8]* %1 to i8*
%3 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%5 = call i32 @read(i32 0, i8* %4, i32 7)
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%7 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (...) @help()
br label %45
11: ; preds = %0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%13 = call i32 @strncmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 (...) @list()
br label %44
17: ; preds = %11
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%19 = call i32 @strncmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 (...) @note()
br label %43
23: ; preds = %17
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%25 = call i32 @strncmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = call i32 (...) @punish()
br label %42
29: ; preds = %23
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%31 = call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29
br label %41
34: ; preds = %29
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%36 = call i32 @strncmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %34
br label %41
41: ; preds = %40, %33
br label %42
42: ; preds = %41, %27
br label %43
43: ; preds = %42, %21
br label %44
44: ; preds = %43, %15
br label %45
45: ; preds = %44, %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [5 x i8] c"note\00"
@.str.4 = [7 x i8] c"punish\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [5 x i8] c"exit\00"
define void @interact() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = call i32 @read(i32 0, i8* %2, i32 7)
%5 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (...) @help()
br label %32
9: ; preds = %0
%10 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @list()
br label %32
14: ; preds = %9
%15 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (...) @note()
br label %32
19: ; preds = %14
%20 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @punish()
br label %32
24: ; preds = %19
%25 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %12, %22, %27, %24, %17, %7
ret void
}