#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__ strcmp(char *, char *);
int /*<<< orphan*/ tolower(int);
int /*<<< orphan*/ toupper(int);
int main(int argc, char **argv) {
  int low = strcmp(argv[0], "low") == 0;
  int c;
  while ((c = getchar()) != EOF)
    putchar(low ? tolower(c) : toupper(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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
je     11d3 <main+0x83>
cmpl   $0x0,-0x14(%rbp)
je     11bb <main+0x6b>
mov    -0x18(%rbp),%edi
call   1070 <tolower@plt>
mov    %eax,-0x1c(%rbp)
jmp    11c6 <main+0x76>
mov    -0x18(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
jmp    1188 <main+0x38>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rdi
lea    0xea2(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e74(%rip),%r14
jmp    1193 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r14),%eax
je     11a6 <main+0x56>
mov    %eax,%edi
test   %rbx,%rbx
jne    1180 <main+0x30>
call   1070 <tolower@plt>
jmp    1185 <main+0x35>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"low\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
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
store i32 %13, i32* %6
br label %14
14: ; preds = %27, %2
%15 = call i32 (...) @getchar()
store i32 %15, i32* %7
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %7
%23 = call i32 @tolower(i32 %22)
br label %27
24: ; preds = %18
%25 = load i32, i32* %7
%26 = call i32 @toupper(i32 %25)
br label %27
27: ; preds = %24, %21
%28 = phi i32 [ %23, %21 ], [ %26, %24 ]
%29 = call i32 @putchar(i32 %28)
br label %14
30: ; preds = %14
ret i32 0
}

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