#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*/ print_osc(int, char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
char tolower(char);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc < 2) {
    usage();
    exit(1);
  }
  char *command = argv[1];
  int i = 0;
  while (command[i] != '\0') {
    command[i] = tolower(command[i]);
    i += 1;
  }
  if (strcmp(command, "help") == 0) {
    usage();
  } else if (strcmp(command, "title") == 0) {
    if (argc != 3) {
      usage();
      exit(1);
    }
    char *title = argv[2];
    print_osc(2, title);
  } else {
    printf("Unknown command: %s\n\n", command);
    usage();
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1191 <main+0x31>
mov    $0x0,%al
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11e5 <main+0x85>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <main+0x44>
mov    -0x18(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    120b <main+0xab>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1285 <main+0x125>
mov    -0x18(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    125f <main+0xff>
cmpl   $0x3,-0x8(%rbp)
je     1240 <main+0xe0>
mov    $0x0,%al
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    $0x2,%edi
call   1070 <print_osc@plt>
jmp    1280 <main+0x120>
mov    -0x18(%rbp),%rsi
lea    0xda1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1285 <main+0x125>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117d <main+0x1d>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x8(%rsi),%rbx
mov    (%rbx),%al
test   %al,%al
je     11b7 <main+0x57>
lea    0x1(%rbx),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%rbp)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    11a0 <main+0x40>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11d9 <main+0x79>
xor    %eax,%eax
call   1060 <usage@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    120c <main+0xac>
cmp    $0x3,%r15d
jne    116c <main+0xc>
mov    0x10(%r14),%rsi
mov    $0x2,%edi
call   1070 <print_osc@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xdf8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    116c <main+0xc>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"title\00"
@.str.2 = [22 x i8] c"Unknown command: %s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (...) @usage()
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
store i32 0, i32* %7
br label %18
18: ; preds = %26, %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %18
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call signext i8 @tolower(i8 signext %31)
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %18
39: ; preds = %18
%40 = load i8*, i8** %6
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (...) @usage()
br label %67
45: ; preds = %39
%46 = load i8*, i8** %6
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %61
49: ; preds = %45
%50 = load i32, i32* %4
%51 = icmp ne i32 %50, 3
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = call i32 (...) @usage()
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %49
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
store i8* %58, i8** %8
%59 = load i8*, i8** %8
%60 = call i32 @print_osc(i32 2, i8* %59)
br label %66
61: ; preds = %45
%62 = load i8*, i8** %6
%63 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %62)
%64 = call i32 (...) @usage()
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %55
br label %67
67: ; preds = %66, %43
%68 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"title\00"
@.str.2 = [22 x i8] c"Unknown command: %s\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %17, %12 ], [ 0, %7 ]
%14 = phi i8 [ %19, %12 ], [ %10, %7 ]
%15 = phi i8* [ %18, %12 ], [ %9, %7 ]
%16 = tail call signext i8 @tolower(i8 signext %14)
store i8 %16, i8* %15
%17 = add nuw i64 %13, 1
%18 = getelementptr inbounds i8, i8* %9, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %12
21: ; preds = %12, %7
%22 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (...) @usage()
br label %42
26: ; preds = %21
%27 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = icmp eq i32 %0, 3
br i1 %30, label %34, label %31
31: ; preds = %29
%32 = tail call i32 (...) @usage()
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %29
%35 = getelementptr inbounds i8*, i8** %1, i64 2
%36 = load i8*, i8** %35
%37 = tail call i32 @print_osc(i32 2, i8* %36)
br label %42
38: ; preds = %26
%39 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%40 = tail call i32 (...) @usage()
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %34, %24
%43 = tail call i32 @exit(i32 0)
unreachable
}