#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*/ printf(char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tolower(int);
int /*<<< orphan*/ toupper(int);
main(int argc, char *argv[]) {
  int c;
  if (strcmp(argv[0], "./tolower") == 0)
    while ((c = getchar()) != EOF)
      putchar(tolower(c));
  else if (strcmp(argv[0], "./toupper") == 0)
    while ((c = getchar()) != EOF)
      putchar(toupper(c));
  else
    printf("Unknown Parameter.\n");
  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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ca <main+0x6a>
jmp    1198 <main+0x38>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%eax
je     11c5 <main+0x65>
mov    -0x14(%rbp),%edi
call   1080 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1198 <main+0x38>
jmp    122f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe32(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <main+0xbe>
jmp    11ec <main+0x8c>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2deb(%rip),%rcx
cmp    (%rcx),%eax
je     1219 <main+0xb9>
mov    -0x14(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11ec <main+0x8c>
jmp    122a <main+0xca>
lea    0xdef(%rip),%rdi
call   1050 <printf@plt>
jmp    122f <main+0xcf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rdi
lea    0xe92(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119c <main+0x3c>
mov    (%rbx),%rdi
lea    0xe88(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11cb <main+0x6b>
lea    0xe81(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e3e(%rip),%rbx
cmp    (%rbx),%eax
je     1198 <main+0x38>
xchg   %ax,%ax
mov    %eax,%edi
call   1080 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
jne    11b0 <main+0x50>
jmp    1198 <main+0x38>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e0f(%rip),%rbx
cmp    (%rbx),%eax
je     1198 <main+0x38>
nopl   (%rax)
mov    %eax,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
jne    11e0 <main+0x80>
jmp    1198 <main+0x38>

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

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