#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ process_array(char *, char *);
int /*<<< orphan*/ process_quad(char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strstr(char *, char *);
int /*<<< orphan*/ usage(int, char **);
int /*<<< orphan*/ visual_demo(char **);
int main(int argc, char *argv[]) {
  int res = 0;
  if (argc == 3) {
    visual_demo(argv);
  } else if (argc == 5) {
    freopen(argv[4], "w", stdout);
    if (!strstr(argv[1], "-d")) {
      process_quad(argv[2], argv[3]);
    } else if (!strstr(argv[1], "-q")) {
      process_array(argv[2], argv[3]);
    } else {
      usage(argc, argv);
    }
  } else {
    usage(argc, argv);
    res = -1;
  }
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1195 <main+0x35>
mov    -0x10(%rbp),%rdi
call   1060 <visual_demo@plt>
jmp    1258 <main+0xf8>
cmpl   $0x5,-0x8(%rbp)
jne    1240 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
lea    0xe49(%rip),%rsi
call   1030 <freopen@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%eax
jne    11f3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <process_quad@plt>
jmp    123b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%eax
jne    122a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1080 <process_array@plt>
jmp    1236 <main+0xd6>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <usage@plt>
jmp    123b <main+0xdb>
jmp    1253 <main+0xf3>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <usage@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1258 <main+0xf8>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x5,%edi
je     1178 <main+0x18>
cmp    $0x3,%edi
jne    11c8 <main+0x68>
mov    %rbx,%rdi
call   1060 <visual_demo@plt>
jmp    11f3 <main+0x93>
mov    0x20(%rbx),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
lea    0xe74(%rip),%rsi
call   1030 <freopen@plt>
mov    0x8(%rbx),%rdi
lea    0xe66(%rip),%rsi
call   1070 <strstr@plt>
test   %eax,%eax
je     11d7 <main+0x77>
mov    0x8(%rbx),%rdi
lea    0xe55(%rip),%rsi
call   1070 <strstr@plt>
test   %eax,%eax
je     11e6 <main+0x86>
mov    $0x5,%edi
mov    %rbx,%rsi
call   1050 <usage@plt>
jmp    11f3 <main+0x93>
mov    %rbx,%rsi
call   1050 <usage@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <process_quad@plt>
jmp    11f3 <main+0x93>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1080 <process_array@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [3 x i8] c"-q\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = call i32 @visual_demo(i8** %10)
br label %59
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 5
br i1 %14, label %15, label %54
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 4
%18 = load i8*, i8** %17
%19 = load i32, i32* @stdout
%20 = call i32 @freopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strstr(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @process_quad(i8* %29, i8* %32)
br label %53
34: ; preds = %15
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @strstr(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %48, label %40
40: ; preds = %34
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 3
%46 = load i8*, i8** %45
%47 = call i32 @process_array(i8* %43, i8* %46)
br label %52
48: ; preds = %34
%49 = load i32, i32* %4
%50 = load i8**, i8*** %5
%51 = call i32 @usage(i32 %49, i8** %50)
br label %52
52: ; preds = %48, %40
br label %53
53: ; preds = %52, %26
br label %58
54: ; preds = %12
%55 = load i32, i32* %4
%56 = load i8**, i8*** %5
%57 = call i32 @usage(i32 %55, i8** %56)
store i32 -1, i32* %6
br label %58
58: ; preds = %54, %53
br label %59
59: ; preds = %58, %9
%60 = load i32, i32* %6
ret i32 %60
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [3 x i8] c"-q\00"
define i32 @main(i32 %0, i8** %1) {
switch i32 %0, label %32 [
i32 3, label %3
i32 5, label %5
]
3: ; preds = %2
%4 = tail call i32 @visual_demo(i8** %1)
br label %34
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 4
%7 = load i8*, i8** %6
%8 = load i32, i32* @stdout
%9 = tail call i32 @freopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strstr(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %5
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @process_quad(i8* %16, i8* %18)
br label %34
20: ; preds = %5
%21 = load i8*, i8** %10
%22 = tail call i32 @strstr(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = tail call i32 @process_array(i8* %26, i8* %28)
br label %34
30: ; preds = %20
%31 = tail call i32 @usage(i32 5, i8** %1)
br label %34
32: ; preds = %2
%33 = tail call i32 @usage(i32 %0, i8** %1)
br label %34
34: ; preds = %32, %24, %30, %14, %3
%35 = phi i32 [ 0, %3 ], [ 0, %30 ], [ 0, %24 ], [ 0, %14 ], [ -1, %32 ]
ret i32 %35
}