#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 */
char *midstr(char *, char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void add_slashes_maybe(char *d, char *s) {
  char buf1[32], buf2[32], buf3[32];
  if (strlen(s) != 6) {
    strcpy(d, s);
    return;
  }
  sprintf(d, "%s/%s/%s", midstr(buf1, s, 0, 2), midstr(buf2, s, 2, 2),
          midstr(buf3, s, 4, 2));
}


x86 assembly (clang, -O0):
<add_slashes_maybe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
je     1177 <add_slashes_maybe+0x37>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <add_slashes_maybe+0xa7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1050 <midstr@plt>
mov    %rax,-0x80(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1050 <midstr@plt>
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x2,%ecx
call   1050 <midstr@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    %rax,%r8
lea    0xe1e(%rip),%rsi
call   1060 <sprintf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_slashes_maybe>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jne    11c8 <add_slashes_maybe+0x88>
lea    0x40(%rsp),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1050 <midstr@plt>
mov    %rax,%r15
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1050 <midstr@plt>
mov    %rax,%r12
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x2,%ecx
call   1050 <midstr@plt>
lea    0xe55(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %rax,%r8
call   1060 <sprintf@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s/%s/%s\00"
define void @add_slashes_maybe(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 6
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %12, i8* %13)
br label %27
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i8* @midstr(i8* %17, i8* %18, i32 0, i32 2)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i8* @midstr(i8* %20, i8* %21, i32 2, i32 2)
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%24 = load i8*, i8** %4
%25 = call i8* @midstr(i8* %23, i8* %24, i32 4, i32 2)
%26 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %22, i8* %25)
br label %27
27: ; preds = %15, %11
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s/%s/%s\00"
define void @add_slashes_maybe(i8* %0, i8* %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @strlen(i8* %1)
%10 = icmp eq i32 %9, 6
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = tail call i32 @strcpy(i8* %0, i8* %1)
br label %18
13: ; preds = %2
%14 = call i8* @midstr(i8* %6, i8* %1, i32 0, i32 2)
%15 = call i8* @midstr(i8* %7, i8* %1, i32 2, i32 2)
%16 = call i8* @midstr(i8* %8, i8* %1, i32 4, i32 2)
%17 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15, i8* %16)
br label %18
18: ; preds = %13, %11
ret void
}