#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*/ free(char *);
char *ft_strfjoin(char *, char *, int, int);
char *ft_strfjoinnchar(char *, int, char);
int ft_strlen(char *);
char *ft_strsub(char *, int, int);
char *ft_itodate(char *i) {
  char *date;
  int len;
  date = NULL;
  if ((len = ft_strlen(i)) % 2 == 1)
    i = ft_strfjoin("0", i, 0, 1);
  len = ft_strlen(i);
  if (len >= 2)
    date = ft_strsub(i, len - 2, 2);
  if (len >= 2 + 2) {
    date = ft_strfjoinnchar(date, -1, '/');
    date = ft_strfjoin(date, ft_strsub(i, len - 4, 2), 1, 1);
  }
  if (len >= 2 + 2 + 2) {
    date = ft_strfjoinnchar(date, -1, '/');
    if (len >= 4 + 2 + 2)
      date = ft_strfjoin(date, ft_strsub(i, 0, 4), 1, 1);
    else
      date = ft_strfjoin(date, ft_strsub(i, 0, 2), 1, 1);
  }
  free(i);
  return (date);
}


x86 assembly (clang, -O0):
<ft_itodate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ft_strlen@plt>
mov    %eax,-0x14(%rbp)
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    119c <ft_itodate+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xe74(%rip),%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   1070 <ft_strfjoin@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ft_strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jl     11ca <ft_itodate+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x2,%esi
mov    $0x2,%edx
call   1060 <ft_strsub@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x4,-0x14(%rbp)
jl     121e <ft_itodate+0xce>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x2f,%edx
call   1040 <ft_strfjoinnchar@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x4,%esi
mov    $0x2,%edx
call   1060 <ft_strsub@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1070 <ft_strfjoin@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x6,-0x14(%rbp)
jl     12b1 <ft_itodate+0x161>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x2f,%edx
call   1040 <ft_strfjoinnchar@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x8,-0x14(%rbp)
jl     127d <ft_itodate+0x12d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <ft_strsub@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1070 <ft_strfjoin@plt>
mov    %rax,-0x10(%rbp)
jmp    12ac <ft_itodate+0x15c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <ft_strsub@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1070 <ft_strfjoin@plt>
mov    %rax,-0x10(%rbp)
jmp    12b1 <ft_itodate+0x161>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_itodate>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <ft_strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
jne    1187 <ft_itodate+0x37>
lea    0xe8b(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   1070 <ft_strfjoin@plt>
mov    %rax,%r14
mov    %r14,%rdi
call   1050 <ft_strlen@plt>
cmp    $0x2,%eax
jl     1245 <ft_itodate+0xf5>
mov    %eax,%r15d
lea    -0x2(%r15),%esi
mov    %r14,%rdi
mov    $0x2,%edx
call   1060 <ft_strsub@plt>
mov    %rax,%rbx
cmp    $0x4,%r15d
jb     1247 <ft_itodate+0xf7>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x2f,%edx
call   1040 <ft_strfjoinnchar@plt>
mov    %rax,%rbx
lea    -0x4(%r15),%esi
mov    %r14,%rdi
mov    $0x2,%edx
call   1060 <ft_strsub@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1070 <ft_strfjoin@plt>
mov    %rax,%rbx
cmp    $0x6,%r15d
jb     1247 <ft_itodate+0xf7>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x2f,%edx
call   1040 <ft_strfjoinnchar@plt>
mov    %rax,%rbx
xor    %eax,%eax
cmp    $0x8,%r15d
setae  %al
lea    (%rax,%rax,1),%edx
add    $0x2,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <ft_strsub@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1070 <ft_strfjoin@plt>
mov    %rax,%rbx
jmp    1247 <ft_itodate+0xf7>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
define i8* @ft_itodate(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = call i32 @ft_strlen(i8* %5)
store i32 %6, i32* %4
%7 = srem i32 %6, 2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i8* @ft_strfjoin(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %10, i32 0, i32 1)
store i8* %11, i8** %2
br label %12
12: ; preds = %9, %1
%13 = load i8*, i8** %2
%14 = call i32 @ft_strlen(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 2
%21 = call i8* @ft_strsub(i8* %18, i32 %20, i32 2)
store i8* %21, i8** %3
br label %22
22: ; preds = %17, %12
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 4
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i8*, i8** %3
%27 = call i8* @ft_strfjoinnchar(i8* %26, i32 -1, i8 signext 47)
store i8* %27, i8** %3
%28 = load i8*, i8** %3
%29 = load i8*, i8** %2
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 4
%32 = call i8* @ft_strsub(i8* %29, i32 %31, i32 2)
%33 = call i8* @ft_strfjoin(i8* %28, i8* %32, i32 1, i32 1)
store i8* %33, i8** %3
br label %34
34: ; preds = %25, %22
%35 = load i32, i32* %4
%36 = icmp sge i32 %35, 6
br i1 %36, label %37, label %53
37: ; preds = %34
%38 = load i8*, i8** %3
%39 = call i8* @ft_strfjoinnchar(i8* %38, i32 -1, i8 signext 47)
store i8* %39, i8** %3
%40 = load i32, i32* %4
%41 = icmp sge i32 %40, 8
br i1 %41, label %42, label %47
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = load i8*, i8** %2
%45 = call i8* @ft_strsub(i8* %44, i32 0, i32 4)
%46 = call i8* @ft_strfjoin(i8* %43, i8* %45, i32 1, i32 1)
store i8* %46, i8** %3
br label %52
47: ; preds = %37
%48 = load i8*, i8** %3
%49 = load i8*, i8** %2
%50 = call i8* @ft_strsub(i8* %49, i32 0, i32 2)
%51 = call i8* @ft_strfjoin(i8* %48, i8* %50, i32 1, i32 1)
store i8* %51, i8** %3
br label %52
52: ; preds = %47, %42
br label %53
53: ; preds = %52, %34
%54 = load i8*, i8** %2
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %3
ret i8* %56
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
define i8* @ft_itodate(i8* %0) {
%2 = tail call i32 @ft_strlen(i8* %0)
%3 = srem i32 %2, 2
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i8* @ft_strfjoin(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0, i32 0, i32 1)
br label %7
7: ; preds = %5, %1
%8 = phi i8* [ %6, %5 ], [ %0, %1 ]
%9 = tail call i32 @ft_strlen(i8* %8)
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = add nsw i32 %9, -2
%13 = tail call i8* @ft_strsub(i8* %8, i32 %12, i32 2)
%14 = icmp ugt i32 %9, 3
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = tail call i8* @ft_strfjoinnchar(i8* %13, i32 -1, i8 signext 47)
%17 = add nsw i32 %9, -4
%18 = tail call i8* @ft_strsub(i8* %8, i32 %17, i32 2)
%19 = tail call i8* @ft_strfjoin(i8* %16, i8* %18, i32 1, i32 1)
%20 = icmp ugt i32 %9, 5
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = tail call i8* @ft_strfjoinnchar(i8* %19, i32 -1, i8 signext 47)
%23 = icmp ugt i32 %9, 7
%24 = select i1 %23, i32 4, i32 2
%25 = tail call i8* @ft_strsub(i8* %8, i32 0, i32 %24)
%26 = tail call i8* @ft_strfjoin(i8* %22, i8* %25, i32 1, i32 1)
br label %27
27: ; preds = %21, %7, %11, %15
%28 = phi i8* [ %19, %15 ], [ %13, %11 ], [ null, %7 ], [ %26, %21 ]
%29 = tail call i32 @free(i8* %8)
ret i8* %28
}