#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 */
struct vtkWPString {
  int dummy;
};

/* Variables and functions */
scalar_t__ strtoul(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ vtkWPString_Append(struct vtkWPString *, char const *);
void vtkWrapText_PythonArraySignature(struct vtkWPString *result,
                                      const char *classname,
                                      const char *braces[2], int ndim,
                                      const char **dims) {
  int j, n;
  vtkWPString_Append(result, braces[0]);
  n = (int)strtoul(dims[0], 0, 0);
  if (ndim > 1) {
    for (j = 0; j < n; j++) {
      if (j != 0) {
        vtkWPString_Append(result, ", ");
      }
      vtkWrapText_PythonArraySignature(result, classname, braces, ndim - 1,
                                       dims + 1);
    }
  } else {
    for (j = 0; j < n; j++) {
      if (j != 0) {
        vtkWPString_Append(result, ", ");
      }
      vtkWPString_Append(result, classname);
    }
  }
  vtkWPString_Append(result, braces[1]);
}


x86 assembly (clang, -O0):
<vtkWrapText_PythonArraySignature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1040 <vtkWPString_Append@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <strtoul@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    11d7 <vtkWrapText_PythonArraySignature+0xa7>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11d2 <vtkWrapText_PythonArraySignature+0xa2>
cmpl   $0x0,-0x2c(%rbp)
je     11a5 <vtkWrapText_PythonArraySignature+0x75>
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <vtkWPString_Append@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%r8
add    $0x8,%r8
call   1030 <vtkWrapText_PythonArraySignature@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117f <vtkWrapText_PythonArraySignature+0x4f>
jmp    1224 <vtkWrapText_PythonArraySignature+0xf4>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    121f <vtkWrapText_PythonArraySignature+0xef>
cmpl   $0x0,-0x2c(%rbp)
je     1204 <vtkWrapText_PythonArraySignature+0xd4>
mov    -0x8(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1040 <vtkWPString_Append@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vtkWPString_Append@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11de <vtkWrapText_PythonArraySignature+0xae>
jmp    1224 <vtkWrapText_PythonArraySignature+0xf4>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <vtkWPString_Append@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vtkWrapText_PythonArraySignature>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r13
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdx),%rsi
call   1040 <vtkWPString_Append@plt>
mov    0x0(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,%rbx
cmp    $0x1,%ebp
jle    11b9 <vtkWrapText_PythonArraySignature+0x89>
test   %ebx,%ebx
jle    11fb <vtkWrapText_PythonArraySignature+0xcb>
add    $0xffffffff,%ebp
add    $0x8,%r13
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %r13,%r8
call   1030 <vtkWrapText_PythonArraySignature@plt>
cmp    $0x1,%ebx
je     11fb <vtkWrapText_PythonArraySignature+0xcb>
add    $0xffffffff,%ebx
mov    %r12,%rdi
lea    0xe66(%rip),%rsi
call   1040 <vtkWPString_Append@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %r13,%r8
call   1030 <vtkWrapText_PythonArraySignature@plt>
add    $0xffffffff,%ebx
jne    1190 <vtkWrapText_PythonArraySignature+0x60>
jmp    11fb <vtkWrapText_PythonArraySignature+0xcb>
test   %ebx,%ebx
jle    11fb <vtkWrapText_PythonArraySignature+0xcb>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <vtkWPString_Append@plt>
cmp    $0x1,%ebx
je     11fb <vtkWrapText_PythonArraySignature+0xcb>
add    $0xffffffff,%ebx
lea    0xe29(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <vtkWPString_Append@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <vtkWPString_Append@plt>
add    $0xffffffff,%ebx
jne    11e0 <vtkWrapText_PythonArraySignature+0xb0>
mov    0x8(%r14),%rsi
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <vtkWPString_Append@plt>

LLVM IR (-O0):
%struct.vtkWPString = type { i32 }
@.str = [3 x i8] c", \00"
define void @vtkWrapText_PythonArraySignature(%struct.vtkWPString* %0, i8* %1, i8** %2, i32 %3, i8** %4) {
%6 = alloca %struct.vtkWPString*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
store %struct.vtkWPString* %0, %struct.vtkWPString** %6
store i8* %1, i8** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i8** %4, i8*** %10
%13 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%14 = load i8**, i8*** %8
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @vtkWPString_Append(%struct.vtkWPString* %13, i8* %16)
%18 = load i8**, i8*** %10
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i64 @strtoul(i8* %20, i32 0, i32 0)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %12
%23 = load i32, i32* %9
%24 = icmp sgt i32 %23, 1
br i1 %24, label %25, label %48
25: ; preds = %5
store i32 0, i32* %11
br label %26
26: ; preds = %44, %25
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = load i32, i32* %11
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%35 = call i32 @vtkWPString_Append(%struct.vtkWPString* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %33, %30
%37 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%38 = load i8*, i8** %7
%39 = load i8**, i8*** %8
%40 = load i32, i32* %9
%41 = sub nsw i32 %40, 1
%42 = load i8**, i8*** %10
%43 = getelementptr inbounds i8*, i8** %42, i64 1
br label %44
44: ; preds = %36
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %26
47: ; preds = %26
br label %67
48: ; preds = %5
store i32 0, i32* %11
br label %49
49: ; preds = %63, %48
%50 = load i32, i32* %11
%51 = load i32, i32* %12
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %66
53: ; preds = %49
%54 = load i32, i32* %11
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%58 = call i32 @vtkWPString_Append(%struct.vtkWPString* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %59
59: ; preds = %56, %53
%60 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%61 = load i8*, i8** %7
%62 = call i32 @vtkWPString_Append(%struct.vtkWPString* %60, i8* %61)
br label %63
63: ; preds = %59
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %49
66: ; preds = %49
br label %67
67: ; preds = %66, %47
%68 = load %struct.vtkWPString*, %struct.vtkWPString** %6
%69 = load i8**, i8*** %8
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = call i32 @vtkWPString_Append(%struct.vtkWPString* %68, i8* %71)
ret void
}

LLVM IR (-O2):
%struct.vtkWPString = type { i32 }
@.str = [3 x i8] c", \00"
define void @vtkWrapText_PythonArraySignature(%struct.vtkWPString* %0, i8* %1, i8** nocapture %2, i32 %3, i8** nocapture %4) {
%6 = load i8*, i8** %2
%7 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* %6)
%8 = load i8*, i8** %4
%9 = tail call i64 @strtoul(i8* %8, i32 0, i32 0)
%10 = trunc i64 %9 to i32
%11 = icmp sgt i32 %3, 1
%12 = icmp sgt i32 %10, 0
br i1 %11, label %17, label %13
13: ; preds = %5
br i1 %12, label %14, label %33
14: ; preds = %13
%15 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* %1)
%16 = icmp eq i32 %10, 1
br i1 %16, label %33, label %27
17: ; preds = %5
br i1 %12, label %18, label %33
18: ; preds = %17
%19 = add nsw i32 %3, -1
%20 = getelementptr inbounds i8*, i8** %4, i64 1
tail call void @vtkWrapText_PythonArraySignature(%struct.vtkWPString* %0, i8* %1, i8** %2, i32 %19, i8** %20)
%21 = icmp eq i32 %10, 1
br i1 %21, label %33, label %22
22: ; preds = %18, %22
%23 = phi i32 [ %25, %22 ], [ 1, %18 ]
%24 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
tail call void @vtkWrapText_PythonArraySignature(%struct.vtkWPString* %0, i8* %1, i8** %2, i32 %19, i8** %20)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %10
br i1 %26, label %33, label %22
27: ; preds = %14, %27
%28 = phi i32 [ %31, %27 ], [ 1, %14 ]
%29 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* %1)
%31 = add nuw nsw i32 %28, 1
%32 = icmp eq i32 %31, %10
br i1 %32, label %33, label %27
33: ; preds = %27, %22, %14, %18, %13, %17
%34 = getelementptr inbounds i8*, i8** %2, i64 1
%35 = load i8*, i8** %34
%36 = tail call i32 @vtkWPString_Append(%struct.vtkWPString* %0, i8* %35)
ret void
}