#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 *_addStrings(char *, char *, int, int);
int strlen(char *);
char *addStrings(char *num1, char *num2) {
  int len1 = strlen(num1);
  int len2 = strlen(num2);
  if (len1 >= len2)
    return _addStrings(num1, num2, len1, len2);
  return _addStrings(num2, num1, len2, len1);
}


x86 assembly (clang, -O0):
<addStrings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     1170 <addStrings+0x50>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <_addStrings@plt>
mov    %rax,-0x8(%rbp)
jmp    1187 <addStrings+0x67>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <_addStrings@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addStrings>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jge    1149 <addStrings+0x29>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
jmp    1153 <addStrings+0x33>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <_addStrings@plt>

LLVM IR (-O0):
define i8* @addStrings(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i8* @_addStrings(i8* %16, i8* %17, i32 %18, i32 %19)
store i8* %20, i8** %3
br label %27
21: ; preds = %2
%22 = load i8*, i8** %5
%23 = load i8*, i8** %4
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = call i8* @_addStrings(i8* %22, i8* %23, i32 %24, i32 %25)
store i8* %26, i8** %3
br label %27
27: ; preds = %21, %15
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
define i8* @addStrings(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp slt i32 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i8* @_addStrings(i8* %0, i8* %1, i32 %3, i32 %4)
br label %10
8: ; preds = %2
%9 = tail call i8* @_addStrings(i8* %1, i8* %0, i32 %4, i32 %3)
br label %10
10: ; preds = %8, %6
%11 = phi i8* [ %7, %6 ], [ %9, %8 ]
ret i8* %11
}