#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 command_import_csv(char *, char *, char);
int command_import_emacs(char *, char *, char);
int command_import_gnucash(char *, char *);
scalar_t__ strstr(char *, char *);
int command_import(char account[], char import_filename[], char separator) {
  if ((strstr(import_filename, ".csv") != 0) ||
      (strstr(import_filename, ".CSV") != 0))
    return command_import_csv(account, import_filename, separator);
  if (strstr(import_filename, ".gnucash") != 0)
    return command_import_gnucash(account, import_filename);
  return command_import_emacs(account, import_filename, '|');
}


x86 assembly (clang, -O0):
<command_import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1189 <command_import+0x49>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11a2 <command_import+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsbl -0x19(%rbp),%edx
call   1030 <command_import_csv@plt>
mov    %eax,-0x4(%rbp)
jmp    11e6 <command_import+0xa6>
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11d1 <command_import+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <command_import_gnucash@plt>
mov    %eax,-0x4(%rbp)
jmp    11e6 <command_import+0xa6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x7c,%edx
call   1040 <command_import_emacs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_import>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
jne    1174 <command_import+0x34>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1187 <command_import+0x47>
movsbl %bpl,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <command_import_csv@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
test   %rax,%rax
je     11aa <command_import+0x6a>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <command_import_gnucash@plt>
mov    $0x7c,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <command_import_emacs@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".csv\00"
@.str.1 = [5 x i8] c".CSV\00"
@.str.2 = [9 x i8] c".gnucash\00"
define i32 @command_import(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8 %2, i8* %7
%8 = load i8*, i8** %6
%9 = call i64 @strstr(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11, %3
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i8, i8* %7
%19 = call i32 @command_import_csv(i8* %16, i8* %17, i8 signext %18)
store i32 %19, i32* %4
br label %32
20: ; preds = %11
%21 = load i8*, i8** %6
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = call i32 @command_import_gnucash(i8* %25, i8* %26)
store i32 %27, i32* %4
br label %32
28: ; preds = %20
%29 = load i8*, i8** %5
%30 = load i8*, i8** %6
%31 = call i32 @command_import_emacs(i8* %29, i8* %30, i8 signext 124)
store i32 %31, i32* %4
br label %32
32: ; preds = %28, %24, %15
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c".csv\00"
@.str.1 = [5 x i8] c".CSV\00"
@.str.2 = [9 x i8] c".gnucash\00"
define i32 @command_import(i8* %0, i8* %1, i8 signext %2) {
%4 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6, %3
%10 = tail call i32 @command_import_csv(i8* %0, i8* %1, i8 signext %2)
br label %18
11: ; preds = %6
%12 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @command_import_gnucash(i8* %0, i8* %1)
br label %18
16: ; preds = %11
%17 = tail call i32 @command_import_emacs(i8* %0, i8* %1, i8 signext 124)
br label %18
18: ; preds = %16, %14, %9
%19 = phi i32 [ %10, %9 ], [ %15, %14 ], [ %17, %16 ]
ret i32 %19
}