#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 *calloc(int, int);
int int_digits(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
char *base_mul(char *x, char *y) {
  int xd, yd, zd;
  int d;
  char *res;
  xd = strtol(x, NULL, 10);
  yd = strtol(y, NULL, 10);
  zd = xd * yd;
  d = int_digits(zd);
  res = calloc(d + 1, sizeof(char));
  snprintf(res, d, "%d", zd);
  res[d] = 0;
  return res;
}


x86 assembly (clang, -O0):
<base_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <int_digits@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%ecx
lea    0xe4c(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base_mul>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
imul   %eax,%r14d
mov    %r14d,%edi
call   1030 <int_digits@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbp
lea    0xe76(%rip),%rdx
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r14d,%ecx
call   1040 <snprintf@plt>
movslq %ebx,%rax
movb   $0x0,0x0(%rbp,%rax,1)
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i8* @base_mul(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %3
%11 = call i32 @strtol(i8* %10, i32* null, i32 10)
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = call i32 @strtol(i8* %12, i32* null, i32 10)
store i32 %13, i32* %6
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = call i32 @int_digits(i32 %17)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
%21 = call i8* @calloc(i32 %20, i32 1)
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = call i32 @snprintf(i8* %22, i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %9
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
%30 = load i8*, i8** %9
ret i8* %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i8* @base_mul(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 @strtol(i8* nocapture %0, i32* null, i32 10)
%4 = tail call i32 @strtol(i8* nocapture %1, i32* null, i32 10)
%5 = mul nsw i32 %4, %3
%6 = tail call i32 @int_digits(i32 %5)
%7 = add nsw i32 %6, 1
%8 = tail call i8* @calloc(i32 %7, i32 1)
%9 = tail call i32 @snprintf(i8* %8, i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8 0, i8* %11
ret i8* %8
}