#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*/ sprintf(char *, char *, char *, char *, char *);
char *string_alloc(scalar_t__);
scalar_t__ string_length(char *);
char *smt_binary(char *opt, char *op1, char *op2) {
  char *string;
  string = string_alloc(1 + string_length(opt) + 1 + string_length(op1) + 1 +
                        string_length(op2) + 1);
  sprintf(string, "(%s %s %s)", opt, op1, op2);
  return string;
}


x86 assembly (clang, -O0):
<smt_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <string_length@plt>
add    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <string_length@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <string_length@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1030 <string_alloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe58(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smt_binary>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1040 <string_length@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1040 <string_length@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <string_length@plt>
add    %r12,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0x4,%rdi
call   1030 <string_alloc@plt>
mov    %rax,%rbx
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"(%s %s %s)\00"
define i8* @smt_binary(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i64 @string_length(i8* %8)
%10 = add nsw i64 1, %9
%11 = add nsw i64 %10, 1
%12 = load i8*, i8** %5
%13 = call i64 @string_length(i8* %12)
%14 = add nsw i64 %11, %13
%15 = add nsw i64 %14, 1
%16 = load i8*, i8** %6
%17 = call i64 @string_length(i8* %16)
%18 = add nsw i64 %15, %17
%19 = add nsw i64 %18, 1
%20 = call i8* @string_alloc(i64 %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i8* %24)
%26 = load i8*, i8** %7
ret i8* %26
}

LLVM IR (-O2):
@.str = [11 x i8] c"(%s %s %s)\00"
define i8* @smt_binary(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @string_length(i8* %0)
%5 = tail call i64 @string_length(i8* %1)
%6 = tail call i64 @string_length(i8* %2)
%7 = add i64 %4, 4
%8 = add i64 %7, %5
%9 = add i64 %8, %6
%10 = tail call i8* @string_alloc(i64 %9)
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
ret i8* %10
}