#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*/ EOF;
int /*<<< orphan*/ execute_script(char *, int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_series_folder();
char *make_bash_ready(int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
size_t strlen(char *);
char *write_script(char *, char *, int);
void unzip_all_comic_book_archives() {
  char *folderToSend = make_bash_ready(get_series_folder());
  size_t folderLength = strlen(folderToSend);
  char *scriptToRun = (char *)malloc(sizeof(char) * (folderLength + 95));
  if (scriptToRun == NULL) {
    exit(21);
  }
  sprintf(scriptToRun,
          "(cd %s && find -name '*.cbz' -exec sh -c 'unzip "
          "-qqo -d \"${1%%.cbz}\" \"$1\" && rm -f \"$1\"' _ {} \\;)",
          folderToSend);
  char *scriptFile = write_script(".unzip.sh", scriptToRun, false);
  free(folderToSend);
  free(scriptToRun);
  (void)execute_script(scriptFile, 21, false, EOF, false);
}


x86 assembly (clang, -O0):
<unzip_all_comic_book_archives>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <get_series_folder@plt>
mov    %eax,%edi
call   1050 <make_bash_ready@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x5f,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e3 <unzip_all_comic_book_archives+0x53>
mov    $0x15,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe0e(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe60(%rip),%rdi
xor    %edx,%edx
call   1080 <write_script@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dbe(%rip),%rax
mov    (%rax),%ecx
mov    $0x15,%esi
xor    %r8d,%r8d
mov    %r8d,%edx
call   1090 <execute_script@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unzip_all_comic_book_archives>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <get_series_folder@plt>
mov    %eax,%edi
call   1050 <make_bash_ready@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x5f(%rax),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1214 <unzip_all_comic_book_archives+0x84>
mov    %rax,%rbx
lea    0xe3b(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1080 <write_script@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%ecx
mov    %r15,%rdi
mov    $0x15,%esi
xor    %edx,%edx
xor    %r8d,%r8d
pop    %rbx
pop    %r14
pop    %r15
jmp    1090 <execute_script@plt>
mov    $0x15,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [98 x i8] c"(cd %s && find -name '*.cbz' -exec sh -c 'unzip -qqo -d \22${1%%.cbz}\22 \22$1\22 && rm -f \22$1\22' _ {} \\;)\00"
@.str.1 = [10 x i8] c".unzip.sh\00"
@EOF = global i32 0
define void @unzip_all_comic_book_archives() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = call i32 (...) @get_series_folder()
%6 = call i8* @make_bash_ready(i32 %5)
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %2
%9 = load i64, i64* %2
%10 = add i64 %9, 95
%11 = mul i64 1, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @exit(i32 21)
unreachable
19: ; preds = %0
%20 = load i8*, i8** %3
%21 = load i8*, i8** %1
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %3
%24 = call i8* @write_script(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 0)
store i8* %24, i8** %4
%25 = load i8*, i8** %1
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %4
%30 = load i32, i32* @EOF
%31 = call i32 @execute_script(i8* %29, i32 21, i32 0, i32 %30, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [98 x i8] c"(cd %s && find -name '*.cbz' -exec sh -c 'unzip -qqo -d \22${1%%.cbz}\22 \22$1\22 && rm -f \22$1\22' _ {} \\;)\00"
@.str.1 = [10 x i8] c".unzip.sh\00"
@EOF = global i32 0
define void @unzip_all_comic_book_archives() {
%1 = tail call i32 (...) @get_series_folder()
%2 = tail call i8* @make_bash_ready(i32 %1)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = trunc i64 %3 to i32
%5 = add i32 %4, 95
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @exit(i32 21)
unreachable
11: ; preds = %0
%12 = tail call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %2)
%13 = tail call i8* @write_script(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 0)
%14 = tail call i32 @free(i8* %2)
%15 = tail call i32 @free(i8* %7)
%16 = load i32, i32* @EOF
%17 = tail call i32 @execute_script(i8* %13, i32 21, i32 0, i32 %16, i32 0)
ret void
}