#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tolower(char);
int /*<<< orphan*/ toupper(char);
int main(int argc, char *argv[]) {
  char c;
  printf("%s\n", argv[0]);
  if (strcmp(argv[0], "lower")) {
    while ((c = getchar()) != EOF) {
      putchar(toupper(c));
    }
  } else {
    while ((c = getchar()) != EOF) {
      putchar(tolower(c));
    }
  }
}


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),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11e4 <main+0x84>
jmp    11ab <main+0x4b>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e29(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11df <main+0x7f>
movsbl -0x11(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11ab <main+0x4b>
jmp    1222 <main+0xc2>
jmp    11e9 <main+0x89>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2deb(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     121d <main+0xbd>
movsbl -0x11(%rbp),%edi
call   1080 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11e9 <main+0x89>
jmp    1222 <main+0xc2>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%rsi
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    (%rbx),%rdi
lea    0xe84(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e52(%rip),%rbx
mov    (%rbx),%cl
test   %r14,%r14
je     11cc <main+0x6c>
cmp    %cl,%al
je     11ea <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%al
jne    11b0 <main+0x50>
jmp    11ea <main+0x8a>
cmp    %cl,%al
je     11ea <main+0x8a>
movsbl %al,%edi
call   1080 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%al
jne    11d0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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