#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 GenerateArraySpecification(char *, char *, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int strlen(char *);
int GenerateArraySpec2(char *iname, char *ispec, char *ospec, int olen) {
  char *buf;
  int len;
  int got = 0;
  len = strlen(iname) + strlen(ispec) + 2;
  buf = (char *)malloc(len);
  snprintf(buf, len, "%s %s", iname, ispec);
  if (*buf) {
    got = GenerateArraySpecification(buf, ospec, olen);
    free(buf);
  }
  return got;
}


x86 assembly (clang, -O0):
<GenerateArraySpec2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe4e(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e0 <GenerateArraySpec2+0x90>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <GenerateArraySpecification@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenerateArraySpec2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%ebx
add    $0x2,%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
lea    0xe73(%rip),%rdx
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r13,%rcx
mov    %r12,%r8
call   1060 <snprintf@plt>
cmpb   $0x0,0x0(%rbp)
je     11bf <GenerateArraySpec2+0x6f>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <GenerateArraySpecification@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
jmp    11c1 <GenerateArraySpec2+0x71>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
define i32 @GenerateArraySpec2(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 i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 2
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i32, i32* %10
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @snprintf(i8* %21, i32 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i8*, i8** %9
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %4
%30 = load i8*, i8** %9
%31 = load i8*, i8** %7
%32 = load i32, i32* %8
%33 = call i32 @GenerateArraySpecification(i8* %30, i8* %31, i32 %32)
store i32 %33, i32* %11
%34 = load i8*, i8** %9
%35 = call i32 @free(i8* %34)
br label %36
36: ; preds = %29, %4
%37 = load i32, i32* %11
ret i32 %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
define i32 @GenerateArraySpec2(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = add i32 %5, 2
%8 = add i32 %7, %6
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @snprintf(i8* %10, i32 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = tail call i32 @GenerateArraySpecification(i8* %10, i8* %2, i32 %3)
%16 = tail call i32 @free(i8* %10)
br label %17
17: ; preds = %14, %4
%18 = phi i32 [ %15, %14 ], [ 0, %4 ]
ret i32 %18
}