#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__ delsubdir(char const *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int maildir_mddelete(const char *s) {
  char *q;
  q = malloc(strlen(s) + sizeof("/cur"));
  if (!q)
    return (-1);
  strcat(strcpy(q, s), "/cur");
  if (delsubdir(q) == 0) {
    strcat(strcpy(q, s), "/new");
    if (delsubdir(q) == 0) {
      strcat(strcpy(q, s), "/tmp");
      if (delsubdir(q) == 0 && delsubdir(s) == 0) {
        free(q);
        return (0);
      }
    }
  }
  free(q);
  return (-1);
}


x86 assembly (clang, -O0):
<maildir_mddelete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cltq
add    $0x5,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119d <maildir_mddelete+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1269 <maildir_mddelete+0x109>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %eax,%edi
lea    0xe4d(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <delsubdir@plt>
cmp    $0x0,%rax
jne    1259 <maildir_mddelete+0xf9>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %eax,%edi
lea    0xe24(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <delsubdir@plt>
cmp    $0x0,%rax
jne    1254 <maildir_mddelete+0xf4>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %eax,%edi
lea    0xdfb(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <delsubdir@plt>
cmp    $0x0,%rax
jne    124f <maildir_mddelete+0xef>
mov    -0x10(%rbp),%rdi
call   1050 <delsubdir@plt>
cmp    $0x0,%rax
jne    124f <maildir_mddelete+0xef>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1269 <maildir_mddelete+0x109>
jmp    1254 <maildir_mddelete+0xf4>
jmp    1259 <maildir_mddelete+0xf9>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maildir_mddelete>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <strlen@plt>
lea    0x5(%rax),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     120e <maildir_mddelete+0xae>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe6e(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1050 <delsubdir@plt>
test   %rax,%rax
jne    11ff <maildir_mddelete+0x9f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe4d(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1050 <delsubdir@plt>
test   %rax,%rax
jne    11ff <maildir_mddelete+0x9f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe2c(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1050 <delsubdir@plt>
test   %rax,%rax
jne    11ff <maildir_mddelete+0x9f>
mov    %r14,%rdi
call   1050 <delsubdir@plt>
test   %rax,%rax
je     121a <maildir_mddelete+0xba>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1213 <maildir_mddelete+0xb3>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    1204 <maildir_mddelete+0xa4>

LLVM IR (-O0):
@.str = [5 x i8] c"/cur\00"
@.str.1 = [5 x i8] c"/new\00"
@.str.2 = [5 x i8] c"/tmp\00"
define i32 @maildir_mddelete(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = add i64 %7, 5
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %1
store i32 -1, i32* %2
br label %50
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = call i32 @strcat(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = call i64 @delsubdir(i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %47
22: ; preds = %14
%23 = load i8*, i8** %4
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = call i32 @strcat(i32 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %4
%28 = call i64 @delsubdir(i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %22
%31 = load i8*, i8** %4
%32 = load i8*, i8** %3
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = call i32 @strcat(i32 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %4
%36 = call i64 @delsubdir(i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %30
%39 = load i8*, i8** %3
%40 = call i64 @delsubdir(i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8*, i8** %4
%44 = call i32 @free(i8* %43)
store i32 0, i32* %2
br label %50
45: ; preds = %38, %30
br label %46
46: ; preds = %45, %22
br label %47
47: ; preds = %46, %14
%48 = load i8*, i8** %4
%49 = call i32 @free(i8* %48)
store i32 -1, i32* %2
br label %50
50: ; preds = %47, %42, %13
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [5 x i8] c"/cur\00"
@.str.1 = [5 x i8] c"/new\00"
@.str.2 = [5 x i8] c"/tmp\00"
define i32 @maildir_mddelete(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add i32 %2, 5
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %28, label %6
6: ; preds = %1
%7 = tail call i32 @strcpy(i8* %4, i8* %0)
%8 = tail call i32 @strcat(i32 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = tail call i64 @delsubdir(i8* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %6
%12 = tail call i32 @strcpy(i8* %4, i8* %0)
%13 = tail call i32 @strcat(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i64 @delsubdir(i8* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = tail call i32 @strcpy(i8* %4, i8* %0)
%18 = tail call i32 @strcat(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i64 @delsubdir(i8* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = tail call i64 @delsubdir(i8* %0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %11, %21, %16, %6
br label %25
25: ; preds = %21, %24
%26 = phi i32 [ -1, %24 ], [ 0, %21 ]
%27 = tail call i32 @free(i8* %4)
br label %28
28: ; preds = %25, %1
%29 = phi i32 [ -1, %1 ], [ %26, %25 ]
ret i32 %29
}