#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 */
typedef int /*<<< orphan*/ test_string;

/* Variables and functions */
int test_parse(int, char *, char *);
int lisp_test1() {
  char *test_string[] = {"(A B C)",   "((A) B C)", "((A B) C D)",
                         "(A (B) C)", "(A B (C))", "((A) (B) (C))",
                         "(((A B)))", "(abc efg)", "(a . b)"};
  char *test_result[] = {"(A . (B . (C . nil)))",
                         "((A . nil) . (B . (C . nil)))",
                         "((A . (B . nil)) . (C . (D . nil)))",
                         "(A . ((B . nil) . (C . nil)))",
                         "(A . (B . ((C . nil) . nil)))",
                         "((A . nil) . ((B . nil) . ((C . nil) . nil)))",
                         "(((A . (B . nil)) . nil) . nil)",
                         "(abc . (efg . nil))",
                         "(a . b)"};
  int count = 0;
  int i;
  for (i = 0; i < sizeof(test_string) / sizeof(char *); i++) {
    count = test_parse(i, test_string[i], test_result[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<lisp_test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x50(%rbp),%rdi
lea    0x2c4a(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0x2c82(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
cmp    $0x9,%rax
jae    11bd <lisp_test1+0x9d>
mov    -0xa8(%rbp),%edi
movslq -0xa8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
movslq -0xa8(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rdx
ff
call   1030 <test_parse@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    116c <lisp_test1+0x4c>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lisp_test1>:
push   %rax
lea    0xee8(%rip),%rsi
lea    0xf3d(%rip),%rdx
xor    %edi,%edi
call   1030 <test_parse@plt>
lea    0xedb(%rip),%rsi
lea    0xf3e(%rip),%rdx
mov    $0x1,%edi
call   1030 <test_parse@plt>
lea    0xecd(%rip),%rsi
lea    0xf44(%rip),%rdx
mov    $0x2,%edi
call   1030 <test_parse@plt>
lea    0xec1(%rip),%rsi
lea    0xf50(%rip),%rdx
mov    $0x3,%edi
call   1030 <test_parse@plt>
lea    0xeb3(%rip),%rsi
lea    0xf56(%rip),%rdx
mov    $0x4,%edi
call   1030 <test_parse@plt>
lea    0xea5(%rip),%rsi
lea    0xf5c(%rip),%rdx
mov    $0x5,%edi
call   1030 <test_parse@plt>
lea    0xe9b(%rip),%rsi
lea    0xf72(%rip),%rdx
mov    $0x6,%edi
call   1030 <test_parse@plt>
lea    0xe8d(%rip),%rsi
lea    0xf7a(%rip),%rdx
mov    $0x7,%edi
call   1030 <test_parse@plt>
lea    0xe7f(%rip),%rdx
mov    $0x8,%edi
mov    %rdx,%rsi
call   1030 <test_parse@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"(A B C)\00"
@.str.1 = [10 x i8] c"((A) B C)\00"
@.str.2 = [12 x i8] c"((A B) C D)\00"
@.str.3 = [10 x i8] c"(A (B) C)\00"
@.str.4 = [10 x i8] c"(A B (C))\00"
@.str.5 = [14 x i8] c"((A) (B) (C))\00"
@.str.6 = [10 x i8] c"(((A B)))\00"
@.str.7 = [10 x i8] c"(abc efg)\00"
@.str.8 = [8 x i8] c"(a . b)\00"
@__const.lisp_test1.test_string = [9 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0)]
@.str.9 = [22 x i8] c"(A . (B . (C . nil)))\00"
@.str.10 = [30 x i8] c"((A . nil) . (B . (C . nil)))\00"
@.str.11 = [36 x i8] c"((A . (B . nil)) . (C . (D . nil)))\00"
@.str.12 = [30 x i8] c"(A . ((B . nil) . (C . nil)))\00"
@.str.13 = [30 x i8] c"(A . (B . ((C . nil) . nil)))\00"
@.str.14 = [46 x i8] c"((A . nil) . ((B . nil) . ((C . nil) . nil)))\00"
@.str.15 = [32 x i8] c"(((A . (B . nil)) . nil) . nil)\00"
@.str.16 = [20 x i8] c"(abc . (efg . nil))\00"
@__const.lisp_test1.test_result = [9 x i8*] [i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0)]
define i32 @lisp_test1() {
%1 = alloca [9 x i8*]
%2 = alloca [9 x i8*]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [9 x i8*]* %1 to i8*
%6 = bitcast [9 x i8*]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 9
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = load i32, i32* %4
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [9 x i8*], [9 x i8*]* %1, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [9 x i8*], [9 x i8*]* %2, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @test_parse(i32 %12, i8* %16, i8* %20)
store i32 %21, i32* %3
br label %22
22: ; preds = %11
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %7
25: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"(A B C)\00"
@.str.1 = [10 x i8] c"((A) B C)\00"
@.str.2 = [12 x i8] c"((A B) C D)\00"
@.str.3 = [10 x i8] c"(A (B) C)\00"
@.str.4 = [10 x i8] c"(A B (C))\00"
@.str.5 = [14 x i8] c"((A) (B) (C))\00"
@.str.6 = [10 x i8] c"(((A B)))\00"
@.str.7 = [10 x i8] c"(abc efg)\00"
@.str.8 = [8 x i8] c"(a . b)\00"
@.str.9 = [22 x i8] c"(A . (B . (C . nil)))\00"
@.str.10 = [30 x i8] c"((A . nil) . (B . (C . nil)))\00"
@.str.11 = [36 x i8] c"((A . (B . nil)) . (C . (D . nil)))\00"
@.str.12 = [30 x i8] c"(A . ((B . nil) . (C . nil)))\00"
@.str.13 = [30 x i8] c"(A . (B . ((C . nil) . nil)))\00"
@.str.14 = [46 x i8] c"((A . nil) . ((B . nil) . ((C . nil) . nil)))\00"
@.str.15 = [32 x i8] c"(((A . (B . nil)) . nil) . nil)\00"
@.str.16 = [20 x i8] c"(abc . (efg . nil))\00"
define i32 @lisp_test1() {
%1 = tail call i32 @test_parse(i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%2 = tail call i32 @test_parse(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%3 = tail call i32 @test_parse(i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%4 = tail call i32 @test_parse(i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%5 = tail call i32 @test_parse(i32 4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%6 = tail call i32 @test_parse(i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%7 = tail call i32 @test_parse(i32 6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0))
%8 = tail call i32 @test_parse(i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%9 = tail call i32 @test_parse(i32 8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}