#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 */
scalar_t__ conf_get_int(char *, char *, int);
int /*<<< orphan*/ err_log(int /*<<< orphan*/, int, char *);
char *strdup(char *);
char toupper(char);
char *_db_proper_path(char *path) {
  char *new_path;
  char *path_ptr;
  new_path = strdup(path);
  if (!new_path) {
    err_log(0, 0x00000004, "malloc: _db_proper_path\n");
  }
  if (conf_get_int("scanning", "case_sensitive", 1) == 0) {
    path_ptr = new_path;
    while (*path_ptr) {
      *path_ptr = toupper(*path_ptr);
      path_ptr++;
    }
  }
  return new_path;
}


x86 assembly (clang, -O0):
<_db_proper_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <_db_proper_path+0x37>
xor    %edi,%edi
mov    $0x4,%esi
lea    0xe8e(%rip),%rdx
call   1040 <err_log@plt>
lea    0xe9b(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x1,%edx
call   1060 <conf_get_int@plt>
cmp    $0x0,%rax
jne    11d8 <_db_proper_path+0x98>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d3 <_db_proper_path+0x93>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a1 <_db_proper_path+0x61>
jmp    11d8 <_db_proper_path+0x98>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_db_proper_path>:
push   %r14
push   %rbx
push   %rax
call   1050 <strdup@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1164 <_db_proper_path+0x24>
lea    0xea8(%rip),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   1040 <err_log@plt>
lea    0xeae(%rip),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x1,%edx
call   1060 <conf_get_int@plt>
test   %rax,%rax
jne    11a6 <_db_proper_path+0x66>
mov    (%r14),%al
test   %al,%al
je     11a6 <_db_proper_path+0x66>
mov    %r14,%rbx
add    $0x1,%rbx
nop
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <_db_proper_path+0x50>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"malloc: _db_proper_path\0A\00"
@.str.1 = [9 x i8] c"scanning\00"
@.str.2 = [15 x i8] c"case_sensitive\00"
define i8* @_db_proper_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @err_log(i32 0, i32 4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = call i64 @conf_get_int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8*, i8** %3
store i8* %15, i8** %4
br label %16
16: ; preds = %20, %14
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = call signext i8 @toupper(i8 signext %22)
%24 = load i8*, i8** %4
store i8 %23, i8* %24
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
br label %16
27: ; preds = %16
br label %28
28: ; preds = %27, %11
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@.str = [25 x i8] c"malloc: _db_proper_path\0A\00"
@.str.1 = [9 x i8] c"scanning\00"
@.str.2 = [15 x i8] c"case_sensitive\00"
define noalias i8* @_db_proper_path(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @err_log(i32 0, i32 4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i64 @conf_get_int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9, %12
%13 = phi i8 [ %17, %12 ], [ %10, %9 ]
%14 = phi i8* [ %16, %12 ], [ %2, %9 ]
%15 = tail call signext i8 @toupper(i8 signext %13)
store i8 %15, i8* %14
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %12
19: ; preds = %12, %9, %6
ret i8* %2
}