#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*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gethome();
scalar_t__ rm(char *, int);
scalar_t__ sstrncat(char *, size_t *, int, char const *, int);
int /*<<< orphan*/ stdout;
int strlen(char const *);
int clear_localdb(int verbose) {
  size_t len;
  char tmp[512];
  char const *homedir;
  homedir = gethome();
  if (homedir == NULL)
    return 1;
  len = 0;
  if (sstrncat(tmp, &len, 512, homedir, strlen(homedir)))
    return 1;
  if (sstrncat(tmp, &len, 512, "/.tldrc", (sizeof("/.tldrc") - 1)))
    return 1;
  if (rm(tmp, (0x1)))
    return 1;
  if (verbose) {
    fprintf(stdout, "Successfully removed %s\n", tmp);
  } else {
    fprintf(stdout, "Successfully removed local database\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<clear_localdb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <gethome@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    1186 <clear_localdb+0x36>
movl   $0x1,-0x4(%rbp)
jmp    1295 <clear_localdb+0x145>
movq   $0x0,-0x10(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x228(%rbp)
mov    -0x218(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x218(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x228(%rbp),%rdi
mov    -0x220(%rbp),%rcx
mov    %eax,%r8d
lea    -0x10(%rbp),%rsi
mov    $0x200,%edx
call   1050 <sstrncat@plt>
cmp    $0x0,%rax
je     11eb <clear_localdb+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    1295 <clear_localdb+0x145>
lea    -0x210(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x200,%edx
lea    0xdfe(%rip),%rcx
mov    $0x7,%r8d
call   1050 <sstrncat@plt>
cmp    $0x0,%rax
je     1223 <clear_localdb+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    1295 <clear_localdb+0x145>
lea    -0x210(%rbp),%rdi
mov    $0x1,%esi
call   1030 <rm@plt>
cmp    $0x0,%rax
je     124a <clear_localdb+0xfa>
movl   $0x1,-0x4(%rbp)
jmp    1295 <clear_localdb+0x145>
cmpl   $0x0,-0x8(%rbp)
je     1277 <clear_localdb+0x127>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    -0x210(%rbp),%rdx
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    128e <clear_localdb+0x13e>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_localdb>:
push   %rbp
push   %r14
push   %rbx
sub    $0x210,%rsp
mov    %edi,%r14d
xor    %eax,%eax
call   1070 <gethome@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     121a <clear_localdb+0xca>
mov    %rax,%rbp
movq   $0x0,0x8(%rsp)
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x200,%edx
mov    %rbp,%rcx
mov    %eax,%r8d
call   1050 <sstrncat@plt>
test   %rax,%rax
jne    121a <clear_localdb+0xca>
lea    0xe53(%rip),%rcx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x200,%edx
mov    $0x7,%r8d
call   1050 <sstrncat@plt>
test   %rax,%rax
jne    121a <clear_localdb+0xca>
lea    0x10(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
call   1030 <rm@plt>
test   %rax,%rax
jne    121a <clear_localdb+0xca>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
test   %r14d,%r14d
je     120a <clear_localdb+0xba>
lea    0xe0e(%rip),%rsi
xor    %ebx,%ebx
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    121a <clear_localdb+0xca>
lea    0xe10(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/.tldrc\00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"Successfully removed %s\0A\00"
@.str.2 = [37 x i8] c"Successfully removed local database\0A\00"
define i32 @clear_localdb(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca [512 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
%7 = call i8* (...) @gethome()
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %40
11: ; preds = %1
store i64 0, i64* %4
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = call i64 @sstrncat(i8* %12, i64* %4, i32 512, i8* %13, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 1, i32* %2
br label %40
19: ; preds = %11
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%21 = call i64 @sstrncat(i8* %20, i64* %4, i32 512, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %2
br label %40
24: ; preds = %19
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%26 = call i64 @rm(i8* %25, i32 1)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %2
br label %40
29: ; preds = %24
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* @stdout
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %39
36: ; preds = %29
%37 = load i32, i32* @stdout
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %36, %32
store i32 0, i32* %2
br label %40
40: ; preds = %39, %28, %23, %18, %10
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [8 x i8] c"/.tldrc\00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"Successfully removed %s\0A\00"
@.str.2 = [37 x i8] c"Successfully removed local database\0A\00"
define i32 @clear_localdb(i32 %0) {
%2 = alloca i64
%3 = alloca [512 x i8]
%4 = bitcast i64* %2 to i8*
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = tail call i8* (...) @gethome()
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %8
8: ; preds = %1
store i64 0, i64* %2
%9 = tail call i32 @strlen(i8* %6)
%10 = call i64 @sstrncat(i8* %5, i64* %2, i32 512, i8* %6, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = call i64 @sstrncat(i8* %5, i64* %2, i32 512, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = call i64 @rm(i8* %5, i32 1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = icmp eq i32 %0, 0
%20 = load i32, i32* @stdout
br i1 %19, label %23, label %21
21: ; preds = %18
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %25
23: ; preds = %18
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %21, %23, %15, %12, %8, %1
%26 = phi i32 [ 1, %1 ], [ 1, %8 ], [ 1, %12 ], [ 1, %15 ], [ 0, %23 ], [ 0, %21 ]
ret i32 %26
}