#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printUsage();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  int x, y, curx;
  char c;
  char line[25];
  int input_window_width;
  if (argc == 1) {
    printUsage();
    exit(0);
  }
  switch (argv[1][0]) {
  case 'o':
    break;
  case 'b':
    break;
  case 'c':
    printf("\033[2J");
    break;
  case 'g':
    if (argc >= 4) {
      x = atoi(argv[2]);
      y = atoi(argv[3]);
      printf("\033[%d;%dH", (y + 1), (x + 1));
    }
    break;
  case 'p':
    if (argc >= 3) {
      printf("%s", argv[2]);
    }
    break;
  case 'i':
  case 'j':
    if (argc >= 2) {
      scanf("%18s", line);
      printf("%s", line);
    }
    break;
  default:
    printUsage();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117e <main+0x2e>
mov    $0x0,%al
call   1050 <printUsage@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0xe,%eax
ja     126b <main+0x11b>
mov    -0x50(%rbp),%rax
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1272 <main+0x122>
jmp    1272 <main+0x122>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x122>
cmpl   $0x4,-0x8(%rbp)
jl     1210 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x122>
cmpl   $0x3,-0x8(%rbp)
jl     1235 <main+0xe5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x122>
cmpl   $0x2,-0x8(%rbp)
jl     1266 <main+0x116>
lea    -0x40(%rbp),%rsi
lea    0xdfe(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x122>
mov    $0x0,%al
call   1050 <printUsage@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
je     120e <main+0xbe>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
cmp    $0xe,%eax
ja     11a4 <main+0x54>
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmp    $0x2,%edi
jl     1205 <main+0xb5>
lea    0xec0(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
jmp    11fe <main+0xae>
xor    %eax,%eax
call   1050 <printUsage@plt>
jmp    1205 <main+0xb5>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1205 <main+0xb5>
cmp    $0x4,%edi
jl     1205 <main+0xb5>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
lea    0x1(%rax),%esi
add    $0x1,%ebp
lea    0xe5e(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1205 <main+0xb5>
cmp    $0x3,%edi
jl     1205 <main+0xb5>
mov    0x10(%rbx),%rsi
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1050 <printUsage@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\1B[2J\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%18s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca [25 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (...) @printUsage()
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
switch i32 %23, label %64 [
i32 111, label %24
i32 98, label %25
i32 99, label %26
i32 103, label %28
i32 112, label %46
i32 105, label %55
i32 106, label %55
]
24: ; preds = %17
br label %66
25: ; preds = %17
br label %66
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %66
28: ; preds = %17
%29 = load i32, i32* %4
%30 = icmp sge i32 %29, 4
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %6
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %43)
br label %45
45: ; preds = %31, %28
br label %66
46: ; preds = %17
%47 = load i32, i32* %4
%48 = icmp sge i32 %47, 3
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %49, %46
br label %66
55: ; preds = %17, %17
%56 = load i32, i32* %4
%57 = icmp sge i32 %56, 2
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = getelementptr inbounds [25 x i8], [25 x i8]* %10, i64 0, i64 0
%60 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %59)
%61 = getelementptr inbounds [25 x i8], [25 x i8]* %10, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %58, %55
br label %66
64: ; preds = %17
%65 = call i32 (...) @printUsage()
br label %66
66: ; preds = %64, %63, %54, %45, %26, %25, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"\1B[2J\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%18s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [25 x i8]
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (...) @printUsage()
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %39 [
i32 111, label %41
i32 98, label %41
i32 99, label %14
i32 103, label %16
i32 112, label %28
i32 105, label %34
i32 106, label %34
]
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %41
16: ; preds = %9
%17 = icmp sgt i32 %0, 3
br i1 %17, label %18, label %41
18: ; preds = %16
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = add nsw i32 %24, 1
%26 = add nsw i32 %21, 1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26)
br label %41
28: ; preds = %9
%29 = icmp sgt i32 %0, 2
br i1 %29, label %30, label %41
30: ; preds = %28
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %41
34: ; preds = %9, %9
%35 = icmp sgt i32 %0, 1
br i1 %35, label %36, label %41
36: ; preds = %34
%37 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %41
39: ; preds = %9
%40 = tail call i32 (...) @printUsage()
br label %41
41: ; preds = %34, %36, %28, %30, %16, %18, %39, %14, %9, %9
ret i32 0
}