#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*/ die(char *, char *, ...);
int /*<<< orphan*/ edit_bitmap(char *);
scalar_t__ strcmp(char *, char *);
char *strrchr(char *, char);
int /*<<< orphan*/ transfer_params(char *);
void do_bitmap_edit(char *filename) {
  char *bmp = ".bmp";
  char *fn = strrchr(filename, *bmp);
  if (!fn)
    die("'%s'/'%s' filename extension required:  %s", ".bmp", ".dat", filename);
  if (strcmp(fn, ".dat") == 0)
    transfer_params(filename);
  if (strcmp(fn, ".bmp") == 0)
    edit_bitmap(filename);
  die("Unknown filename extension:  %s", filename);
}


x86 assembly (clang, -O0):
<do_bitmap_edit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a6 <do_bitmap_edit+0x56>
mov    -0x8(%rbp),%rcx
lea    0xe74(%rip),%rdi
lea    0xe68(%rip),%rsi
lea    0xe91(%rip),%rdx
mov    $0x0,%al
call   1060 <die@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <do_bitmap_edit+0x79>
mov    -0x8(%rbp),%rdi
call   1070 <transfer_params@plt>
mov    -0x18(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <do_bitmap_edit+0x9c>
mov    -0x8(%rbp),%rdi
call   1030 <edit_bitmap@plt>
mov    -0x8(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1060 <die@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_bitmap_edit>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1188 <do_bitmap_edit+0x38>
lea    0xe95(%rip),%rdi
lea    0xe89(%rip),%rsi
lea    0xeb2(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <die@plt>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11a4 <do_bitmap_edit+0x54>
mov    %r14,%rdi
call   1070 <transfer_params@plt>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11c0 <do_bitmap_edit+0x70>
mov    %r14,%rdi
call   1030 <edit_bitmap@plt>
lea    0xe6e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <die@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".bmp\00"
@.str.1 = [43 x i8] c"'%s'/'%s' filename extension required: %s\00"
@.str.2 = [5 x i8] c".dat\00"
@.str.3 = [32 x i8] c"Unknown filename extension: %s\00"
define void @do_bitmap_edit(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i8* @strrchr(i8* %5, i8 signext %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %1
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = call i32 @transfer_params(i8* %19)
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %4
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8*, i8** %2
%27 = call i32 @edit_bitmap(i8* %26)
br label %28
28: ; preds = %25, %21
%29 = load i8*, i8** %2
%30 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".bmp\00"
@.str.1 = [43 x i8] c"'%s'/'%s' filename extension required: %s\00"
@.str.2 = [5 x i8] c".dat\00"
@.str.3 = [32 x i8] c"Unknown filename extension: %s\00"
define void @do_bitmap_edit(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %6
6: ; preds = %4, %1
%7 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @transfer_params(i8* %0)
br label %11
11: ; preds = %9, %6
%12 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @edit_bitmap(i8* %0)
br label %16
16: ; preds = %14, %11
%17 = tail call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %0)
ret void
}