#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 /*<<< orphan*/ free(char *);
char *shift(char *, int);
char *sum(char **, char **);
char *combine(char **z1, char **z2, char **z3, int n) {
  char *z1_shift, *z3_shift;
  char *res, *res_tmp;
  z1_shift = shift(*z1, (n - n / 2) * 2);
  z3_shift = shift(*z3, (n - n / 2));
  res_tmp = sum(&z1_shift, &z3_shift);
  res = sum(&res_tmp, z2);
  free(z1_shift);
  free(z3_shift);
  free(res_tmp);
  return res;
}


x86 assembly (clang, -O0):
<combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
shl    $0x1,%esi
call   1050 <shift@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
call   1050 <shift@plt>
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <sum@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1040 <sum@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rsi,%r14
mov    (%rdi),%rdi
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
sub    %eax,%ebx
lea    (%rbx,%rbx,1),%esi
call   1050 <shift@plt>
mov    %rax,0x18(%rsp)
mov    (%r15),%rdi
mov    %ebx,%esi
call   1050 <shift@plt>
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <sum@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1040 <sum@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @combine(i8** %0, i8** %1, i8** %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = load i32, i32* %8
%16 = load i32, i32* %8
%17 = sdiv i32 %16, 2
%18 = sub nsw i32 %15, %17
%19 = mul nsw i32 %18, 2
%20 = call i8* @shift(i8* %14, i32 %19)
store i8* %20, i8** %9
%21 = load i8**, i8*** %7
%22 = load i8*, i8** %21
%23 = load i32, i32* %8
%24 = load i32, i32* %8
%25 = sdiv i32 %24, 2
%26 = sub nsw i32 %23, %25
%27 = call i8* @shift(i8* %22, i32 %26)
store i8* %27, i8** %10
%28 = call i8* @sum(i8** %9, i8** %10)
store i8* %28, i8** %12
%29 = load i8**, i8*** %6
%30 = call i8* @sum(i8** %12, i8** %29)
store i8* %30, i8** %11
%31 = load i8*, i8** %9
%32 = call i32 @free(i8* %31)
%33 = load i8*, i8** %10
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %12
%36 = call i32 @free(i8* %35)
%37 = load i8*, i8** %11
ret i8* %37
}

LLVM IR (-O2):
define i8* @combine(i8** nocapture %0, i8** %1, i8** nocapture %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = bitcast i8** %5 to i8*
%9 = bitcast i8** %6 to i8*
%10 = bitcast i8** %7 to i8*
%11 = load i8*, i8** %0
%12 = sdiv i32 %3, -2
%13 = add i32 %12, %3
%14 = shl nsw i32 %13, 1
%15 = tail call i8* @shift(i8* %11, i32 %14)
store i8* %15, i8** %5
%16 = load i8*, i8** %2
%17 = tail call i8* @shift(i8* %16, i32 %13)
store i8* %17, i8** %6
%18 = call i8* @sum(i8** %5, i8** %6)
store i8* %18, i8** %7
%19 = call i8* @sum(i8** %7, i8** %1)
%20 = load i8*, i8** %5
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %7
%25 = call i32 @free(i8* %24)
ret i8* %19
}