#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 atoi(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
char *strpbrk(char *, char *);
char *complexNumberMultiply(char *a, char *b) {
  int aReal, bReal, aImage, bImage, tmp;
  char *ret = (char *)malloc(sizeof(char) * 100);
  aReal = atoi(a);
  bReal = atoi(b);
  aImage = atoi((strpbrk(a, "+") + 1));
  bImage = atoi((strpbrk(b, "+") + 1));
  sprintf(ret, "%d+%di", aReal * bReal - aImage * bImage,
          aReal * bImage + bReal * aImage);
  return ret;
}


x86 assembly (clang, -O0):
<complexNumberMultiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x64,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%edx
imul   -0x18(%rbp),%edx
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
sub    %eax,%edx
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    %eax,%ecx
lea    0xe23(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<complexNumberMultiply>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%rbx
mov    $0x64,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0x2b,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    $0x2b,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rdi
call   1050 <atoi@plt>
mov    %r15d,%edx
imul   %ebp,%edx
imul   %eax,%ebp
imul   %ebx,%eax
sub    %eax,%edx
imul   %r15d,%ebx
add    %ebp,%ebx
lea    0xe47(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%ecx
call   1060 <sprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [7 x i8] c"%d+%di\00"
define i8* @complexNumberMultiply(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = call i64 @malloc(i32 100)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %10
%13 = load i8*, i8** %3
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %5
%15 = load i8*, i8** %4
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i8*, i8** %3
%18 = call i8* @strpbrk(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %7
%21 = load i8*, i8** %4
%22 = call i8* @strpbrk(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
%25 = load i8*, i8** %10
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = sub nsw i32 %28, %31
%33 = load i32, i32* %5
%34 = load i32, i32* %8
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = mul nsw i32 %36, %37
%39 = add nsw i32 %35, %38
%40 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %39)
%41 = load i8*, i8** %10
ret i8* %41
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d+%di\00"
define i8* @complexNumberMultiply(i8* %0, i8* %1) {
%3 = tail call i64 @malloc(i32 100)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @atoi(i8* %0)
%6 = tail call i32 @atoi(i8* %1)
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 43)
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 43)
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = tail call i32 @atoi(i8* %11)
%13 = mul nsw i32 %6, %5
%14 = mul nsw i32 %12, %9
%15 = sub nsw i32 %13, %14
%16 = mul nsw i32 %12, %5
%17 = mul nsw i32 %9, %6
%18 = add nsw i32 %16, %17
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %18)
ret i8* %4
}