#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 *get_bitstr(int, int);
int getint(char *);
int strlen(char *);
char *addbits(char str1[], char str2[]) {
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  int x = getint(str1);
  int y = getint(str2);
  int z = x + y;
  char *res = get_bitstr(z, (len1 > len2) ? len1 : len2);
  return res;
}


x86 assembly (clang, -O0):
<addbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getint@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getint@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1196 <addbits+0x66>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    119c <addbits+0x6c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1050 <get_bitstr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addbits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <getint@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <getint@plt>
add    %eax,%ebx
cmp    %ebp,%r15d
cmovg  %r15d,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <get_bitstr@plt>

LLVM IR (-O0):
define i8* @addbits(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 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %6
%15 = load i8*, i8** %3
%16 = call i32 @getint(i8* %15)
store i32 %16, i32* %7
%17 = load i8*, i8** %4
%18 = call i32 @getint(i8* %17)
store i32 %18, i32* %8
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = add nsw i32 %19, %20
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = load i32, i32* %5
br label %30
28: ; preds = %2
%29 = load i32, i32* %6
br label %30
30: ; preds = %28, %26
%31 = phi i32 [ %27, %26 ], [ %29, %28 ]
%32 = call i8* @get_bitstr(i32 %22, i32 %31)
store i8* %32, i8** %10
%33 = load i8*, i8** %10
ret i8* %33
}

LLVM IR (-O2):
define i8* @addbits(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @getint(i8* %0)
%6 = tail call i32 @getint(i8* %1)
%7 = add nsw i32 %6, %5
%8 = icmp sgt i32 %3, %4
%9 = select i1 %8, i32 %3, i32 %4
%10 = tail call i8* @get_bitstr(i32 %7, i32 %9)
ret i8* %10
}