#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*/ ft_strlen(char const *);
char *ft_strnew(int /*<<< orphan*/);
char stub1(char const);
char *ft_strmap(char const *s, char (*f)(char)) {
  int i;
  char *dest;
  if (!(dest = ft_strnew(ft_strlen(s))))
    return (NULL);
  i = 0;
  while (s[i]) {
    dest[i] = (*f)(s[i]);
    i++;
  }
  return (dest);
}


x86 assembly (clang, -O0):
<ft_strmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%edi
call   1040 <ft_strnew@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    115b <ft_strmap+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <ft_strmap+0x89>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11a1 <ft_strmap+0x81>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %al,%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <ft_strmap+0x42>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_strmap>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <ft_strlen@plt>
mov    %eax,%edi
call   1040 <ft_strnew@plt>
mov    %rax,%r12
test   %rax,%rax
je     1168 <ft_strmap+0x48>
mov    (%r15),%al
test   %al,%al
je     1168 <ft_strmap+0x48>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   *%r14
mov    %al,(%r12,%rbx,1)
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <ft_strmap+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @ft_strmap(i8* %0, i8 (i8)* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8 (i8)*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8 (i8)* %1, i8 (i8)** %5
%8 = load i8*, i8** %4
%9 = call i32 @ft_strlen(i8* %8)
%10 = call i8* @ft_strnew(i32 %9)
store i8* %10, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %37
13: ; preds = %2
store i32 0, i32* %6
br label %14
14: ; preds = %21, %13
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %35
21: ; preds = %14
%22 = load i8 (i8)*, i8 (i8)** %5
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call signext i8 %22(i8 signext %27)
%29 = load i8*, i8** %7
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %14
35: ; preds = %14
%36 = load i8*, i8** %7
store i8* %36, i8** %3
br label %37
37: ; preds = %35, %12
%38 = load i8*, i8** %3
ret i8* %38
}

LLVM IR (-O2):
define i8* @ft_strmap(i8* %0, i8 (i8)* nocapture %1) {
%3 = tail call i32 @ft_strlen(i8* %0)
%4 = tail call i8* @ft_strnew(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %14, %9 ], [ 0, %6 ]
%11 = phi i8 [ %16, %9 ], [ %7, %6 ]
%12 = tail call signext i8 %1(i8 signext %11)
%13 = getelementptr inbounds i8, i8* %4, i64 %10
store i8 %12, i8* %13
%14 = add nuw i64 %10, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %6, %2
ret i8* %4
}