#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 *convert_base10(int, int);
int convert_basex(char *, int);
int my_getnbr(char *);
char *convert_base(char *nbr, char *base_from, char *base_to) {
  int strd;
  char *result;
  if (my_getnbr(base_from) == 10) {
    return (convert_base10(my_getnbr(nbr), my_getnbr(base_to)));
  }
  if (my_getnbr(base_from) != 16) {
    strd = convert_basex(nbr, my_getnbr(base_from));
    result = convert_base10(strd, my_getnbr(base_to));
  }
  return (result);
}


x86 assembly (clang, -O0):
<convert_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <my_getnbr@plt>
cmp    $0xa,%eax
jne    117e <convert_base+0x4e>
mov    -0x10(%rbp),%rdi
call   1040 <my_getnbr@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <my_getnbr@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1030 <convert_base10@plt>
mov    %rax,-0x8(%rbp)
jmp    11d4 <convert_base+0xa4>
mov    -0x18(%rbp),%rdi
call   1040 <my_getnbr@plt>
cmp    $0x10,%eax
je     11cc <convert_base+0x9c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <my_getnbr@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1050 <convert_basex@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <my_getnbr@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
call   1030 <convert_base10@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):
<convert_base>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <my_getnbr@plt>
cmp    $0xa,%eax
jne    1155 <convert_base+0x25>
mov    %r15,%rdi
call   1040 <my_getnbr@plt>
jmp    117a <convert_base+0x4a>
mov    %rbx,%rdi
call   1040 <my_getnbr@plt>
cmp    $0x10,%eax
jne    1168 <convert_base+0x38>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1040 <my_getnbr@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <convert_basex@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <my_getnbr@plt>
mov    %ebx,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <convert_base10@plt>

LLVM IR (-O0):
define i8* @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
%10 = load i8*, i8** %6
%11 = call i32 @my_getnbr(i8* %10)
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i32 @my_getnbr(i8* %14)
%16 = load i8*, i8** %7
%17 = call i32 @my_getnbr(i8* %16)
%18 = call i8* @convert_base10(i32 %15, i32 %17)
store i8* %18, i8** %4
br label %34
19: ; preds = %3
%20 = load i8*, i8** %6
%21 = call i32 @my_getnbr(i8* %20)
%22 = icmp ne i32 %21, 16
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = call i32 @my_getnbr(i8* %25)
%27 = call i32 @convert_basex(i8* %24, i32 %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = load i8*, i8** %7
%30 = call i32 @my_getnbr(i8* %29)
%31 = call i8* @convert_base10(i32 %28, i32 %30)
store i8* %31, i8** %9
br label %32
32: ; preds = %23, %19
%33 = load i8*, i8** %9
store i8* %33, i8** %4
br label %34
34: ; preds = %32, %13
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
define i8* @convert_base(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @my_getnbr(i8* %1)
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @my_getnbr(i8* %0)
br label %14
8: ; preds = %3
%9 = tail call i32 @my_getnbr(i8* %1)
%10 = icmp eq i32 %9, 16
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = tail call i32 @my_getnbr(i8* %1)
%13 = tail call i32 @convert_basex(i8* %0, i32 %12)
br label %14
14: ; preds = %6, %11
%15 = phi i32 [ %13, %11 ], [ %7, %6 ]
%16 = tail call i32 @my_getnbr(i8* %2)
%17 = tail call i8* @convert_base10(i32 %15, i32 %16)
br label %18
18: ; preds = %14, %8
%19 = phi i8* [ undef, %8 ], [ %17, %14 ]
ret i8* %19
}