#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 EOF;
int getchar();
int getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ tolower(int);
int /*<<< orphan*/ toupper(int);
int main(int argc, char *argv[]) {
  int c, o, af, uf;
  while ((o = getopt(argc, argv, "ulh")) != -1)
    switch (o) {
    case 'l':
      af = 1;
      break;
    case 'u':
      uf = 1;
      break;
    case 'h':
      printf("Usage: STREAM | convert_case [-u|-l]\n");
      return 1;
    case '?':
      return 1;
    }
  while ((c = getchar()) != EOF) {
    if ((af) == 1)
      putchar(tolower(c));
    else if ((uf) == 1)
      putchar(toupper(c));
  }
  return 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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     121d <main+0xbd>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     120c <main+0xac>
jmp    11a9 <main+0x49>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     11f4 <main+0x94>
jmp    11ba <main+0x5a>
mov    -0x24(%rbp),%eax
sub    $0x6c,%eax
je     11dc <main+0x7c>
jmp    11cb <main+0x6b>
mov    -0x24(%rbp),%eax
sub    $0x75,%eax
je     11e8 <main+0x88>
jmp    1218 <main+0xb8>
movl   $0x1,-0x1c(%rbp)
jmp    1218 <main+0xb8>
movl   $0x1,-0x20(%rbp)
jmp    1218 <main+0xb8>
lea    0xe09(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1283 <main+0x123>
movl   $0x1,-0x4(%rbp)
jmp    1283 <main+0x123>
jmp    1176 <main+0x16>
jmp    1222 <main+0xc2>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2db5(%rip),%rcx
cmp    (%rcx),%eax
je     127c <main+0x11c>
cmpl   $0x1,-0x1c(%rbp)
jne    1259 <main+0xf9>
mov    -0x14(%rbp),%edi
call   1070 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1277 <main+0x117>
cmpl   $0x1,-0x20(%rbp)
jne    1272 <main+0x112>
mov    -0x14(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1277 <main+0x117>
jmp    1222 <main+0xc2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea0(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0x68,%eax
je     11bc <main+0x6c>
cmp    $0x3f,%eax
je     11c8 <main+0x78>
cmp    $0xffffffff,%eax
jne    1160 <main+0x10>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e5c(%rip),%rbp
cmp    0x0(%rbp),%eax
je     11cd <main+0x7d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%edi
call   1060 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    0x0(%rbp),%eax
jne    11a0 <main+0x50>
jmp    11cd <main+0x7d>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ulh\00"
@.str.1 = [38 x i8] c"Usage: STREAM | convert_case [-u|-l]\0A\00"
@EOF = global i32 0
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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %22, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %7
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i32, i32* %7
switch i32 %16, label %22 [
i32 108, label %17
i32 117, label %18
i32 104, label %19
i32 63, label %21
]
17: ; preds = %15
store i32 1, i32* %8
br label %22
18: ; preds = %15
store i32 1, i32* %9
br label %22
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %45
21: ; preds = %15
store i32 1, i32* %3
br label %45
22: ; preds = %15, %18, %17
br label %10
23: ; preds = %10
br label %24
24: ; preds = %43, %23
%25 = call i32 (...) @getchar()
store i32 %25, i32* %6
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* %6
%33 = call i32 @tolower(i32 %32)
%34 = call i32 @putchar(i32 %33)
br label %43
35: ; preds = %28
%36 = load i32, i32* %9
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %6
%40 = call i32 @toupper(i32 %39)
%41 = call i32 @putchar(i32 %40)
br label %42
42: ; preds = %38, %35
br label %43
43: ; preds = %42, %31
br label %24
44: ; preds = %24
store i32 0, i32* %3
br label %45
45: ; preds = %44, %21, %19
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [4 x i8] c"ulh\00"
@EOF = global i32 0
@str = [37 x i8] c"Usage: STREAM | convert_case [-u|-l]\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %3 [
i32 -1, label %5
i32 63, label %18
i32 104, label %9
]
5: ; preds = %3
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %18, label %11
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %18
11: ; preds = %5, %11
%12 = phi i32 [ %15, %11 ], [ %6, %5 ]
%13 = tail call i32 @tolower(i32 %12)
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %11
18: ; preds = %3, %11, %5, %9
%19 = phi i32 [ 1, %9 ], [ 0, %5 ], [ 0, %11 ], [ 1, %3 ]
ret i32 %19
}