#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 /*<<< orphan*/ putchar(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ tolower(int);
int /*<<< orphan*/ toupper(int);
int main(int argc, char **argv) {
  int upper = 1;
  int c;
  if (argc > 1 && strncmp(argv[1], "lower", 6) == 0) {
    upper = 0;
  }
  if (upper == 1) {
    while ((c = getchar()) != EOF) {
      putchar(toupper(c));
    }
  } else {
    while ((c = getchar()) != EOF) {
      putchar(tolower(c));
    }
  }
  return 0;
}


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   $0x1,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11a1 <main+0x51>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11e2 <main+0x92>
jmp    11b0 <main+0x60>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%eax
je     11dd <main+0x8d>
mov    -0x18(%rbp),%edi
call   1050 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x60>
jmp    1219 <main+0xc9>
jmp    11e7 <main+0x97>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
je     1214 <main+0xc4>
mov    -0x18(%rbp),%edi
call   1070 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11e7 <main+0x97>
jmp    1219 <main+0xc9>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jle    1170 <main+0x20>
mov    0x8(%rsi),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11ad <main+0x5d>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e6a(%rip),%rbx
cmp    (%rbx),%eax
je     11a9 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
call   1050 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
jne    1190 <main+0x40>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e2d(%rip),%rbx
cmp    (%rbx),%eax
je     11a9 <main+0x59>
nop
mov    %eax,%edi
call   1070 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
jne    11c0 <main+0x70>
jmp    11a9 <main+0x59>

LLVM IR (-O0):
@.str = [6 x i8] c"lower\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 0, i32* %6
br label %17
17: ; preds = %16, %10, %2
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %30
20: ; preds = %17
br label %21
21: ; preds = %25, %20
%22 = call i32 (...) @getchar()
store i32 %22, i32* %7
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %7
%27 = call i32 @toupper(i32 %26)
%28 = call i32 @putchar(i32 %27)
br label %21
29: ; preds = %21
br label %40
30: ; preds = %17
br label %31
31: ; preds = %35, %30
%32 = call i32 (...) @getchar()
store i32 %32, i32* %7
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %7
%37 = call i32 @tolower(i32 %36)
%38 = call i32 @putchar(i32 %37)
br label %31
39: ; preds = %31
br label %40
40: ; preds = %39, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"lower\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %8, %2
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %31, label %17
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %8
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %31, label %24
17: ; preds = %4, %17
%18 = phi i32 [ %21, %17 ], [ %5, %4 ]
%19 = tail call i32 @toupper(i32 %18)
%20 = tail call i32 @putchar(i32 %19)
%21 = tail call i32 (...) @getchar()
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %31, label %17
24: ; preds = %13, %24
%25 = phi i32 [ %28, %24 ], [ %14, %13 ]
%26 = tail call i32 @tolower(i32 %25)
%27 = tail call i32 @putchar(i32 %26)
%28 = tail call i32 (...) @getchar()
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %24
31: ; preds = %17, %24, %4, %13
ret i32 0
}