#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 *convertation(int, int, char *);
int find_in_str(char *, char);
scalar_t__ ft_strlen(char *);
char *ft_convert_base(char *nbr, char *base_from, char *base_to) {
  int nbr_i;
  char *result;
  nbr_i = 0;
  while (*nbr) {
    if (find_in_str(base_from, *nbr) != -1)
      nbr_i = nbr_i * (int)ft_strlen(base_from) + find_in_str(base_from, *nbr);
    else
      return (0);
    nbr++;
  }
  result = convertation((int)ft_strlen(base_to), nbr_i, base_to);
  return (result);
}


x86 assembly (clang, -O0):
<ft_convert_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c9 <ft_convert_base+0x99>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1050 <find_in_str@plt>
cmp    $0xffffffff,%eax
je     11ab <ft_convert_base+0x7b>
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ft_strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1050 <find_in_str@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    11b8 <ft_convert_base+0x88>
movq   $0x0,-0x8(%rbp)
jmp    11ec <ft_convert_base+0xbc>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114b <ft_convert_base+0x1b>
mov    -0x20(%rbp),%rdi
call   1040 <ft_strlen@plt>
mov    %eax,%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <convertation@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_convert_base>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    (%rdi),%al
test   %al,%al
je     1186 <ft_convert_base+0x56>
mov    %rsi,%r15
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r15,%rdi
call   1050 <find_in_str@plt>
cmp    $0xffffffff,%eax
je     11a6 <ft_convert_base+0x76>
mov    %r15,%rdi
call   1040 <ft_strlen@plt>
imul   %eax,%ebp
movsbl -0x1(%rbx),%esi
mov    %r15,%rdi
call   1050 <find_in_str@plt>
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <ft_convert_base+0x20>
jmp    1188 <ft_convert_base+0x58>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1040 <ft_strlen@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <convertation@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @ft_convert_base(i8* nocapture %0, i8* %1, i8* %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3, %12
%7 = phi i8 [ %20, %12 ], [ %4, %3 ]
%8 = phi i32 [ %18, %12 ], [ 0, %3 ]
%9 = phi i8* [ %19, %12 ], [ %0, %3 ]
%10 = tail call i32 @find_in_str(i8* %1, i8 signext %7)
%11 = icmp eq i32 %10, -1
br i1 %11, label %27, label %12
12: ; preds = %6
%13 = tail call i64 @ft_strlen(i8* %1)
%14 = trunc i64 %13 to i32
%15 = mul nsw i32 %8, %14
%16 = load i8, i8* %9
%17 = tail call i32 @find_in_str(i8* %1, i8 signext %16)
%18 = add nsw i32 %15, %17
%19 = getelementptr inbounds i8, i8* %9, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %12, %3
%23 = phi i32 [ 0, %3 ], [ %18, %12 ]
%24 = tail call i64 @ft_strlen(i8* %2)
%25 = trunc i64 %24 to i32
%26 = tail call i8* @convertation(i32 %25, i32 %23, i8* %2)
br label %27
27: ; preds = %6, %22
%28 = phi i8* [ %26, %22 ], [ null, %6 ]
ret i8* %28
}