#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *leave_extension(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *trim_extension(char *);
int main(int argc, char **argv) {
  int exit_usage = 0;
  if (argc != 3)
    exit_usage = 1;
  else if (strcmp(argv[2], "trim") == 0)
    printf("%s\n", trim_extension(argv[1]));
  else if (strcmp(argv[2], "leave") == 0)
    printf("%s\n", leave_extension(argv[1]));
  else
    exit_usage = 1;
  if (exit_usage) {
    fprintf(stderr, "Usage: %s filename_with_extension [trim/leave]\n",
            argv[0]);
    exit(1);
  }
  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   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1193 <main+0x33>
movl   $0x1,-0x14(%rbp)
jmp    1222 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <trim_extension@plt>
mov    %rax,%rsi
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
jmp    121d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <leave_extension@plt>
mov    %rax,%rsi
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xb8>
movl   $0x1,-0x14(%rbp)
jmp    121d <main+0xbd>
jmp    1222 <main+0xc2>
cmpl   $0x0,-0x14(%rbp)
je     1252 <main+0xf2>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdcc(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11ba <main+0x5a>
mov    0x10(%rbx),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119e <main+0x3e>
mov    0x10(%rbx),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11ba <main+0x5a>
mov    0x8(%rbx),%rdi
call   1080 <leave_extension@plt>
jmp    11a7 <main+0x47>
mov    0x8(%rbx),%rdi
call   1030 <trim_extension@plt>
mov    %rax,%rsi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"trim\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"leave\00"
@stderr = global i32 0
@.str.3 = [48 x i8] c"Usage: %s filename_with_extension [trim/leave]\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
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %6
br label %37
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @trim_extension(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %36
22: ; preds = %10
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i8* @leave_extension(i8* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %35
34: ; preds = %22
store i32 1, i32* %6
br label %35
35: ; preds = %34, %28
br label %36
36: ; preds = %35, %16
br label %37
37: ; preds = %36, %9
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"trim\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"leave\00"
@stderr = global i32 0
@.str.3 = [48 x i8] c"Usage: %s filename_with_extension [trim/leave]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i8* @trim_extension(i8* %11)
br label %26
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i8* @leave_extension(i8* %19)
br label %26
21: ; preds = %2, %13
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %1
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17, %9
%27 = phi i8* [ %20, %17 ], [ %12, %9 ]
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
ret i32 0
}