#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 */
double atof(char *);
char *masprintf(char *, double);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *add_len_strings(char *ls1, char *ls2) {
  char *result;
  if (strcmp("", ls1) != 0 || strcmp("", ls2) != 0) {
    double l1 = atof(ls1);
    double l2 = atof(ls2);
    result = masprintf("%g", l1 + l2);
    if (NULL == result)
      return NULL;
  } else {
    result = strdup("");
    if (NULL == result)
      return NULL;
  }
  return result;
}


x86 assembly (clang, -O0):
<add_len_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1184 <add_len_strings+0x44>
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11d8 <add_len_strings+0x98>
mov    -0x10(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
call   1030 <masprintf@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    11d3 <add_len_strings+0x93>
movq   $0x0,-0x8(%rbp)
jmp    120e <add_len_strings+0xce>
jmp    1206 <add_len_strings+0xc6>
lea    0xe23(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1201 <add_len_strings+0xc1>
movq   $0x0,-0x8(%rbp)
jmp    120e <add_len_strings+0xce>
jmp    1206 <add_len_strings+0xc6>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_len_strings>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1172 <add_len_strings+0x32>
lea    0xe9d(%rip),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a7 <add_len_strings+0x67>
mov    %rbx,%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1040 <atof@plt>
addsd  (%rsp),%xmm0
lea    0xe6d(%rip),%rdi
call   1030 <masprintf@plt>
test   %rax,%rax
jne    119f <add_len_strings+0x5f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe54(%rip),%rdi
call   1060 <strdup@plt>
test   %rax,%rax
jne    119f <add_len_strings+0x5f>
jmp    119d <add_len_strings+0x5d>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%g\00"
define i8* @add_len_strings(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %12, %2
%17 = load i8*, i8** %4
%18 = call double @atof(i8* %17)
store double %18, double* %7
%19 = load i8*, i8** %5
%20 = call double @atof(i8* %19)
store double %20, double* %8
%21 = load double, double* %7
%22 = load double, double* %8
%23 = fadd double %21, %22
%24 = call i8* @masprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %23)
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = icmp eq i8* null, %25
br i1 %26, label %27, label %28
27: ; preds = %16
store i8* null, i8** %3
br label %37
28: ; preds = %16
br label %35
29: ; preds = %12
%30 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = icmp eq i8* null, %31
br i1 %32, label %33, label %34
33: ; preds = %29
store i8* null, i8** %3
br label %37
34: ; preds = %29
br label %35
35: ; preds = %34, %28
%36 = load i8*, i8** %6
store i8* %36, i8** %3
br label %37
37: ; preds = %35, %33, %27
%38 = load i8*, i8** %3
ret i8* %38
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%g\00"
define i8* @add_len_strings(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5, %2
%9 = tail call double @atof(i8* %0)
%10 = tail call double @atof(i8* %1)
%11 = fadd double %9, %10
%12 = tail call i8* @masprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %17
14: ; preds = %5
%15 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14, %8
%18 = phi i8* [ %12, %8 ], [ %15, %14 ]
br label %19
19: ; preds = %14, %8, %17
%20 = phi i8* [ %18, %17 ], [ null, %8 ], [ null, %14 ]
ret i8* %20
}